p.339 9.11
Find the maximum flow in the network of Figure 9.79.
p.339 9.15
a. Find a minimum spanning tree for the graph in Figure 9.82 using both Prim's and Kruskal's algorithms.
b. Is this minimum spanning tree unique? Why?
p.88 3.21
Write routines to implement two stacks using only one array. Your stack routines should not declare an overflow unless every slot in the array is used.
p.88 3.26
A "deque" is a data structure consisting of a list of items, on which the following
p.88
3.21
Write routines to implement two stacks using only one array. Your stack routines should not declare an overflow unless every slot in the array is used.
#ifndef _Stack_h #define _Stack_h struct StackRecord; typedef struct StackRecord *Stack; int
p.280
8.7
A formatted version
We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send a file from any computer on the network to any oth
p.212 6.2
a. Show the result of inserting 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, and 2, one at a time, into an initially empty binary heap.
b. Show the result of using the linear-time algorithm to build a binary heap using the same input.
p.212 6
p.212
6.2
a. Show the result of inserting 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, and 2, one at a time, into an initially empty binary heap. b. Show the result of using the linear-time algorithm to build a binary heap using the same input. a.
1 3
p.257 7.4
Show the result of running Shellsort on the input 9, 8, 7, 6, 5, 4, 3, 2, 1 using the increments cfw_1, 3, 7.
p.258 7.14
How would you implement mergesort without using recursion?
p.258 7.20
a. For the quicksort implementation in this chapter, w
p.280 8.7 A formatted version
We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send a file from any computer on the network to any oth
p.339
9.11
Find the maximum flow in the network of Figure 9.79. Answer:
A 1 s 6 4 2 G 4 3 D 0 0 H 4 I 2 3 E 0
2
B
2 2
C 0 3 0 F
4 3 t 4
p.339
9.15
a. Find a minimum spanning tree for the graph in Figure 9.82 using both Prim's and Kruskal's algorithms. b.
Project 1:
Binary Search Trees
This project requires you to implement operations on unbalanced binary search trees, AVL trees, and splay trees. You are to analyze and compare the performances of a sequence of insertions and deletions on these search tree
Project 2:
Electric Wiring
Bill is designing electric wiring for his new house. First of all, he has fixed the positions of several electrical outlets on the walls. To neatly connect any pair of outlets, he would make sure that the wire is always imbedded
Project 3:
Review of Programming Contest Rules
The ACM ICPC's rule of scoring is as the following: A problem is solved when it is accepted by the judges. Teams are ranked according to the most problems solved. For the purposes of awards, or in determining
p.172
5.1
Given input cfw_4371, 1323, 6173, 4199, 4344, 9679, 1989 and a hash function h(X) = X (mod 10), show the resulting: a. Separate chaining hash table. b. Open addressing hash table using linear probing. c. Open addressing hash table using quadrati
p.172 5.1
Given input cfw_4371, 1323, 6173, 4199, 4344, 9679, 1989 and a hash function h(X) = X (mod 10), show the resulting:
a. Separate chaining hash table.
b. Open addressing hash table using linear probing.
c. Open addressing hash table using quadr
4.5 Splay Trees Target : Any M consecutive tree operations
starting from an empty tree take at most O(M log N) time.
But o a single operation might S if one node takes O(N) time SThe we can is that only means Does it mean that every ure bound weaker. to a
CHAPTER
5
PRIORITY QUEUES (HEAPS) delete the element with the highest \ lowest priority
5.6 Leftist Heaps
1. Structure Property: A structural property, an ordering property H Definition R the null path length Npl(X) is the length of the shortest path from
CHAPTER
9
Introduction NP-Completeness
Graph Algorithms
9.7 Introduction NP-Completeness The Euler circuit problem :find a path that touches every edge exactly once Time is Linear. The Hamiltonian cycle problem :find a simple cycle that contains every ver
3 Dynamic Programming
Use a table instead of recursion 1. Fibonacci Numbers: F(N) = F(N 1) + F(N 2)
int Fib( int N ) cfw_ if ( N <= 1 ) return 1; else return Fib( N - 1 ) + Fib( N - 2 );
T( N ) T ( N 1 ) + T ( N 2 ) T(N) F(N)
F6 F5 F4 F3 F2 F1 F0 F1 F1 F
CHAPTER
10
ALGORITHM DESIGN TECHNIQUES
10.1 Greedy Algorithms
Optimization Problems: Given a set of constrains and an optimization function. Solutions that satisfy the constrains are called feasible solutions. A feasible solution for which the optimizati
CHAPTER
11
Amortized Analysis mSplay tree vs. AVL tree; skew heap vs. leftist heap
Target : Any M consecutive operations take at
most O(M log N) time. - Amortized time bound
worst-case bound
amortized bound average-case bound
2 Binomial Queues
H Claim m
p.85 3.6
Write a function to add two polynomials. Do not destroy the input. Use a linked list implementation.
If the polynomials have M and N terms, respectively, what is the time complexity of your program?
p.86 3.12
a. Write a nonrecursive procedure t
p.85 3.6 Write a function to add two polynomials. Do not destroy the input. Use a linked list implementation. If the polynomials have M and N terms, respectively, what is the time complexity of your program?
typedef struct Node struct Node cfw_ int Coeffi
p.141 4.16
Show the result of inserting 2, 1, 4, 5, 9, 3, 6, 7 into an initially empty AVL tree.
p.141 4.22
Write the functions to perform the double rotation without the inefficiency of doing two single rotations.
p.141
4.16
Show the result of inserting 2, 1, 4, 5, 9, 3, 6, 7 into an initially empty AVL tree.
4 2 1 3 5 7 6 9
p.141 4.22 Write the functions to perform the double rotation without the inefficiency of doing two single rotations.
#ifndef _AvlTree_H #defi
p.141 4.23
Show the result of accessing the keys 3, 9, 1, 5 in order in the splay tree in Figure 4.61.
Figure 4.61:
_10_
/ \
_4_ 11
/ \ \
2 6 12
/ \ / \ \
1 3 5 8 13
/ \
7 9
p.143 4.36
a. Show the result of inserting the following keys into an in
p.141
4.23
Show the result of accessing the keys 3, 9, 1, 5 in order in the splay tree in Figure 4.61. Figure 4.61
10
4 2 1 3 5 7 6 8
11 12 13
9
Result for 3:
3 2 1 4 6 5 7 8 9
10 11 12 13
Result for 9:
9 3 2 1 6 5 7 4 8
10 11 12 13
Result for 1:
1 9 2 3
TA: f %O8
[email protected] , [email protected]
project f : ftp:/ds_student:[email protected]
4.4 AVL Trees Target : Speed up searching (with insertion
and deletion)
root small large
Tool : Binary search
trees
Problem : Although Tp = O( height ), b