Dictionary Program
/Used the book from CIS 215 Chp.20 Binary Search Trees
/
#include "Dictionary.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void BinaryTree:insertNode(string w)
cfw_
TreeNode *newNode; /pointer to the
Course 313
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
Examples
Set, stack, queue, graph, list
Set: a set may have operations such as union, inters
Course 313
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
Course 313
Dynamic Programming
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
The
Course 313
Algorithmic Methods
Methods
Greedy Algorithms
o Prim, Kruskal, Dijkstra
o Scheduling, Huffman Codes, Bin Packing
Divide and Conquer
o Quicksort
o Mergesort
Cryptographic Algorithms
o Ceasar, Cipher
Dynamic Programming
o Knapsack, Floyd, Mat
Course 313
Sorting
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.
o Sortin
Course 313
Heaps
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
Linked l
Course 313
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
Course 313
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