Course Review COMP171 Spring 2009. Hashing / Slide 2 Elementary Data Structures * Linked lists n Types: singular, doubly, circular n Operations: insert,

Slides:



Advertisements
Similar presentations
Transform and Conquer Chapter 6. Transform and Conquer Solve problem by transforming into: a more convenient instance of the same problem (instance simplification)
Advertisements

©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
Advanced Data Structures
Binary Trees, Binary Search Trees CMPS 2133 Spring 2008.
Chapter 6: Transform and Conquer
Binary Trees, Binary Search Trees COMP171 Fall 2006.
CS 171: Introduction to Computer Science II
CSE 332 Review Slides Tyler Robison Summer
More sorting algorithms: Heap sort & Radix sort. Heap Data Structure and Heap Sort (Chapter 7.6)
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
Connected Components, Directed Graphs, Topological Sort COMP171.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (4) Data Structures 11/18/2008 Yang Song.
Lec 15 April 9 Topics: l binary Trees l expression trees Binary Search Trees (Chapter 5 of text)
Unit 11a 1 Unit 11: Data Structures & Complexity H We discuss in this unit Graphs and trees Binary search trees Hashing functions Recursive sorting: quicksort,
Data Structures, Spring 2004 © L. Joskowicz 1 DAST – Final Lecture Summary and overview What we have learned. Why it is important. What next.
Cpt S 223 – Advanced Data Structures Course Review Midterm Exam # 2
Important Problem Types and Fundamental Data Structures
Advanced Data Structures and Algorithms COSC-600 Lecture presentation-6.
CS112A1 Spring 2008 Practice Final. ASYMPTOTIC NOTATION: a)Show that log(n) and ln(n) are the same in terms of Big-Theta notation b)Show that log(n+1)
Compiled by: Dr. Mohammad Alhawarat BST, Priority Queue, Heaps - Heapsort CHAPTER 07.
Advanced Algorithms Analysis and Design Lecture 8 (Continue Lecture 7…..) Elementry Data Structures By Engr Huma Ayub Vine.
1 Hash Tables  a hash table is an array of size Tsize  has index positions 0.. Tsize-1  two types of hash tables  open hash table  array element type.
Review – Part 1 CSE 2011 Winter September 2015.
CS 3610 Midterm Review.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Review Midterm.
Final Review Dr. Yingwu Zhu. Goals Use appropriate data structures to solve real- world problems –E.g., use stack to implement non-recursive BST traversal,
Binary Trees, Binary Search Trees RIZWAN REHMAN CENTRE FOR COMPUTER STUDIES DIBRUGARH UNIVERSITY.
Sorting. Pseudocode of Insertion Sort Insertion Sort To sort array A[0..n-1], sort A[0..n-2] recursively and then insert A[n-1] in its proper place among.
Starting at Binary Trees
Final Exam Review CS Total Points – 60 Points Writing Programs – 50 Points Tracing Algorithms, determining results, and drawing pictures – 50.
Chapter 2: Basic Data Structures. Spring 2003CS 3152 Basic Data Structures Stacks Queues Vectors, Linked Lists Trees (Including Balanced Trees) Priority.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Review Final.
Review for Final Exam – cs411/511 Definitions (5 questions, 2 points each) Algorithm Analysis (3 questions, 3 points each) General Questions (3 questions,
Review for Final Exam Non-cumulative, covers material since exam 2 Data structures covered: –Treaps –Hashing –Disjoint sets –Graphs For each of these data.
CSS446 Spring 2014 Nan Wang.  to study trees and binary trees  to understand how binary search trees can implement sets  to learn how red-black trees.
Week 10 - Friday.  What did we talk about last time?  Graph representations  Adjacency matrix  Adjacency lists  Depth first search.
Binary Tree. Some Terminologies Short review on binary tree Tree traversals Binary Search Tree (BST)‏ Questions.
CIS 068 Welcome to CIS 068 ! Lesson 12: Data Structures 3 Trees.
CISC220 Fall 2009 James Atlas Dec 07: Final Exam Review.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
Lecture 10COMPSCI.220.FS.T Binary Search Tree BST converts a static binary search into a dynamic binary search allowing to efficiently insert and.
1 Joe Meehean. A A B B D D I I C C E E X X A A B B D D I I C C E E X X  Terminology each circle is a node pointers are edges topmost node is the root.
Hello Everyone!!! 1. Tree And Graphs 2 Features of Trees  Tree Nodes Each node have 0 or more children A node have must one parent  Binary tree Tree.
 Saturday, April 20, 8:30-11:00am in B9201  Similar in style to written midterm exam  May include (a little) coding on paper  About 1.5 times as long.
Final Exam Review CS Total Points – 20 Points Writing Programs – 65 Points Tracing Algorithms, determining results, and drawing pictures – 50.
1 the BSTree class  BSTreeNode has same structure as binary tree nodes  elements stored in a BSTree are a key- value pair  must be a class (or a struct)
Final Exam Review COP4530.
Final Exam Review CS 3358.
Trees Chapter 15.
DATA STRUCTURES AND OBJECT ORIENTED PROGRAMMING IN C++
Lecture 18. Basics and types of Trees
Week 11 - Friday CS221.
DATA STRUCTURES AND OBJECT ORIENTED PROGRAMMING IN C++
Cse 373 April 26th – Exam Review.
November 1st – Exam Review
Binary Trees, Binary Search Trees
Review for Midterm Neil Tang 03/04/2010
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
CSE 326: Data Structures: Midterm Review
Final Exam Review COP4530.
(2,4) Trees (2,4) Trees (2,4) Trees.
Chapter 6: Transform and Conquer
(2,4) Trees 2/15/2019 (2,4) Trees (2,4) Trees.
Binary Trees, Binary Search Trees
(2,4) Trees (2,4) Trees (2,4) Trees.
Final Review Dr. Yingwu Zhu.
DATA STRUCTURE.
Important Problem Types and Fundamental Data Structures
Binary Trees, Binary Search Trees
Heaps Chapter 6 Section 6.9.
Presentation transcript:

Course Review COMP171 Spring 2009

Hashing / Slide 2 Elementary Data Structures * Linked lists n Types: singular, doubly, circular n Operations: insert, find, delete O(N) * Stack ADT (array or linked-list) n First-in-Last-out n Operations: push, pop * Queue ADT (array or linked-list) n First-in-First-out n Operations: enqueue, dequeue * Priority queue (heap) n Heap-order property n Operations: insert and deleteMin (both O(log N) using array)

Hashing / Slide 3 Analysis of Algorithms * Worst case analysis n time and memory space n depends on the input (size, special features) and algorithms n growth rate of the functions * Asymptotic notations O(.): upper bound, “ at most ”, worst case, ≤ n Ω(.): lower bound, “at least”, best case, ≥ Θ(.): tight bound, O(.) && Ω(.), asymptotically “≈ ” growth rate

Hashing / Slide 4 Comparison-based Sorting Algorithms Algorithm s MethodWorst timeAverage time Memor y Insertion sort A[1 … p-1] are sorted, then insert A[p] O(N²) O(N + #Inversions) O(1) Mergesort Divide, conquer and merge O(N logN) O(N) Quicksort Pick pivot, partition, recursion O(N²) O(N logN)O(logN) Heapsort Build heap, deleteMin O(N logN) O(1)

Hashing / Slide 5 Other Sorting Algorithms * Theorem: Any comparison based sorting algorithm takes Ω(n logn) comparisons to sort a list of n distinct elements. * Non-comparison sorting n Rely on some special features of the input n Counting sort: O(N + Range) n Radix sort: O(N × #digits)

Hashing / Slide 6 Overview of the Forrest * Binary Trees n Binary Search Trees  AVL trees * M-ary Trees n B + -Trees * Terms: n root, leaves, child & parent, siblings, internal nodes, n height, paths & length, depth, n subtrees * Main theme: search, insertion, deletion.

Hashing / Slide 7 Binary Search Trees * Traversal n Pre-order, in-order, post-order * Average depth O(log N), max depth O(N), * Operations: n Search, findMin, findMax n Insertion n Deletion: 3 cases, recursive * All takes O(height of the tree).

Hashing / Slide 8 AVL Trees * Balanced BST n Height of an AVL tree is O(log N). * Search O(log N) * Insertion: 2 types of rebalancing O(log N) n Trace from the new node to the root, locate the unbalanced node, and at most one rotation. Single rotation for “ outside ” insertion Double rotation for “ inside ” insertion * Deletion O(log N) n Trace the deletion path, and more than one node may need rotation.

Hashing / Slide 9 B + -Trees * M-ary trees n The root is either a leaf or has 2 to M children (1 to M-1 keys). n Each internal node, except the root, has between  M/2  and M children (  M/2  - 1 and M - 1 keys). n Each leaf has between  L/2  and L keys and corresponding data items. n The data items are stored at leaves * Search * Insertion: always insert to a leaf n Possibly splitting leaf (and internal nodes) n Update the key in a internal node if necessary * Deletion n “Borrow” a key from your siblings n Merge two leaves (or internal nodes) – opposite to splitting

Hashing / Slide 10 Graph Essentials * Graph = Vertices + Edges * Representation n Adjacency matrix: O(N 2 ) space, O(1) access time n Adjacency list: O(M+N) space, O(N) access time * Keywords n subgraph, tree, acyclic graph n path, length, cycle, simple n directed, undirected n incident, degree, indegree / outdegree n connected components

Hashing / Slide 11 Graph Traversal: BFS * Connectivity and shortest path (from source) * Time: O(M+N) * Use visited table, predecessor list, and distance table * BFS tree

Hashing / Slide 12 Graph Traversal: DFS * Connectivity and cycle detection * Time: O(M+N) * Recursive function * DFS tree

Hashing / Slide 13 Topological Sort * Topological ordering on DAG and connectivity * Time: O(M+N) * Repeatedly remove zero-degreed vertices and the outgoing arcs * Linear ordering

Hashing / Slide 14 Hashing  Hashing is a function that maps a key (K) into an entry in a table (hash table), T[h(K)]. It only supports operations Find, insertion, deletion * The hashing function should be n Computationally fast, and efficient with O(1) complexity n Minimize the collisions, when T[h(K1)] = T[h)K2)] and K1 and K2 are two distinctive keys * Collision Resolution 1: Separate chaining * Collision Resolution 2: Open Addressing n Linear Probing n Quadratic Probing n Double hashing