Download Week 10 Review/Summary File

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Quadtree wikipedia , lookup

Linked list wikipedia , lookup

Binary search tree wikipedia , lookup

Array data structure wikipedia , lookup

Transcript
Data Structures & Algorithms: Week 10 Review/Summary
Some key ideas:
 A data structure is an arrangement of data in a computer’s memory.
 Algorithms manipulate data in these structures in various ways, such as searching for a particular data item and sorting data.
 Some algorithms may be implemented iteratively (using a loop) with others might be implemented recursively.
 An Abstract Data Type (ADT) is a set of data together with a set of operations on that data. The definition of an ADT does not
specify how the set of operations is implemented. Essentially, an ADT is a way of looking at a data structure, focusing on what
it does and ignoring how it does it.
So far, we have covered the following textbook chapters: 1, 2, 3, 4, 5, 6. 7 and 8.
Below are the abstract data types we have encountered so far.
Abstract Data
Type
List
Key operations
Insert / Add
Find an item
Delete / Remove
Get an item at a given position
Possible implementations we
have considered
Using an unsorted array (arraybased list)
Using a sorted array (sorted
array-based list)
Using a linked list (singly linked
list, or doubly-linked list)
Stack
Queue
Push
Pop
Top
Enqueue / Insert
Dequeue / Remove
Peek
Using an array or a linked list
Using an array or a linked list
Runtime of key operations when
using the specified implementation
Insert (at end) – O(1)
Find-item – O(N)
Delete (once found) – O(N)
Get-item-at-position – O(1)
Insert – O(N)
Find-item – O(log N)
Delete (once found) – O(N)
Get-item-at-position – O(1)
Insert (at beginning) – O(1)
Find-item – O(N)
Delete (once found) – O(1)
Get-item-at-position – O(N)
Push – O(1)
Pop – O(1)
Top – O(1)
Enqueue – O(1)
Pop – O(1)
Top – O(1)
Deque
Tree
Binary search
tree
Push
Pop
Insert
Eject
Pre-order traversal
Post-order traversal
Breadth-first or level-order
traversal
Insert
Find
Delete
Traversals (particularly inorder traversal
Using a circular array or a
doubly-linked list
Push – O(1)
Pop – O(1)
Insert – O(1)
Eject – O(1)
Using a linked structure in which Traversals – O(N)
each node holds a reference its
first child and next sibling
Using a linked structure in which * You should be able to answer this
each node holds a reference to
after the week 10 lab!
the left & right child. Methods
can be implemented recursively
or non-recursively.
Below are some special algorithms we have encountered so far in this class.
Task
Searching for an item in a 1-D array
Sorting an 1-D array of items
Algorithm
Linear / Sequential Search
Binary Search (only for sorted arrays)
Selection sort
Runtime
O(N) – where N is # of items in array
O(log N) – where N is # of items in array
O(N2) – where N is # of items in array
For each of the data structures and algorithms we have considered, you should understand:
 How they work
 Typical applications
 How to use them / apply them to a problem
o You should also be able to think through how to use them in non-obvious ways, e.g. the question about implementing a
queue with 2 stacks
 How to implement them
 How they perform – their runtime