Exam Review 3 Chapters 10 – 13, 15 CSC212 Section FG CS Dept, CCNY.

Slides:



Advertisements
Similar presentations
Exam Review 3 Chapters 10 – 13, 15 CSC212 Section FG CS Dept, CCNY.
Advertisements

Comp 122, Spring 2004 Binary Search Trees. btrees - 2 Comp 122, Spring 2004 Binary Trees  Recursive definition 1.An empty tree is a binary tree 2.A node.
Transform and Conquer Chapter 6. Transform and Conquer Solve problem by transforming into: a more convenient instance of the same problem (instance simplification)
@ Zhigang Zhu, CSC212 Data Structure - Section FG Lecture 22 Recursive Sorting, Heapsort & STL Quicksort Instructor: Zhigang Zhu Department.
@ Zhigang Zhu, CSC212 Data Structure - Section FG Lecture 19 Searching Instructor: Zhigang Zhu Department of Computer Science City College.
Data Structures: Trees i206 Fall 2010 John Chuang Some slides adapted from Marti Hearst, Brian Hayes, or Glenn Brookshear.
CS 206 Introduction to Computer Science II 11 / 04 / 2009 Instructor: Michael Eckmann.
© 2004 Goodrich, Tamassia Priority Queues1 Heaps: Tree-based Implementation of a Priority Queue.
Version TCSS 342, Winter 2006 Lecture Notes Priority Queues Heaps.
@ Zhigang Zhu, CSC212 Data Structure - Section RS Lecture 18a Trees, Logs and Time Analysis Instructor: Zhigang Zhu Department of Computer.
Graphs & Exam Review 3 Chapter 10 – 13 CS211 CS Dept, MHC.
Review for Test 2 i206 Fall 2010 John Chuang. 2 Topics  Operating System and Memory Hierarchy  Algorithm analysis and Big-O Notation  Data structures.
Chapter 6: Priority Queues Priority Queues Binary Heaps Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
Course Review COMP171 Spring Hashing / Slide 2 Elementary Data Structures * Linked lists n Types: singular, doubly, circular n Operations: insert,
1 TCSS 342, Winter 2005 Lecture Notes Priority Queues and Heaps Weiss Ch. 21, pp
© 2006 Pearson Addison-Wesley. All rights reserved11 A-1 Chapter 11 Trees.
Priority Queues1 Part-D1 Priority Queues. Priority Queues2 Priority Queue ADT (§ 7.1.3) A priority queue stores a collection of entries Each entry is.
Fundamentals of Python: From First Programs Through Data Structures
Trees Main and Savitch Chapter 10. Binary Trees A binary tree has nodes, similar to nodes in a linked list structure. Data of one sort or another may.
1 Chapter 8 Priority Queues. 2 Implementations Heaps Priority queues and heaps Vector based implementation of heaps Skew heaps Outline.
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 17: Binary Search Trees; Heaps.
Binary Trees Chapter 6.
B-trees (Balanced Trees) A B-tree is a special kind of tree, similar to a binary tree. However, It is not a binary search tree. It is not a binary tree.
Foundation of Computing Systems Lecture 6 Trees: Part III.
Compiled by: Dr. Mohammad Alhawarat BST, Priority Queue, Heaps - Heapsort CHAPTER 07.
CS 3610 Midterm Review.
ADT Table and Heap Ellen Walker CPSC 201 Data Structures Hiram College.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Review Midterm.
Chapter 19 Implementing Trees and Priority Queues Fundamentals of Java.
Chapter 19 Implementing Trees and Priority Queues Fundamentals of Java.
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,
Chapter 21 Binary Heap.
Data Structures Week 8 Further Data Structures The story so far  Saw some fundamental operations as well as advanced operations on arrays, stacks, and.
P p Chapter 10 has several programming projects, including a project that uses heaps. p p This presentation shows you what a heap is, and demonstrates.
Trees CS 105. L9: Trees Slide 2 Definition The Tree Data Structure stores objects (nodes) hierarchically nodes have parent-child relationships operations.
PRIORITY QUEUES AND HEAPS CS16: Introduction to Data Structures & Algorithms Tuesday, February 24,
Chapter 2: Basic Data Structures. Spring 2003CS 3152 Basic Data Structures Stacks Queues Vectors, Linked Lists Trees (Including Balanced Trees) Priority.
CS221: Algorithms and Data Structures Lecture #3 Mind Your Priority Queues Steve Wolfman 2014W1 1.
CSC211 Data Structures Lecture 18 Heaps and Priority Queues Instructor: Prof. Xiaoyan Li Department of Computer Science Mount Holyoke College.
1 CSC212 Data Structure - Section AB Lecture 22 Recursive Sorting, Heapsort & STL Quicksort Instructor: Edgardo Molina Department of Computer Science City.
1 5. Abstract Data Structures & Algorithms 5.1 Data Structure Fundamentals.
+ David Kauchak cs312 Review. + Midterm Will be posted online this afternoon You will have 2 hours to take it watch your time! if you get stuck on a problem,
Computer Science 112 Fundamentals of Programming II Introduction to Trees.
Programming Abstractions Cynthia Lee CS106X. Topics:  Binary Search Tree (BST) › Starting with a dream: binary search in a linked list? › How our dream.
CSC212 Data Structure Lecture 16 Heaps and Priority Queues Instructor: George Wolberg Department of Computer Science City College of New York.
8 January Heap Sort CSE 2011 Winter Heap Sort Consider a priority queue with n items implemented by means of a heap  the space used is.
CISC220 Fall 2009 James Atlas Dec 07: Final Exam Review.
@ Zhigang Zhu, CSC212 Data Structure - Section FG Lecture 17 B-Trees and the Set Class Instructor: Zhigang Zhu Department of Computer Science.
CSE373: Data Structures & Algorithms Lecture 5: Dictionary ADTs; Binary Trees Lauren Milne Summer 2015.
2015-T2 Lecture 28 School of Engineering and Computer Science, Victoria University of Wellington  Marcus Frean, Lindsay Groves, Peter Andreae and Thomas.
Trees Chapter 15.
Fundamentals of Programming II Introduction to Trees
CSC212 Data Structure - Section AB
i206: Lecture 13: Recursion, continued Trees
Review for Midterm Neil Tang 03/04/2010
original list {67, 33,49, 21, 25, 94} pass { } {67 94}
i206: Lecture 14: Heaps, Graphs intro.
CSC212 Data Structure - Section RS
Balanced-Trees This presentation shows you the potential problem of unbalanced tree and show two way to fix it This lecture introduces heaps, which are.
Heaps Chapter 10 has several programming projects, including a project that uses heaps. This presentation shows you what a heap is, and demonstrates two.
Heaps Chapter 10 has several programming projects, including a project that uses heaps. This presentation shows you what a heap is, and demonstrates two.
B-Trees This presentation shows you the potential problem of unbalanced tree and show one way to fix it This lecture introduces heaps, which are used.
Heaps Chapter 11 has several programming projects, including a project that uses heaps. This presentation shows you what a heap is, and demonstrates.
Balanced-Trees This presentation shows you the potential problem of unbalanced tree and show two way to fix it This lecture introduces heaps, which are.
Heaps Chapter 11 has several programming projects, including a project that uses heaps. This presentation shows you what a heap is, and demonstrates.
Final Review Dr. Yingwu Zhu.
B-Trees This presentation shows you the potential problem of unbalanced tree and show one way to fix it This lecture introduces heaps, which are used.
Heaps Chapter 10 has several programming projects, including a project that uses heaps. This presentation shows you what a heap is, and demonstrates two.
Heaps Chapter 6 Section 6.9.
CS210- Lecture 13 June 28, 2005 Agenda Heaps Complete Binary Tree
Presentation transcript:

Exam Review 3 Chapters 10 – 13, 15 CSC212 Section FG CS Dept, CCNY

Trees and Traversals Tree, Binary Tree, Complete Binary Tree –child, parent, sibling, root, leaf, ancestor,... Array Representation for Complete Binary Tree –Difficult if not complete binary tree A Class of binary_tree_node –each node with two link fields Tree Traversals –recursive thinking makes things much easier A general Tree Traversal –A Function as a parameter of another function

Binary Search Trees (BSTs) Binary search trees are a good implementation of data types such as sets, bags, and dictionaries. Searching for an item is generally quick since you move from the root to the item, without looking at many other items. Adding and deleting items is also quick. But as you'll see later, it is possible for the quickness to fail in some cases -- can you see why? ( unbalanced )

Heaps Heap Definition –A complete binary tree with a nice property Heap Applications –priority queues (chapter 8), sorting (chapter 13) Two Heap Operations – add, remove –reheapification upward and downward –why is a heap good for implementing a priority queue? Heap Implementation –using binary_tree_node class –using fixed size or dynamic arrays

B-Trees A B-tree is a tree for sorting entries following the six rules B-Tree is balanced - every leaf in a B-tree has the same depth Adding, erasing and searching an item in a B-tree have worst-case time O(log n), where n is the number of entries However the implementation of adding and erasing an item in a B-tree is not a trivial task.

Trees - Time Analysis Big-O Notation : –Order of an algorithm versus input size (n) Worse Case Times for Tree Operations –O(d), d = depth of the tree Time Analysis for BSTs –worst case: O(n) Time Analysis for Heaps –worst case O(log n) Time Analysis for B-Trees –worst case O(log n) Logarithms and Logarithmic Algorithms –doubling the input only makes time increase a fixed number

Searching Applications –Database, Internet, AI... Most Common Methods –Serial Search – O(n) –Binary Search – O(log n) –Search by Hashing - O(k) Run-Time Analysis –Average-time analysis –Time analysis of recursive algorithms

Quadratic Sorting Both Selectionsort and Insertionsort have a worst- case time of O(n 2 ), making them impractical for large arrays. But they are easy to program, easy to debug. Insertionsort also has good performance when the array is nearly sorted to begin with. But more sophisticated sorting algorithms are needed when good performance is needed in all cases for large arrays.

O(NlogN) Sorting Recursive Sorting Algorithms –Divide and Conquer technique An O(NlogN) Heap Sorting Algorithm –making use of the heap properties STL Sorting Functions –C++ sort function –Original C version of qsort

Graphs Examples/Applications Terminologies Representations Graph Traversal