Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

21
Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming

Transcript of Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Page 1: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Review for Final

Andy WangData Structures, Algorithms, and

Generic Programming

Page 2: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Final Exam (Wed 12/3)

• 25%: Lectures 1 - 7• 25%: Lectures 8 - 15• 50%: Lectures 16 - 22

Page 3: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Strings and BitVectors

• Three characteristics of a proper type

• Two major advantages of C++ strings over C strings

• How to set/unset/test nth bit in a char

Page 4: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Hash functions and templates

• Hash functions• Description• Properties

• Three design principles for hashing a sequence of keys

• Implement simple template classes/functions

Page 5: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Search Algorithms

• Definition of invariants• Big “O” notation (worst case

running time)

Page 6: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Linked Lists and Deques

• List vs. vector vs. deque• Implement list operations• Why multiple iterators for a given

class• pContainers vs. aContainers• How to compute the size of a

deque and why

Page 7: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Stacks and Queues

• Implement of DFS and BFS in pseudo code

• How to implement a queue with a stack

• How to implement a stack with a queue

Page 8: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Function Objects and Generic Algorithms

• Advantages of function objects• Implement generic copy, find,

max, sort• Running time of generic sort

Page 9: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Iterators and Generic Set Algorithms

• Types of iterators and when to use what

• Conceptual understanding of set operations

• Implement union, intersection, difference, containment, merge

Page 10: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Sets and Maps

• How to use set operations to find out words not in a dictionary

• How to use sets to implement maps

• How to use maps to implement linked lists and trees

Page 11: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Trees 1

• Definitions: graph, tree, depth, leaf, binary tree, complete binary tree, partially ordered tree, heap

• Traversals: preorder, postorder, levelorder, inorder

• How to use nodes listed in different orders to uniquely identify a tree

Page 12: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Trees 1

• Total number of vertices in a complete binary tree

• Total number of leafs in a complete binary tree

• What if we have a complete tri-nary tree?

Page 13: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Trees 1

• How to use a vector to represent a complete binary tree

• How do you access parent, left child, and right child?

• Heap operations• Push (bottom up)• Pop (top down)

Page 14: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Trees 1

• Heap operations• Push (bottom up)• Pop (top down)

Page 15: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Trees 2

• Tree navigators vs. iterators• For a complete binary tree, which

node is the first node for an inorder traversal? Which node is the last?

Page 16: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Trees 2

• For a complete binary tree, which node is the first node for a preorder traversal? Which node is the last?

Page 17: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Trees 2

• For a complete binary tree, which node is the first node for a postorder traversal? Which node is the last?

Page 18: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Trees 2

• For a complete binary tree, which node is the first node for a levelorder traversal? Which node is the last?

• How to implement a levelorder binary tree iterator

Page 19: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Trees 3

• How to store a tree in a file• How to perform node insertion and

removal

Page 20: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Trees 4

• Definition: totally ordered tree• How to perform a binary tree with

a binary search tree• Best and worst running time of

binary search via a binary search tree

Page 21: Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.

Trees 4

• How to improve the average running time of binary search via a binary search tree