Week 8 - An Application of Stacks and Queues
Using the Stack and Queue classes, write a program that takes an infix expression S
as input and converts S to the corresponding postfix expression S and then evaluates
S using the postfix arithmetic.
Example
S

Week 11: (Part I) - Dictionaries: Binary Search Trees
1
Dictionaries
A dictionary is a set of elements that supports the following operations:
insert a given element into the set
delete a specified element from the set
search for a given element in the

Week 10: Huffman Codes - An application of binary trees and priority queues1
An Application of Binary Trees and Priority
Queues:
Huffman Codes
This week, we consider an application of of binary trees and priority queues. The
algorithm we develope here is

Week 7 - Stacks and Queues
1. A linked list has exactly n nodes. The elements in these nodes are
selected from the set cfw_0, 1, . . . , n. There are no duplicates in the list.
Design an O(n) worst case time algorithm to find which one of the elements
fro

Week 13: Part II - Graph Search Algorithms
PROGRAMMING PROJECT:
Finding Connected Components and Cutpoints of a Graph
This project is concerned with finding the connected components of an undirected
graph and identifying the cutpoints of the components.
I

Week 9: (Part I) - Trees and Binary Trees
HOMEWORK EXERCISES
1. The degree of a node in a tree is the number of children the node has. If a
tree has n1 nodes of degree 1, n2 nodes of degree 2, ., nm nodes of degree m,
compute the number of leaves in the t

Week 11: (Part I) - Dictionaries: Binary Search Trees
HOMEWORK EXERCISES
1. Suppose that we have numbers between 1 and 1000 in a binary search tree and
want to search for the number 363. Which of the following sequences could not
be the sequence of nodes

Week 4 - Introduction to Algorithms and Complexity
1. Show that the following statements are true:
(a)
n(n1)
2
is O(n2 )
(b) max(n3 , 10n2 ) is O(n3 )
(c)
Pn
i=1
ik is O(nk+1 ) and (nk+1 ), for integer k
(d) If p(x) is any k th degree polynomial with a po

Week 13: Part I - Graph Search Algorithms
PROGRAMMING PROJECT:
Finding Connected Components of a Graph
This project is concerned with finding the connected components of an undirected
graph. A graph is said to be connected if there exists a path in the gr

Week 5 - Template Classes and Sequence Containers
PROGRAMMING PROJECT:
class IntegerNumber cfw_ . . . ;
Implement the IntegerNumber class so that the following user codes works:
IntegerNumber A;
/ IntegerNumber object A
/ is created and A contains the int

Week 11: (Part II) - Dictionaries: Hash Tables
HOMEWORK EXERCISES
1. Consider inserting the keys 10, 22, 31, 4, 15, 28, 17, 88, 59 into a closed hash
table of length m = 11 using the primary hashing function h(k) = k mod m.
Illustrate the result of insert

Week 11: (Part II) - Dictionaries: Hash Tables
1
Hash Tables
We discussed the binary search tree implementation of dictionaries in the last section.
A binary serach tree supports operations such as inserting a new element, deleting a
specified element, se

Week 12: Graph Algorithms
1
Graph Algorithms
Graphs are very useful in representing arbitrary relationships among data objects.
There are two kinds of graphs: Directed graphs (also known as digraphs) and undirected graphs (simply called graphs). In this l

Week 8 - An Application of Stacks and Queues
1
Algebraic Expressions (infix, postfix, and prefix):
This week we discuss a major application of stacks. Though it is one of the well
known applications, it is by no means the only one.
To proceed with the pre

Week 4 - Introduction to Algorithms and Complexity
1
Algorithm Analysis
Some Definitions
We begin with informal definitions of a some important notions that are frequently
used in this lecture notes.
Algorithm. A finite sequence of instructions, each of w

Week 6 - Linked Lists
1
LISTS
A list, is a sequence container that stores elements in a linear order. Lists are normally
implemented using a collection of linked nodes (objects).
The linked list consists of a series of nodes, which are not necessarily adj

Week 13: Part II - Graph Search Algorithms
A Closer Look at Depth-First-Search
Input:
Adjacency list of a graph G = (V, E) and a start node s V .
Output:
For each node, the depth-first number (dfn) of the node.
For each edge, whether the edge is a tree ed

Week 9: (Part II) - Complete Binary Trees and Priority Queues
1
Priority Queues
A Priority queue is an important abstract data type that supports insertion of a new
item (Insert) and deleletion of the smallest item (DeleteMin). These operations find
exten

Week 13: Part I - Graph Search Algorithms
1
Exploration of Graphs (Depth First Search and Breadth First Search)
A basic requirement for most graph algorithms is the systematic explo ration of a
graph starting at some node s (or at some set of nodes S). Th

Week 9: (Part I) - Trees and Binary Trees
1
Binary Trees
The notion of a tree is an important concept in computing. Trees represent hierarchical relationships among elements of a set.
We begin with some definitions.
Tree:
1. A single node is a tree and th