Graphs & Exam Review 3 Chapter 10 – 13 CS211 CS Dept, MHC.

Slides:



Advertisements
Similar presentations
Lecture 15. Graph Algorithms
Advertisements

Exam Review 3 Chapters 10 – 13, 15 CSC212 Section FG CS Dept, CCNY.
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.
AVL Trees COL 106 Amit Kumar Shweta Agrawal Slide Courtesy : Douglas Wilhelm Harder, MMath, UWaterloo
©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
Introduction This chapter explores graphs and their applications in computer science This chapter explores graphs and their applications in computer science.
Edited by Malak Abdullah Jordan University of Science and Technology Data Structures Using C++ 2E Chapter 12 Graphs.
Graphs Graphs are the most general data structures we will study in this course. A graph is a more general version of connected nodes than the tree. Both.
Advanced Data Structures
Exam Review 3 Chapters 10 – 13, 15 CSC212 Section FG CS Dept, CCNY.
Binary Search Trees Briana B. Morrison Adapted from Alan Eugenio.
CSCE 210 Data Structures and Algorithms
CS 206 Introduction to Computer Science II 10 / 31 / 2008 Happy Halloween!!! Instructor: Michael Eckmann.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
@ Zhigang Zhu, CSC212 Data Structure - Section RS Lecture 18a Trees, Logs and Time Analysis Instructor: Zhigang Zhu Department of Computer.
CS 206 Introduction to Computer Science II 11 / 03 / 2008 Instructor: Michael Eckmann.
Course Review COMP171 Spring Hashing / Slide 2 Elementary Data Structures * Linked lists n Types: singular, doubly, circular n Operations: insert,
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,
CS 206 Introduction to Computer Science II 03 / 25 / 2009 Instructor: Michael Eckmann.
Fall 2007CS 2251 Graphs Chapter 12. Fall 2007CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs To.
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 Foundations of Software Design Fall 2002 Marti Hearst Lecture 17: Binary Search Trees; Heaps.
Important Problem Types and Fundamental Data Structures
Binary Trees Chapter 6.
Version TCSS 342, Winter 2006 Lecture Notes Trees Binary Trees Binary Search Trees.
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.
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.
Review – Part 1 CSE 2011 Winter September 2015.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Final Exam Review CS 3610/5610N Dr. Jundong Liu.
CS 3610 Midterm Review.
Lecture 10 Trees –Definiton of trees –Uses of trees –Operations on a tree.
Chapter 19 Implementing Trees and Priority Queues Fundamentals of Java.
Chapter 19 Implementing Trees and Priority Queues Fundamentals of Java.
Chapter 6 Binary Trees. 6.1 Trees, Binary Trees, and Binary Search Trees Linked lists usually are more flexible than arrays, but it is difficult to use.
Chapter 21 Binary Heap.
Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.
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.
CS Data Structures II Review & Final Exam. 2 Topics Review Final Exam.
Trees CS 105. L9: Trees Slide 2 Definition The Tree Data Structure stores objects (nodes) hierarchically nodes have parent-child relationships operations.
Preview  Graph  Tree Binary Tree Binary Search Tree Binary Search Tree Property Binary Search Tree functions  In-order walk  Pre-order walk  Post-order.
Chapter 2: Basic Data Structures. Spring 2003CS 3152 Basic Data Structures Stacks Queues Vectors, Linked Lists Trees (Including Balanced Trees) Priority.
CSC211 Data Structures Lecture 18 Heaps and Priority Queues Instructor: Prof. Xiaoyan Li Department of Computer Science Mount Holyoke College.
Queues, Stacks and Heaps. Queue List structure using the FIFO process Nodes are removed form the front and added to the back ABDC FrontBack.
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.
CSE 340: Review (at last!) Measuring The Complexity Complexity is a function of the size of the input O() Ω() Θ() Complexity Analysis “same order” Order.
Data Structures Lakshmish Ramaswamy. Tree Hierarchical data structure Several real-world systems have hierarchical concepts –Physical and biological systems.
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.
1Computer Sciences. 2 HEAP SORT TUTORIAL 4 Objective O(n lg n) worst case like merge sort. Sorts in place like insertion sort. A heap can be stored as.
@ Zhigang Zhu, CSC212 Data Structure - Section FG Lecture 17 B-Trees and the Set Class Instructor: Zhigang Zhu Department of Computer Science.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Final Exam Review COP4530.
CSCE 210 Data Structures and Algorithms
Graphs Chapter 15 introduces graphs which are probably the most general and commonly-used data structure. This lecture introduces heaps, which are used.
Trees Chapter 15.
Fundamentals of Programming II Introduction to Trees
DATA STRUCTURES AND OBJECT ORIENTED PROGRAMMING IN C++
i206: Lecture 13: Recursion, continued Trees
Review for Midterm Neil Tang 03/04/2010
Chapter 1.
i206: Lecture 14: Heaps, Graphs intro.
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.
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.
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.
Final Review Dr. Yingwu Zhu.
Important Problem Types and Fundamental Data Structures
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 6 Section 6.9.
Presentation transcript:

Graphs & Exam Review 3 Chapter 10 – 13 CS211 CS Dept, MHC

Graphs -- concepts Graphs: –A finite set of vertices and a finite set of edges. Each edge connects two vertices. –Empty graphs Undirected graph –The order of two connected vertices is unimportant. Directed graph –An edge connects a source and a target.

Graphs - more terms Loops –An edge that connects a vertex to itself Path –A sequence of vertices, each adjacent pair of vertices are connected by an edge. Multiple edges –Two or more edges connecting the same two vertices in the same directions. Simple graphs –Graphs with no loops and multiple edges

Graphs – implementation: how to represent a graph? Two-dimensional array Linked list representation of graphs Representing graphs with edge sets –An array of sets (10 vertices, 10 sets.)

Graphs – applications: when to use a graph? Determine whether a path exist? Find the shortest path

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

Xiaoyan Li, Goals (WHERE) p Implement these data structures as classes in C++ p Determine which structures are appropriate in various situations p Confidently learn new structures beyond what are presented in this class p also learn part of the OOP and software development methodology understand the data types inside out

Xiaoyan Li, Good luck on your finals A happy and fruitful year of 2008