Solution R-4.4
Professor Amongus claims can be contradicted by the following examples while insertion of
cfw_1,2,3 will not lead to the same binary tree as of cfw_2,1,3
Solution R-4.7
The smallest num
Homework 9 Solution
Exercise R-9.11
The longest prex that is also a sufx of this string is "cgtacg".
Exercise C-9.4
Modify the KMPMatch algorithm to maintain a variable maxIndex which is the index of
C-2.8: Describe the structure and pseudocode for an array-based implementation of an
index-based list that achieves O(1) time for insertions and removals at index 0, as well as
insertions and removals
R-13.7
A. I will use the adjacency list structure. Because the space of adjacency is n + m = 30000, and the
space of adjacency matrix is n^2 = 10000*10000.
B. I will use the adjacency list structure.
Homework 2 Solution
Exercise R-2.10
A worst-case sequence for insertion sort would be one that is in descending order of keys,
e.g., 44 36 29 25 22 15 13 10 9 3. With this sequence, each element will
Homework 3 Solution
Exercise R-3.3
There are several solutions. One is to draw the AVL tree created by the input sequence:
9;5;12;7;13. Now draw the tree created when you switch the 5 and the 7 in the
Homework 4 Solution
Exercise R-4.9
O(nlogn) time
Exercise R-4.14
The bubble-sort and merge-sort algorithms are stable.
Exercise R-4.16
No. Bucket-sort does not use a constant amount of additional stor
Homework 6 Solution
Exercise R-6.5
Inserting a vertex runs in O(1) time since it is simply inserting an element into a doubly
linked list. To remove a vertex, on the other hand, we must inspect all ed
Homework 7 Solution
Exercise R-7.7
Answers vary. For example, the following is correct.
Exercise C-7.3
The greedy algorithm presented in this exercise is not guaranteed to find the shortest path
betwe
CS 600
Assignment 5
Abishek Lakshmirathan
R-8.4 Suppose we modify the deterministic version of the quick-sort algorithm so that,
instead of selecting the last element in an n-element sequence as the p
CS-600
Homework 8
Abishek Lakshmirathan
C-15.2
The cycle property of graph states that if the weight of an edge e in the graph is larger than any other
edge, then this edge cannot belong to minimum sp
CS 600
Assignment 5
Abishek Lakshmirathan
R-8.4 Suppose we modify the deterministic version of the quick-sort algorithm
so that, instead of selecting the last element in an n-element sequence as the
p
CS 600
Assignment 6
Abishek Lakshmirathan
Answer R 10.6: Consider the string Tamassia. The associated frequencies are as below:
Character
Frequency
T
1
M
1
I
1
S
2
A
3
2
T
M
I
S
1
2
2
T
M
A
3
3
I
S
A
CS 600
ASSIGNMENT 7
Abishek Lakshmirathan
R-13.7 Would you use the adjacency list structure or the adjacency matrix structure in each of
the following cases? Justify your choice.
a) The graph has 10,0
CS 600
Assignment 3
Abishek Lakshmirathan
R 4.4
Professor Amongus is wrong as the tree that is formed when we enter the elements cfw_1,2 differs from
the tree that is formed when we enter the elements
CS-600
Homework 9
Abishek Lakshmirathan
R-17.3:
A Boolean formula consists of a set of clauses Ci X for i = 1, . . ., m, where X = cfw_x1, . . ., xn,
x1, . . ., xn is a set of literals. It is called s
CS 600
Final Exam
Abishek Lakshmirathan
Answer 1:
Changed needed while implementing this approach of Djisktras Algorithm are:
A priority queue is used that supports deleteMin and insert.
This variant
CS 600
Assignment 1-3 Redo
Abishek Lakshmirathan
Solution C-1.30:
Suppose array expansion occurs at N+ N which takes c.( N+ N) time (for some constant c>0)
Previous expansion occurred at N and N inser
Homework 8 Solution
Exercise R-8.2
Answer the following questions on the flow network N and flow f shown in Figure 8.6a:
What are the forward edges of augmenting path? What are the backward edges?
Th
Homework 10 Solution
Exercise R-11.1
Many solutions exist, such as the below from a student in the class:
Exercise R-11.10
400
Exercise C-11.2
In step1, every processor decides, with probability 4/n,
Homework 11 Solution
Exercise R-13.1
Professor Amongus reduced a problem in P to a problem in NP. To show P= NP, he
would have to reduce a problem in NP to a problem in P. We already know that every
p
Solution C-6.6
Amultimapallowsmappingfromkeystomultiplevalues.
A scheme to implement a multimap so that the put(k, v) method runs in O(1)
expected time and the FindAll(k) method runs in O(1 + s) time
package T3;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class FordFulkerson cfw_
private Set<Edge> path=new HashSet<Edge>();
public int getMaxStream(String start,Stri
R-8.4
According the quick sort tree, in a sorted sequence, the sequence can be divided into a
paragraphs like a tree. The height of tree is logn, and also is the running time of search each
element. I
R-10.6
Set S:abcdefgh
The Huffman tree of the set S is blow:
The frequency of each character is 1
C-10.5
From the maximum denomination to minimum denomination
Check if the current denomination can be
R-17.3
According the definition of Complexity Class NP, we know that a non-deterministic algorithm A
accepts a string x if there exists some sequence of choose operations that causes A to output
yes o
According the theorem 1.29, we can assume that Xi is 0 when bear wins.
So Pr(X<(1 ) <e(-^2)/2
because = 1/3*n = n/3, and Pr(X<(1 ) <e(-^2)/2.
if bear wins the majority, then X<(1 ) = n/2
So = -1/2.
So
C-1.30
Set T(n) is the capacity of the array after n adding generation
T(n) = T(n-1) + T(n-1)1/2T(n-1)=T(n-2) + T(n-2)1/2
T(2) = T(1) + T(1)1/2
All left side plus and all right side plus so
T(n) = T(1