/Used the book from CIS 215 Chp.20 Binary Search Trees
using namespace std;
void BinaryTree:insertNode(string w)
TreeNode *newNode; /pointer to the
ADTS, Stacks, and Queues
Abstract Data Types
What is an abstract data type?
Data plus operations on that data
Data may be described as a set of objects
Set, stack, queue, graph, list
Set: a set may have operations such as union, inters
Introduction To Algorithms
The word comes from a Persian author, Abu Jafar Mohammed ibm Musa al Khowarizmi
(c. 825 A.D.)
Author of a textbook on mathematics
Algorism the process of doing arithmetic using Arabic numbers
In contrast to abacist
What is Dynamic Programming
Solves problems by building on previous advances
o This saves recalculation time
May give a less than optimal but speedy results
Examples: Floyd, Matrix Chain Multiplication, Knapsack Problem
o Prim, Kruskal, Dijkstra
o Scheduling, Huffman Codes, Bin Packing
Divide and Conquer
o Ceasar, Cipher
o Knapsack, Floyd, Mat
In search of efficiency
There are many sorting algorithms. Typically simple sorting algorithms are Big O (N 2 ).
More complex algorithms may be Big O (N lg N).
Any general purpose sorting algorithm requires NlogN comparisons.
What is a Priority Queue?
Used for operating system scheduling
Might be used for printer queues
Other practical uses such as sorting
o Used in greedy algorithms
A priority queue is a data structure
o Operations: Insert, deleteMin
Chapter 5: Hashing
Data structure: The hash table
Hashing allows insertions, deletions, and finds in constant average time. Generally an array of
some fixed size.
Key Factors in Hashing
What hash function should be used?
What happens when two
Introduction to Trees
A tree is a collection of nodes
o A tree is a collection of N nodes, one of which is the root, and N-1 edges.
o The root of each subtree is a child of r, the root; r is the parent of each subtree
Nodes with no children a