Tutorial 7: Binary Search Tree
Short review on binary tree Tree traversals Binary Search Tree (BST)
Properties FindKey FindMin/FindMax Insert/Delete For sorting?
Short review on binary tree
At most two children for each node A root no
Tutorial 8: AVL Tree
Searching Finding min/max Insertion Deletion
AVL Tree
AVL Tree is a binary search tree that satisfies For each node, the height of the left and right subtrees can differ by at most 1 Recall that the height of a node is
B -Tree
+
COMP171 Tutorial 9
Deficiency of AVL Tree
Performs really bad when the data is too huge and cannot be put in the main memory Too much disk access if the data is stored in the disk
Access on disk is much slower than access on main me
Graphs (BFS & DFS)
COMP171 Tutorial 10
Graphs
Graph
G=(V,E)
V: set of vertices E: set of edges V={1,2,3,4,5} E={(1,2)(1,5)(2,5)(2,4)(4,5)(2,3)(2,4)}
Two
standard ways to represent a graph
As a collection of adjacency lists As an adjacen
Tutorial 6: Quick Sort & heap sort
Quick sort Heap sort Empirical Analysis
Introduction
Quick sort, like merge sort, is based on the divide-and-conquer paradigm. Intuitively, it operates as follows.
Divide:
CHOOSE A PIVOT ELEMENT in the list. P