CSCI-255
Advanced Data Structures Lecture 8
Why Emphasize Growth Rates?
The algorithm with the lower growth rate will be faster for all but a finite number of cases Performance is most important for larger problem size As memory prices continue to fall, b

CSCI-255
Advanced Data Structures Lecture 26
Graph Connectivity and Graph Traversal
s-t connectivity problem: Given two nodes s and t, is there a path between s and t? s-t shortest path problem: Given two nodes s and t, what is the length of the shortest

CSCI-255
Advanced Data Structures Lecture 25
Graphs
How would you represent the following?
A chart of driving distances between cities in Canada A network The prerequisite relationship between CS classes
These problems have similar structure:
A collection

CSCI-255
Advanced Data Structures Lecture 24
Recap: Time Complexity of Basic AVL Tree Operations
Insert
Maximum possible number of rotations = 1
Delete
Maximum possible number of rotations = lg(n)
Worst case times
Search: O(lgn) Insert: O(lgn) Delete: O(l

CSCI-255
Advanced Data Structures Lecture 23
AVL Trees: Insert (contd)
1. 2. Insert the node as in a BST Starting at the newly inserted node, travel up the tree (towards the root), updating the balances along the way
The first node for which the balance f

CSCI-255
Advanced Data Structures Lecture 22
Recap from Last Lecture
Asymptotic time complexity of basic BST operations (i.e., Search, Insert, Delete) is O(h) where h is the height of the tree
BSTs are limited because of their bad worst-case performance O

CSCI-255
Advanced Data Structures Lecture 21
Time Complexity of Basic BST Operations
Search, Insert, Delete
These operations visit the nodes along a root-to-leaf path (e.g., Search(15), Insert(19), Delete(21)
The number of nodes encountered on unique path

CSCI-255
Advanced Data Structures Lecture 20
Deleting an Element from a BST
Algorithm: Find the node to delete, delete it When deleting a node from a BST, there are 3 cases to consider
The node is a leaf; it has no children. This is the easiest case to de

CSCI-255
Advanced Data Structures Lecture 19
Inserting an Element into a BST (contd)
Do 6.22(e) (DONE IN CLASS)
Running Time?
Exercise: Write a recursive version of insert (DONE IN CLASS)
Tree Traversal
Tree traversal is the process of visiting each node

CSCI-255
Advanced Data Structures Lecture 18
Binary Search Trees (BST)
A binary tree with the following property:
For each node of the tree, all values stored in its left subtree (the tree whose root is the left child) are less than the value stored in th

CSCI-255
Advanced Data Structures Lecture 17
Trees for Searching
Was a reasonable ordering criterion applied to construct this tree?
With this ordering, nothing really interesting is achieved in the context of searching
Binary Trees An Informal Definition

CSCI-255
Advanced Data Structures Lecture 16
Time Complexity Analysis of Recursive Algorithms
So far we have analyzed the time efficiency of nonrecursive algorithms only How can we apply our general analysis framework/model to recursive algorithms?
Rememb

CSCI-255
Advanced Data Structures Lecture 27
Minimum Spanning Tree
Minimum spanning tree: Given a connected graph G = (V, E) with real-valued edge weights ce, a MST is a subset of the edges T E such that T is a spanning tree whose sum of edge weights is