datastructures presentation

Upload: baskarsingaram

Post on 01-Jun-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 DataStructures Presentation

    1/23

     

    Introduction to Data Structures

  • 8/9/2019 DataStructures Presentation

    2/23

     

    Data Structures

     A data structure is a scheme

    for organizing data in the

    memory of a computer.

    Some of the more commonly

    used data structures include

    lists, arrays, stacks, queues,

    heaps, trees, and graphs.Binary Tree

  • 8/9/2019 DataStructures Presentation

    3/23

  • 8/9/2019 DataStructures Presentation

    4/23

     

    "#ample$ A %ueue

     A queue is an e#ample of commonly used simple datastructure. A queue has !eginning and end, called the front  

    and back of the queue.

    Data enters the queue at one end and lea&es at the other.

    Because of this, data e#its the queue in the same order in

    which it enters the queue, like people in a checkout line at

    a supermarket.

  • 8/9/2019 DataStructures Presentation

    5/23

     

    "#ample$ A Binary Tree

     A binary tree is another

    commonly used data

    structure. It is organized like

    an upside down tree.

    "ach spot on the tree, called

    a node, holds an item of data

    along with a left pointer anda right pointer. Binary Tree

  • 8/9/2019 DataStructures Presentation

    6/23

     

    "#ample$ A Binary Tree

    The pointers are lined up

    so that the structure forms

    the upside down tree, with

    a single node at the top,called the root node, and

    !ranches increasing on the

    left and right as you go

    down the tree.Binary Tree

  • 8/9/2019 DataStructures Presentation

    7/23

     

    hoosing Data Structures

    By comparing the queue with

    the !inary tree, you can see

    how the structure of the data

    affects what can !e done

    efficiently with the data. 

  • 8/9/2019 DataStructures Presentation

    8/23

     

    hoosing Data Structures

     A queue is a good data structure

    to use for storing things that need

    to !e kept in order, such as a set

    of documents waiting to !e

    printed on a network printer.

    .

  • 8/9/2019 DataStructures Presentation

    9/23

  • 8/9/2019 DataStructures Presentation

    10/23

     

    hoosing Data Structures

     A !inary tree is a good data

    structure to use for searching

    sorted data.

    The middle item from the list isstored in the root node, with

    lesser items to the left and greater

    items to the right.

  • 8/9/2019 DataStructures Presentation

    11/23

     

    hoosing Data Structures

     A search !egins at the root. The

    computer either find the data, or

    mo&es left or right, depending on

    the &alue for which you are

    searching.

    "ach mo&e down the tree cuts the

    remaining data in half.

  • 8/9/2019 DataStructures Presentation

    12/23

     

    hoosing Data Structures

    Items can !e located &ery quicklyin a tree.

    Telephone directory assistanceinformation is stored in a tree, sothat a name and phone num!ercan !e found quickly.

  • 8/9/2019 DataStructures Presentation

    13/23

     

    hoosing Data Structures

    )or some applications, a queue isthe !est data structure to use.

    )or others, a !inary tree is !etter.

    *rogrammers choose fromamong many data structures!ased on how the data will !eused !y the program.

  • 8/9/2019 DataStructures Presentation

    14/23

     

    Data Structures in Alice

     Alice has two !uilt+in data structures

    that can !e used to organize data, or

    to create other data structures$

      -ists

      Arrays

  • 8/9/2019 DataStructures Presentation

    15/23

     

    -ists

     A list is an ordered set of data. It is often used to store

    o!'ects that are to !e processed sequentially.

     A list can !e used

     to create a queue.

  • 8/9/2019 DataStructures Presentation

    16/23

     

     Arrays

     An array is an inde#ed set of &aria!les, such as

    dancer /0, dancer 10, dancer 20,3 It is like a set of

    !o#es that hold things.

     A list is a set of items.

     An array is a set of 

    &aria!les that each

    store an item.

  • 8/9/2019 DataStructures Presentation

    17/23

     

     Arrays and -ists

    4ou can see the difference !etween arrays and

    lists when you delete items.

  • 8/9/2019 DataStructures Presentation

    18/23

     

     Arrays and -ists

    In a list, the missing spot is filled in when

    something is deleted.

  • 8/9/2019 DataStructures Presentation

    19/23

     

     Arrays and -ists

    In an array, an empty &aria!le is left !ehind

    when something is deleted.

  • 8/9/2019 DataStructures Presentation

    20/23

     

    -ists

     A list is created in Alice !y checking the make a

    list !o# when creating a new &aria!le.

    Make a list !o#

  • 8/9/2019 DataStructures Presentation

    21/23

     

    -ists

    The For all in order and For all together tiles can

    !e used to work with lists. They are at the

    !ottom of the editor area.

  • 8/9/2019 DataStructures Presentation

    22/23

     

     Arrays

     Arrays can !e created in a similar manner, !ut

    more often they are created using the array

    &isualization o!'ect from the Alice local gallery.

    The Array 5isualization o!'ect

    has special properties and

    methods for manipulatingthe elements in an array.

  • 8/9/2019 DataStructures Presentation

    23/23

     

     Arrays

     Alice has a set of !uilt+in functions that can !e

    performed on arrays.