Presentation is loading. Please wait.

Presentation is loading. Please wait.

Final Exam Review COP4530.

Similar presentations


Presentation on theme: "Final Exam Review COP4530."— Presentation transcript:

1 Final Exam Review COP4530

2 A high-level summary of what we learned
Algorithm analysis Data structures Vector, List, Deque STL sequence containers Stack, Queue, Priority queues STL adaptor containers Set and map (multiset, multimap) Hashing tables (unordered_set, unordered_map) STL associative containers Trees set and map in STL implemented using binary search tree Graphs (not covered) Available in Boost Algorithms Various algorithms associated with data structures Various sorting algorithms DFS/BFS, infix to postfix conversion, postfix evaluation Graph algorithms (not covered)

3 f(n) is asymptotically
Big “O” Notation f(n) =O(g(n)) If and only if there exist two constants c > 0 and n0 > 0, such that f(n) < cg(n) for all n >= n0 iff  c, n0 > 0 | 0 < f(n) < cg(n)  n >= n0 cg(n) f(n) f(n) is asymptotically upper bounded by g(n) n0

4 f(n) is asymptotically
Big “Omega” Notation f(n) = (g(n)) iff  c, n0 > 0 | 0 < cg(n) < f(n)  n >= n0 f(n) cg(n) f(n) is asymptotically lower bounded by g(n) n0

5 Big “Theta” Notation f(n) = (g(n)) c2g(n) f(n) f(n) has the
iff  c1, c2, n0 > 0 | 0 < c1g(n) < f(n) < c2g(n)  n >= n0 c2g(n) f(n) f(n) has the same long-term rate of growth as g(n) c1g(n) n0

6 C++ Standard Template Library (STL)
Template based Generic programming One definition works for all types (proper type) Containers – data structures vector, list, deque, priority_queue, set, map, unordered_set, unordered_map, … Algorithms Sorting algorithms, and many others Iterators – to access elements of the containers Encapsulating difference among distinct data structures Common interface for generic algorithms

7 Generic programming basics
How to write template classes Also template function Iterators Const Iterators Unidirectional vs. bidirectional iterators

8 STL Container implementation
Data members (member variables) Constructors Destructor Methods Iterators Overloaded operators The Big five – copy and move assignment operators, copy and move constructors, destructor

9 Basic STL Containers Vector List Familiarity
Similar to array in operation Index-referenced elements (random element access) RESIZABLE First-class objects List Linked list – one element points to next one Singly/Doubly linked list STL List implemented as DOUBLY LINKED STL forward_list is singly linked Familiarity Use of basic operations Implementation of each container

10 Double Ended Queues Deque Operations on a Deque
How is it different from Vector? Deque Implementation Using a circular array Locating the front and the back positions of the deque Calculating the size of the deque Accessing the ith element in the deque How a deque should be implemented if we maintain an explicit size member variable? In particular, member functions front, push_front, pop_front

11 Stack ADT Basic Operations Implementation Common uses of Stack
First In, Last Out Implementation Using an Adaptor Class Common uses of Stack Depth first search Evaluation of postfix expressions Conversion from infix to postfix expressions Matching brackets Function calls Recursion

12 Queue ADT Basic operations Implementation Common uses of Queue
First In, First Out Implementation Using an Adaptor Class Common uses of Queue Breadth first search Buffers Simulations Producer-Consumer Problems

13 Depth First Search How does it work
How to use stack for conducting DFS DFS algorithm implementation

14 Breadth First Search How does it work
How to use queues for conducting BFS BFS algorithm implementation

15 Positional Containers
Definition? Examples? Also called sequential containers in STL terms

16 Trees – Basic Theory Definitions Tree, Rooted Tree
Depth/Height of Vertex Depth/Height of Tree. Descending Path Parent, Child, Sibling, Ancestor, Descendant Root, Leaf

17 Tree Implementation Structure of a node
Linking the children and siblings with constant space for a Node.

18 Generic Tree traversals
Preorder traversal Postorder traversal Levelorder traversal Inorder traversal for binary trees

19 Binary trees Definition Structure representation
Complete Binary Tree Structure representation Relation between number of nodes n and height H of a complete binary tree Levelorder traversal How to compute the height of a tree? Vector representation of a complete binary tree

20 Binary Search Tree Not the same as a binary tree
Also known as Totally Ordered Tree Finding an element Finding the smallest element Finding the largest element Search complexity Best case, Worst case, Average case BST implementation Recursive implementation of tree operations such as insert and delete

21 BST Anomalies Why BST may not necessarily be balanced?
Insertion of element In sorted order Or even mostly sorted order Deletion Bias Why does it arise? Simple ways to overcome the bias.

22 AVL trees Definition of AVL trees Implementation of AVL trees
Building AVL trees by inserting/deleting elements

23 M-ary Trees Definition Implementation Usefulness? M-ary tree
Complete M-ary tree Implementation Usefulness?

24 M-ary Search Trees Not the same as M-ary Trees Representation
Search process

25 B-Trees B = Balanced Conditions for M-ary tree to be called a B-tree
Inserting a value Inserting at a non-full leaf Inserting at a full leaf When to split a non-leaf node When to split the root Deletion Combining leaves, non-leaves Borrowing leaves from neighborhood When does the height of the tree grow? Reduce?

26 Associative Containers
Generic Associative Containers Unimodal vs. Multimodal associative containers Sets Regular set vs. Multi-set Maps Regular maps vs. Multi-maps

27 Hash Tables Basic principles of using hash tables
Designing a hash table Choosing a Hash Function Conflict Resolution Strategy Hash functions Properties of a good hash function

28 Conflict Resolution Strategies
Separate Chaining Linear Probing Quadratic Probing Double Hashing Rehashing

29 Priority Queue What is it? When is it useful? Operations
Push, pop, top, clear, empty Implementation Adaptor class: can use linked lists, Binary Search Trees, B-Trees, Heaps

30 Heaps Notion of partially ordered trees
Heap = partially ordered complete binary tree Vector representation of Heap Implementing different operations Push heap Pop heap Build heap Given a sequence of numbers, building a heap Insertion and deletion

31 Sorting Different sorting techniques Bubble sort Insertion sort
Algorithm details Best-case, worst-case and average case complexity of each Especially for the recursive algorithms Bubble sort Insertion sort Shell sort Heap sort Merge sort Quick sort Pivoting strategy Partitioning strategy Recursion

32 Graph algorithms Representations of Graphs Topological sorting
Shortest-path algorithms Unweighted version Weighted version


Download ppt "Final Exam Review COP4530."

Similar presentations


Ads by Google