Computer science

Introduction to Algorithms Textbook Questions And Answers

US$14.99 US$24.00

b Chapter: 13 -Problem: 3 /b In Exercise 13.3-2, you found the red-black tree that results from successively inserting the keys 41, 38, 31, 12, 19, 8 into an initially empty tree. Now show the red-black trees that result from the successive deletion of the keys in the order

Description

Chapter: 13 -Problem: 3 >> In Exercise 13.3-2, you found the red-black tree that results from successively inserting the keys 41, 38, 31, 12, 19, 8 into an initially empty tree. Now show the red-black trees that result from the successive deletion of the keys in the order 8, 12, 19, 31, 38, 41. Exercise 13.3-2Show the red-black trees that result after successively inserting the keys 41, 38, 31, 12, 19, 8 into an initially e
Answer Preview: Here is the redblack tree that results after successively …

, Chapter: 23 -Problem: 2 >> For a very sparse connected graph G = (V, E), we can further improve upon the O(E + V lg V) running time of Prim's algorithm with Fibonacci heaps by preprocessing G to decrease the number of vertices before running Prim's algorithm. In particular, we choose, for each vertex u, the minimum-weight edge (u, ?) incident on u, and we put (u, ?) into the minimum spanning tree under construction. We then
Answer Preview: a To show that T is a minimum spanning tree of G we need to prove that T is a spanning tree ie a tre…

, Chapter: 11 -Problem: 3 >> Professor Marley hypothesizes that he can obtain substantial performance gains by modifying the chaining scheme to keep each list in sorted order. How does the professor’s modification affect the running time for successful searches, unsuccessful searches, insertions, and deletions?
Answer Preview: ffeting f time will be tken s fllwing Bth Suessful nd Unsuessful Serhes tke time l where l length f …

, Chapter: 31 -Problem: 5 >> If a > b ? 0, show that the call EUCLID (a, b) makes at most 1 + log? b recursive calls. Improve this bound to 1 + log?(b/ gcd(a, b)).
Answer Preview: An extreme point of a convex set is a point in the set that …

, Chapter: 22 -Problem: 4 >> Given an adjacency-list representation of a multi-graph G = (V, E), describe an O(V + E)-time algorithm to compute the adjacency-list representation of the "equivalent" undirected graph G? = (V, E?), where E? consists of the edges in E with all multiple edges between two vertices replaced by a single edge and with all self-loops removed.
Answer Preview: The lost original of the journal most often has been …

,

, Chapter: 31 -Problem: 4 >> Prove that if p is prime and 0 < k < p, then gcd(k, p) = 1.
Answer Preview: The statement that if p is prime and 0 k p then gcd k p 1 is known as Euclidean s Theorem It states …

, Chapter: 26 -Problem: 7 >> Suppose that, in addition to edge capacities, a flow network has vertex capacities. That is each vertex ? has a limit l(?) on how much flow can pass through ?. Show how to transform a flow network G = (V, E) with vertex capacities into an equivalent flow network G? = (V?,E?) without vertex capacities, such that a maximum flow in G? has the same value as a maximum flow in G. How many vertices and e
Answer Preview: We will construct G by splitting each vertex of G into two vertices 1 2 joined by an edge of capacit…

,

, Chapter: 12 -Problem: 2 >> Suppose that we construct a binary search tree by repeatedly inserting distinct values into the tree. Argue that the number of nodes examined in searching for a value in the tree is one plus the number of nodes examined when the value was first inserted into the tree.
Answer Preview: Vasco De Gama was the first European to find an oc…

,

, Chapter: 26 -Problem: 7 >> Show that we could change line 6 of INITIALIZE-PREFLOW to  without affecting the correctness or asymptotic performance of the generic push relabel algorithm. Transcribed Image Text: 6 s.h = |G.V|– 2
Answer Preview: If we set sh V 2 we have to change our definition of a height function to allow sh V …

, Chapter: 25 -Problem: 8 >> Give an O(VE)-time algorithm for computing the transitive closure of a directed graph G = (V, E).
Answer Preview: We can determine the vertices reachable from a particular vertex …

, Chapter: 13 -Problem: 4 >> In which lines of the code for RB-DELETE-FIXUP might we examine or modify the sentinel T.nil?
Answer Preview: They want us to come up with the coatings for each of these letters here So lets just go ahead and s…

,

, Chapter: 27 -Problem: 9 >> For how many processors do the two versions of the chess programs run equally fast, assuming that TP = T1/P + T ??
Answer Preview: Based on the values of work and …

, Chapter: 20 -Problem: 3 >> Observe that, using the structures in this section, the way we find the successor and predecessor of a value x does not depend on whether x is in the set at the time. Show how to find the successor of x in a binary search tree when x is not stored in the tree.
Answer Preview: We need to take care of 3 cases for any node to find its …

, Chapter: 14 -Problem: 1 >> Write pseudocode for LEFT-ROTATE that operates on nodes in an interval tree and updates the max attributes in O(1) time.
Answer Preview: On 20 th May 1498 two years after he set sail from Lisbon Portugal Vasco da Gama arrived on the We…

, Chapter: 29 -Problem: 7 >> Show that the following linear program is unbounded: Transcribed Image Text: maximize X1 X2 subject to -2x1 + X2 < -1 -X1 2x2 < -2 X1, X2 0 .
Answer Preview: To show that the linear program is unbounded we need to find a feasible solution …

,

,

, Chapter: 26 -Problem: 8 >> Suppose that we redefine the residual network to disallow edges into s. Argue that the procedure FORD-FULKERSON still correctly computes a maximum flow.
Answer Preview: Let G f be the residual network just before an iteration of the whileloop of FORDFULKERSON an…

,

, Chapter: 13 -Problem: 5 >> Consider a red-black tree formed by inserting n nodes with RB-INSERT. Argue that if n > 1, the tree has at least one red node.
Answer Preview: Case 1 zz and zppzpp are textREDRED if the loop terminates then zz could not b…

, Chapter: 30 -Problem: 5 >> We have seen how to evaluate a polynomial of degree-bound n at a single point in O(n) time using Horner's rule. We have also discovered how to evaluate such a polynomial at all n complex roots of unity in O(n lg n) time using the FFT. We shall now show how to evaluate a polynomial of degree-bound n at n arbitrary points in O(n lg2 n) time.To do so, we shall assume that we can compute the polynomia
Answer Preview: a To prove that A x mod x z A z for any point z we can use the division algorithm for polynomials which states that given two polynomials f x and g x where g x is not zero there exist unique polynomia…

, Chapter: 4 -Problem: 3 >> Give asymptotic upper an= lower bounds for T (n) in each of the following recurrences. Assume that T (n) is constant for sufficiently small n. Make your bounds as tight as possible, and justify your answers.a. T (n) = 3T (n/2) + n lg nb. T (n) = 4T (n/2) + n2?n.c. T (n) = 2T (n/2) + n/ lg n.d. T (n) = T (n/2) + T (n/4) + T (n/8) + n.e. T (n) = T(n - 1) + 1/n.f. T (n) = T(n - 1) + lg n.g. T (n) = T
Answer Preview: a T n 3T n2 n lg n We have f n n lg n and n log b a n lg 3 n 1585 SincenlgnOn lg 3 for any0 0 We hav…

, Chapter: 25 -Problem: 9 >> Suppose that we can compute the transitive closure of a directed acyclic graph in f (|V|, |E|) time, where f is a monotonically increasing function of |V| and |E|. Show that the time to compute the transitive closure G* = (V, E*) of a general directed graph G = (V, E) is then f (|V|, |E|) + O(V + E*).
Answer Preview: First compute the strongly connected components of th…

, Chapter: 13 -Problem: 1 >> Argue that after executing RB-DELETE-FIXUP, the root of the tree must be black.
Answer Preview: Case 1 transform to 2 3 4 Case 2 …

, Chapter: 29 -Problem: 5 >> Convert the following linear program into slack form: What are the basic and nonbasic variables? Transcribed Image Text: maximize 2x1 6x 3 subject to X1 + X2 X3 < 7 3x1 X2 8 -X1 + 2x2 + 2x3 X1, X2, X3 > 0. VI AL AL I | |
Answer Preview: Converting the given linear program into slack form To convert the given linear program into slack f…

, Chapter: 26 -Problem: 9 >> Suppose that both f and f? are flows in a network G and we compute flow f ? f?. Does the augmented flow satisfy the flow conservation property? Does it satisfy the capacity constraint?
Answer Preview: The augmented flow f f satisfies the flow conservation property but not the capacity constraint pr…

, Chapter: 21 -Problem: 2 >> Show the data structure that results and the answers returned by the FIND-SET operations in the following program. Use the linked-list representation with the weighted-union heuristic. Assume that if the sets containing xi and xj?have the same size, then the operation UNION(xi, xj) appends xj ?s list onto xi ?s list. Tran
Answer Preview: At the end of the execution there is only on…

, Chapter: 7 -Problem: 5 >> We can improve the running time of quicksort in practice by taking advantage of the fast running time of insertion sort when its input is "nearly" sorted. Upon calling quicksort on a subarray with fewer than k elements, let it simply return without sorting the subarray. After the top-level call to quicksort returns, run insertion sort on the entire array to finish the sorting process. Argue that t
Answer Preview: In the quicksort part of the proposed algorithm the recursion stops at level lgn klgnk which makes t…

, Chapter: 22 -Problem: 6 >> Show that in an undirected graph, classifying an edge (u, ?) as a tree edge or a back edge according to whether (u, ?) or (?, u) is encountered first during the depth-first search is equivalent to classifying it according to the ordering of the four types in the classification scheme.
Answer Preview: The number of iterations for the nested for loops is …

, Chapter: 10 -Problem: 1 >> Can you implement the dynamic-set operation INSERT on a singly linked list in O(1) time? How about DELETE?
Answer Preview: INSERT can be done in constant time by arrangin…

, Chapter: 30 -Problem: 6 >> Suppose that instead of performing an n-element FFT over the field of complex numbers (where n is even), we use the ring ?m of integers modulo m, where m = 2tn/2 + 1 and t is an arbitrary positive integer. Use ? = 2t instead of ?n as a principal nth root of unity, modulo m. Prove that the DFT and the inverse DFT are well defined in this system.
Answer Preview: The Discrete Fourier Transform DFT is a powerful tool for analyzing and processing signals It can be …

, Chapter: 27 -Problem: 7 >> Consider the following multithreaded pseudocode for transposing an n × n matrix A in place: Analyze the work, span, and parallelism of this algorithm. Transcribed Image Text: P-TRANSPOSE(A) 1 n = A.rows 2 parallel for j = 2 to n parallel for i = 1 to j – 1 exchange a;; with a;; 3 4
Answer Preview: We analyze the work of PTRANSPOSE as usual by computing the running time of its serializatio…

, Chapter: 20 -Problem: 4 >> Modify the proto-vEB structure to support duplicate keys.
Answer Preview: The array AA found in a proto van Emde Boas structure of size 22 shou…

,

, Chapter: 31 -Problem: 2 >> Prove that there are infinitely many primes. Show that none of the primes p1, p2, . . . ,pk divide (p1p2 ··· pk) + 1.
Answer Preview: There are infinitely many primes Proof Let n be a posi…

, Chapter: 24 -Problem: 2 >> Give an example of a weighted, directed graph G = (V, E) with weight function w : E ? ? and source vertex s such that G satisfies the following property: For every edge (u, ?) ? E, there is a shortest-paths tree rooted at s that contains (u, ?) and another shortest-paths tree rooted at s that does not contain (u, ?).
Answer Preview: Weighted graph a graph whose edges have weights Exam…

, Chapter: 7 -Problem: 6 >> Consider modifying the PARTITION procedure by randomly picking three elements from array A and partitioning about their median (the middle value of the three elements). Approximate the probability of getting at worst an ?-to-(1 – ?) split, as a function of ? in the range 0 < ? < 1.
Answer Preview: With the help of a local navigator da Gama was able to cross the …

, Chapter: 31 -Problem: 4 >> Rewrite EUCLID in an iterative form that uses only a constant amount of memory (that is, stores only a constant number of integer values).
Answer Preview: The convex hull property is the natural generalization o…

, Chapter: 22 -Problem: 10 >> Modify the pseudocode for depth-first search so that it prints out every edge in the directed graph G, together with its type. Show what modifications, if any, you need to make if G is undirected.
Answer Preview: If GG is undirected we dont need to make any modifications See the C demo …

, Chapter: 11 -Problem: 5 >> Suppose that we are storing a set of n keys into a hash table of size m. Show that if the keys are drawn from a universe U with|U| > nm, then U has a subset of size n consisting of keys that all hash to the same slot, so that the worst-case searching time for hashing with chaining is ?(n).
Answer Preview: rding t the …

, Chapter: 20 -Problem: 4 >> Suppose that instead of superimposing a tree of degree ?u, we were to superimpose a tree of degree u1/k, where k > 1 is a constant. What would be the height of such a tree, and how long would each of the operations take?
Answer Preview: Vasco da Gama was best known for being the first to sai…

, Chapter: 10 -Problem: 2 >> A mergeable heap supports the following operations: MAKE-HEAP (which creates an empty mergeable heap), INSERT, MINIMUM, EXTRACT-MIN, and UNION.1 Show how to implement mergeable heaps using linked lists in each of the following cases. Try to make each operation as efficient as possible. Analyze the running time of each operation in terms of the size of the dynamic set(s) being operated on.a. Lists
Answer Preview: In all three cases textMAKEHEAPMAKEHEAP simply creates a new list LL sets Lhead textNILLheadNIL and returns LL in constant time Assume lists are doubly linked To realize a linked list as a heap we ima…

, Chapter: 31 -Problem: 8 >> For any integer k > 0, an integer n is a kth power if there exists an integer a such that ak = n. Furthermore, n > 1 is a nontrivial power if it is a kth power for some integer k > 1. Show how to determine whether a given ?-bit integer n is a nontrivial power in time polynomial in ?.
Answer Preview: A planar polygon is convex if it contains all the line segments connecting any pair of its po…

, Chapter: 27 -Problem: 5 >> Give pseudocode for an efficient multithreaded algorithm that transposes an n × n matrix in place by using divide-and-conquer to divide the matrix recursively into four n/2 × n/2 submatrices. Analyze your algorithm.
Answer Preview: PMATRIXTRANSPOSERECURSIVE A r c s PMATRIXTRANSPOSESWAP A r 1 c 1 r 2 c 2 s 1 s 2 In order to transpo…

, Chapter: 20 -Problem: 6 >> Creating a vEB tree with universe size u requires O(u) time. Suppose we wish to explicitly account for that time. What is the smallest number of operations n for which the amortized time of each operation in a vEB tree is O(lg lg u)?
Answer Preview: On May 20 1498 Portuguese explorer Vasco da Gama landed in Calicut what is now Kozhikode In…

, Chapter: 8 -Problem: 1 >> Using Figure 8.3 as a model, illustrate the operation of RADIX-SORT on the following list of English words: COW, DOG, SEA, RUG, ROW, MOB, BOX, TAB, BAR, EAR, TAR, DIG, BIG, TEA, NOW, FOX. Figure 8.3 Transcribed Image Text: 329 720 720 329 457 355 329 355 657 436 436 436 839 . » 457 .» 839 .» 457 4
Answer Preview: Below is the java program that performs sorting of strings using RadixSort Please copy the program i…

, Chapter: 5 -Problem: 5 >> What is the probability that a k-string over a set of size n forms a k-permutation? How does this question relate to the birthday paradox?
Answer Preview: Permutations The data set can be arranged finite set or ordered in part…

, Chapter: 30 -Problem: 3 >> We can generalize the 1-dimensional discrete Fourier transform defined by equation (30.8) to d dimensions. The input is a d-dimensional array A = (aj1,j2,...,jd)?whose dimensions are?n1, n2, . . . ,nd, where?n1n2 . . .?nd =?n. We define the?d-dimensional discrete Fourier transform by the equation for a. Show that we can compute a d-dimensional DFT by computing 1-dimensional DFTs on each dimens
Answer Preview: a To compute a d dimensional DFT we can use the following algorithm 1 Compute n n1 separate 1 dimens…

, Chapter: 22 -Problem: 4 >> What is the running time of BFS if we represent its input graph by an adjacency matrix and modify the algorithm to handle this form of input?
Answer Preview: For every vertex we have to traverse all adjacent neighbours of current no…

,

, Chapter: 30 -Problem: 3 >> Derive a point-value representation for Arev(x) = ?n ? 1j=0 an-1 j xj from a point value representation for A(x) = A (x) = ?n ? 1j=0 aj xj, assuming that none of the points is 0.
Answer Preview: The point value representation for Arev x n 1j 0 an 1 j xj can be derived from a p…

, Chapter: 26 -Problem: 5 >> State the maximum-flow problem as a linear-programming problem.
Answer Preview: There are two special vertexes S and D known as source an…

, Chapter: 11 -Problem: 5 >> Consider an open-address hash table with a load factor ?. Find the nonzero value ? for which the expected number of probes in an unsuccessful search equals twice the expected number of probes in a successful search. Use the upper bounds given by Theorems 11.6 and 11.8 for these expected numbers of probes. Theorems 11.6 Theorems 11.8
Answer Preview: According to theorem 116 and 118 for an open address has…

, Chapter: 29 -Problem: 9 >> Consider the following 1-variable linear program, which we call P: where r, s, and t are arbitrary real numbers. Let D be the dual of P. State for which values of r, s, and t you can assert that 1. Both P and D have optimal solutions with finite objective values. 2. P is feasible, but D is infeasible. 3. D is feasible, but P is infeasible. 4. Neither P nor D is feasible.
Answer Preview: 1 Both P and D have optimal solutions with finite objective values when r s and t are all non zero …

, Chapter: 20 -Problem: 4 >> What happens if you call VEB-TREE-INSERT with an element that is already in the vEB tree? What happens if you call VEB-TREE-DELETE with an element that is not in the vEB tree? Explain why the procedures exhibit the behavior that they do. Show how to modify vEB trees and their operations so that we can check in constant time whether an element is present.
Answer Preview: Let us consider that x is an element which is already in the vEB tree If the insert ope…

, Chapter: 9 -Problem: 4 >> Suppose we use RANDOMIZED-SELECT to select the minimum element of the array A = ?3, 2, 9, 0, 7, 5, 4, 8, 6, 1?. Describe a sequence of partitions that results in a worst-case performance of RANDOMIZED-SELECT.
Answer Preview: In worst case Randomized select will pick the largest element in array and thus …

, Chapter: 12 -Problem: 6 >> Consider a binary search tree T whose keys are distinct. Show that if the right sub tree of a node x in T is empty and x has a successor y, then y is the lowest ancestor of x whose left child is also an ancestor of x. (Recall that every node is its own ancestor.)
Answer Preview: First we establish that yy must be a…

, Chapter: 31 -Problem: 2 >> Suppose that we are given a function f . ?n ? ?n and an initial value x0 ? ?n. Define xi = f (xi-1) for i = 1, 2, .... Let t and u > 0 be the smallest values such that xt+i = xt+u+i for i = 0, 1, .... In the terminology of Pollard’s rho algorithm, t is the length of the tail and u is the length of the cycle of the rho. Give an efficient algorithm to determine t and u exactly, and analyze its runni
Answer Preview: One way to determine t and u is to use the Floyd s cycle finding algorithm also known as the tortois…

, Chapter: 20 -Problem: 3 >> Add the attribute n to each proto-vEB structure, giving the number of elements currently in the set it represents, and write pseudocode for PROTO-VEB-DELETE that uses the attribute n to decide when to reset summary bits to 0. What is the worst-case running time of your procedure? What other procedures need to change because of the new attribute? Do these changes affect their running times?
Answer Preview: We would keep the same as before but insert immediately after the else a check of whether n 1n1 If …

, Chapter: 7 -Problem: 6 >> Consider a sorting problem in which we do not know the numbers exactly. Instead, for each number, we know an interval on the real line to which it belongs. That is, we are given n closed intervals of the form [ai, bi], where ai ? bi. We wish to fuzzy-sort these intervals, i.e., to produce a permutation ?i1, i2, . . . ,in? of the intervals such that for j = 1, 2, . . . ,n, there exist cj ? [aij , b
Answer Preview: Answer a We sort the left endpoints and their corresponding right endpoints separately Lets call thi…

, Chapter: 10 -Problem: 7 >> Show how to implement a stack using two queues. Analyze the running time of the stack operations.
Answer Preview: StackIsertion and deletion are done on the same end Queue Insertion and deletion happens on differen…

, Chapter: 24 -Problem: 3 >> Can any shortest-path weight from the new vertex ?0 in a constraint graph be positive? Explain.
Answer Preview: As v 0 is the source vertex and is directly reachabl…

, Chapter: 14 -Problem: 1 >> Show how OS-SELECT (T.root, 10) operates on the red-black tree T of Figure 14.1. Figure 14.1 Transcribed Image Text: 26 20 17 41 E--- 12 7 14 21 30 47 -------- -------- E---- ----- --- 4 1 16 2 (14 (10 19 21 28 38 4 2 1 12 20 – key 35 39 ---- T------ 2 1 1 1 1 3 size
Answer Preview: Show how OSSELECT Troot 10 operates on the redblack tree T of Figure 141 An enhanced redblack tree called an orderstatistic tree Red nodes are shaded and black nodes are darkened Each node x has a fie…

, Chapter: 23 -Problem: 3 >> Show that if an edge (u, ?) is contained in some minimum spanning tree, then it is a light edge crossing some cut of the graph.
Answer Preview: Vasco Da Gama discovered the sea route to India in the year 1498 On 20th May 1498 two years after h…

, Chapter: 10 -Problem: 1 >> For each of the four types of lists in the following table, what is the asymptotic worst-case running time for each dynamic-set operation listed? Transcribed Image Text: sorted, singly unsorted, doubly linked sorted, doubly unsorted, singly linked linked linked SEARCH(L,k) INSERT (L,x) DELETE (L,x)
Answer Preview: unsorted singly linked …

, Chapter: 20 -Problem: 2 >> Modify the data structures in this section to support keys that have associated satellite data.
Answer Preview: For any key which is a minimum on some vEB well need to store its satellite data with the min value …

, Chapter: 10 -Problem: 2 >> Write an O(n)-time recursive procedure that, given an n-node binary tree, prints out the key of each node in the tree.
Answer Preview: We can print each node key using …

, Chapter: 23 -Problem: 7 >> Argue that if all edge weights of a graph are positive, then any subset of edges that connects all vertices and has minimum total weight must be a tree. Give an example to show that the same conclusion does not follow if we allow some weights to be nonpositive.
Answer Preview: First we show that the subset of edges of minimum total weight that connects all the vertices is a t…

, Chapter: 10 -Problem: 4 >> As written, each loop iteration in the LIST-SEARCH? procedure requires two tests: one for x ? L.nil and one for x.key ? k. Show how to eliminate the test for x ? L.nil in each iteration.
Answer Preview: We can set the key of the sentinel an…

, Chapter: 24 -Problem: 9 >> Show that the Bellman-Ford algorithm, when run on the constraint graph for a system Ax ? b of difference constraints, minimizes the quantity (max {xi} – min {xi}) subject to Ax ? b. Explain how this fact might come in handy if the algorithm is used to schedule construction jobs.
Answer Preview: Definition Vasco da Gama c 14691524 was a Portuguese navigator who in 14979 sailed around th…

,

, Chapter: 29 -Problem: 9 >> Give an example of a linear program for which the feasible region is not bounded, but the optimal objective value is finite.
Answer Preview: A linear programming problem is one in which we are to find the maximum or minimum value of …

, Chapter: 4 -Problem: 1 >> What does FIND-MAXIMUM-SUBARRAY return when all elements of A are negative?
Answer Preview: If the index …

, Chapter: 24 -Problem: 12 >> Give an efficient algorithm to solve a system Ax ? b of difference constraints when all of the elements of b are real-valued and a specified subset of some, but not necessarily all, of the unknowns xi must be integers.
Answer Preview: To solve the problem of Ax le bAxb where the elements of bb are realvalue…

, Chapter: 12 -Problem: 5 >> Argue that since sorting n elements takes ?(n lg n) time in the worst case in the comparison model, any comparison-based algorithm for constructing a binary search tree from an arbitrary list of n elements takes ?(n lg n) time in the worst case.
Answer Preview: Assume for the sake of contradiction that we can construct the binary …

, Chapter: 30 -Problem: 1 >> Show how ITERATIVE-FFT computes the DFT of the input vector (0, 2, 3,?1, 4, 5, 7, 9).
Answer Preview: ITERATIVE FFT is an iterative algorithm for efficiently computing the Discrete Fourier Transform DFT …

, Chapter: 19 -Problem: 3 >> We wish to augment a Fibonacci heap H to support two new operations without changing the amortized running time of any other Fibonacci-heap operations.a. The operation FIB-HEAP-CHANGE-KEY(H, x, k) changes the key of node x to the value k. Give an efficient implementation of FIB-HEAP-CHANGE-KEY, and analyze the amortized running time of your implementation for the cases in which k is greater than,
Answer Preview: a F IB HE AP CH ANGE KEY H x k If k is greater than x key If k x …

, Chapter: 22 -Problem: 4 >> Prove that for any directed graph G, we have ((GT)SCC)T = GSCC. That is, the transpose of the component graph of GT is the same as the component graph of G.
Answer Preview: First observe that CC is a strongly connected component of GG if and only i…

,

, Chapter: 22 -Problem: 2 >> Give a linear-time algorithm that takes as input a directed acyclic graph G = (V, E) and two vertices s and t, and returns the number of simple paths from s to t in G. For example, the directed acyclic graph of Figure 22.8 contains exactly four simple paths from vertex p to vertex ?: po?, pory?, posry?, and psry?. (Your algorithm needs only to count the simple paths, not list them.) Figure 22.8
Answer Preview: The algorithm works as follows The attribute upathsupaths of node uu tells the number of simple path…

, Chapter: 31 -Problem: 2 >> It is possible to strengthen Euler's theorem slightly to the form Transcribed Image Text: ?(n) Icm (? (p]), , ?(p")) . (31.42)
Answer Preview: First let us prove that for any positive integer n and any a coprime to n we have a n 1 mod n where n is defined as in Equation 31 42 To prove this we consider the set S of positive integers less than …

, Chapter: 20 -Problem: 3 >> Write pseudocode for a procedure that creates an empty van Emde Boas tree.
Answer Preview: We define the procedure for any uu that is a power of 22 If u 2u2 then just slap that fact tog…

, Chapter: 26 -Problem: 4 >> A perfect matching is a matching in which every vertex is matched (Let G = (V, E) be an undirected bipartite graph with vertex partition V = L ? R, where |L| = |R|. For any X ? V, define the neighborhood of X as that is, the set of vertices adjacent to some member of X( Prove Hall?s theorem: there exists a perfect matching in G if and only if |A| ? |N(A)| for every subset A ? L.
Answer Preview: Let G V E be a bipartite graph with vertex partition V L R where L …

, Chapter: 22 -Problem: 2 >> Let G = (V, E) be a connected, undirected graph. An articulation point of G is a vertex whose removal disconnects G. A bridge of G is an edge whose removal disconnects G. A biconnected component of G is a maximal set of edges such that any two edges in the set lie on a common simple cycle. Figure 22.10 illustrates Figure 22.10? The articulation points, bridges, and biconnected components of a con
Answer Preview: a First suppose the root rr of GpiG is an articulation point Then the removal of rr from GG would cause the graph to disconnect so rr has at least 22 children in GG If rr has only one child vv in GpiG …

,

, Chapter: 25 -Problem: 8 >> The FASTER-ALL-PAIRS-SHORTEST-PATHS procedure, as written, requires us to store ?lg(n – 1? matrices, each with n2 elements, for a total space requirement of ?(n2 lg n). Modify the procedure to require only ?(n2) space by using only two n × n matrices.
Answer Preview: The citys first recorded contact with Europe was when Vasco da Gama docke…

, Chapter: 30 -Problem: 2 >> Show how to implement an FFT algorithm with the bit-reversal permutation occurring at the end, rather than at the beginning, of the computation.
Answer Preview: The F FT algorithm can be implemented with the bit re vers al perm utati…

, Chapter: 24 -Problem: 5 >> Show how to modify the Bellman-Ford algorithm slightly so that when we use it to solve a system of difference constraints with m inequalities on n unknowns, the running time is O(n m).
Answer Preview: If there is no negative cycle found the algorithm returns the shortest distances The B…

, Chapter: 14 -Problem: 1 >> Show, by adding pointers to the nodes, how to support each of the dynamic-set queries MINIMUM, MAXIMUM, SUCCESSOR, and PREDECESSOR in O(1) worst case time on an augmented order-statistic tree. The asymptotic performance of other operations on order-statistic trees should not be affected.
Answer Preview: MINIMUM A pointer points to the minimum node if the node i…

, Chapter: 31 -Problem: 4 >> Show that if p is prime and e is a positive integer, then ?(pe) = pe – 1 (p – 1).
Answer Preview: The triangular convex hull or simply triangular hull of a digital object denoted by T H S is the s…

, Chapter: 23 -Problem: 5 >> Let e be a maximum-weight edge on some cycle of connected graph G = (V, E). Prove that there is a minimum spanning tree of G? = (V, E – {e}) that is also a minimum spanning tree of G. That is, there is a minimum spanning tree of G that does not include e.
Answer Preview: Let AA be any cut that causes some vertices in the cycle on once side of t…

,

,

, Chapter: 21 -Problem: 1 >> Suppose that CONNECTED-COMPONENTS is run on the undirected graph G = (V, E), where V = ?a, b, c, d, e, f, g, h, i, j, k? and the edges of E are processed in the order (d, i), (f, k), (g, i), (b, g), (a, h), (i, j ), (d, k), (b, j), (d, f ), (g, j), (a, e). List the vertices in each connected component after each iteration of lines 3–5.
Answer Preview: Here is a stepbystep breakdown of the connected components after each iteration Af…

, Chapter: 11 -Problem: 3 >> Suggest how to implement a direct-address table in which the keys of stored elements do not need to be distinct and the elements can have satellite data. All three dictionary operations (INSERT, DELETE, and SEARCH) should run in O(1) time. (Don't forget that DELETE takes as an argument a pointer to an object to be deleted, not a key.)
Answer Preview: Assuming that fetching an element should return the satellite data of all the stored el…

,

,

,

, Chapter: 10 -Problem: 5 >> Let L be a doubly linked list of length n stored in arrays key, prev, and next of length m. Suppose that these arrays are managed by ALLOCATE-OBJECT and FREE-OBJECT procedures that keep a doubly linked free list F. Suppose further that of the m items, exactly n are on list L and m - n are on the free list. Write a procedure COMPACTIFY-LIST (L,F) that, given the list L and the free list F, moves th
Answer Preview: Here is a possible implementation of the COMPACTIFYLIST procedure def COMPACTIFYLISTL F Check if list L is already compact if L0 1 return Find the las…

, Chapter: 32 -Problem: 1 >> Let yi denote the concatenation of string?y?with itself?i?times. For example,?(ab)3 =?ababab. We say that a string?x????* has?repetition factor?r?if?x?=?yr for some string?y????* and some?r > 0. Let??(x)?denote the largest?r?such that?x?has repetition factor?r. a.?Give an efficient algorithm that takes as input a pattern?P [1. . m]?and computes the value??(Pi)?for?i?=?1, 2, . . . ,m. What is the r
Answer Preview: a The algorithm to compute Pi for i 1 2 m is the KMP Knuth Morris Pratt algorithm The …

, Chapter: 26 -Problem: 3 >> Show that the generic algorithm still works if RELABEL updates u.h by simply computing u.h = u.h + 1. How would this change affect the analysis of RELABEL-TO-FRONT?
Answer Preview: If we change relabel to just increment the value of uu we will not be ruining the correctness of the …

, Chapter: 9 -Problem: 1 >> Show that RANDOMIZED-SELECT never makes a recursive call to a 0-length array.
Answer Preview: Calling a 00length array would mean that the second and third arguments are equal So if th…

, Chapter: 10 -Problem: 4 >> Write an O(n)-time procedure that prints all the keys of an arbitrary rooted tree with n nodes, where the tree is stored using the left-child, right-sibling representation.
Answer Preview: PRINTBINARYTREET …

, Chapter: 23 -Problem: 6 >> Suppose that the edge weights in a graph are uniformly distributed over the halfopen interval [0, 1]. Which algorithm, Kruskal’s or Prim’s, can you make run faster?
Answer Preview: For input drawn from a uniform distrib…

, Chapter: 10 -Problem: 5 >> Write an O(n)-time non recursive procedure that, given an n-node binary tree, prints out the key of each node. Use no more than constant extra space outside of the tree itself and do not modify the tree, even temporarily, during the procedure.
Answer Preview: An time nonrecursive procedure that prints out the key of each node in the n node binary tree using …

,

,

, Chapter: 9 -Problem: 7 >> Describe an O(n)-time algorithm that, given a set S of n distinct numbers and a positive integer k – n, determines the k numbers in S that are closest to the median of S.
Answer Preview: ssume fr simliity tht n is dd nd k is even If the set S ws in srted rder the medin is in sitin n2 …

,

, Chapter: 11 -Problem: 2 >> Demonstrate what happens when we insert the keys 5, 28, 19, 15, 20, 33, 12, 17, 10 into a hash table with collisions resolved by chaining. Let the table have 9 slots, and let the hash function be h(k) = k mod 9.
Answer Preview: Hash Table It stores all the values using indexes which are formed by Hashing function these va…

, Chapter: 24 -Problem: 2 >> Suppose we change line 3 of DAG-SHORTEST-PATHS to read 3 for the first |V| - 1 vertices, taken in topologically sorted order Show that the procedure would remain correct.
Answer Preview: When we reach vertex vv the last vertex in the topological sort i…

,

, Chapter: 24 -Problem: 6 >> Suppose that in addition to a system of difference constraints, we want to handle equality constraints of the form xi = xj + bk. Show how to adapt the Bellman-Ford algorithm to solve this variety of constraint system.
Answer Preview: To obtain the equality constrai…

, Chapter: 14 -Problem: 4 >> Write a recursive procedure OS-KEY-RANK(T, k) that takes as input an order statistic tree T and a key k and returns the rank of k in the dynamic set represented by T. Assume that the keys of T are distinct.
Answer Preview: OSKEYRANKT k if k Trootkey r…

, Chapter: 21 -Problem: 2 >> Show that after all edges are processed by CONNECTED-COMPONENTS, two vertices are in the same connected component if and only if they are in the same set.
Answer Preview: CONNECTEDCOMPONENTS procedure computes a graph in such a way that it puts all the vertices of the same component in its own set The algorithm for the CONNECTEDCOMPONENTS is the following CONNECTEDCOMP…

, Chapter: 23 -Problem: 3 >> A bottleneck spanning tree T of an undirected graph G is a spanning tree of G whose largest edge weight is minimum over all spanning trees of G. We say that the value of the bottleneck spanning tree is the weight of the maximum-weight edge in T.a. Argue that a minimum spanning tree is a bottleneck spanning tree.Part (a) shows that finding a bottleneck spanning tree is no harder than finding a mini
Answer Preview: ANSWER a A minimum spanning tree is a spanning tree of a graph with the smallest possible total edge …

, Chapter: 24 -Problem: 4 >> Give an efficient algorithm to count the total number of paths in a directed acyclic graph. Analyze your algorithm.
Answer Preview: If its not a directed graph then there is at most 1 path between any …

, Chapter: 21 -Problem: 1 >> Write pseudocode for MAKE-SET, FIND-SET, and UNION using the linked-list representation and the weighted-union heuristic. Make sure to specify the attributes that you assume for set objects and list objects.
Answer Preview: SOLUTION Given that psudocode for MAKE SET END SET UNION SET F…

, Chapter: 20 -Problem: 8 >> Suppose that we designed a proto-vEB structure in which each cluster array had only u1/4 elements. What would the running times of each operation be?
Answer Preview: right continuing on our lovely journey of our in computer science we are talking a little bit more a…

, Chapter: 24 -Problem: 6 >> Let G = (V, E) be a weighted, directed graph with weight function w : E ? ? and no negative-weight cycles. Let s ? V be the source vertex, and let G be initialized by INITIALIZE-SINGLE-SOURCE (G, s). Prove that for every vertex ? ? V?, there exists a path from s to ? in G? and that this property is maintained as an invariant over any sequence of relaxations.
Answer Preview: Input is a directed graph G V E and a weight function w E Define the path weight w p of path p v 0 v 1 v k to be the sum of edge weights on the path T…

,

, Chapter: 22 -Problem: 1 >> How can the number of strongly connected components of a graph change if a new edge is added?
Answer Preview: The number of unequivocally associated components can as diminish as the number of edges increments …

, Chapter: 22 -Problem: 8 >> Suppose that instead of a linked list, each array entry Adj[u] is a hash table containing the vertices ? for which (u, ?) ? E. If all edge lookups are equally likely, what is the expected time to determine whether an edge is in the graph? What disadvantages does this scheme have? Suggest an alternate data structure for each edge list that solves these problems. Does your alternative have disadvant
Answer Preview: A negative weight cycle is a cycle with weights that sum to …

, Chapter: 25 -Problem: 9 >> Modify FASTER-ALL-PAIRS-SHORTEST-PATHS so that it can determine whether the graph contains a negative-weight cycle.
Answer Preview: For the modification keep computing for one step more than the original that is we compute all …

, Chapter: 26 -Problem: 5 >> We say that a bipartite graph G = (V, E), where V = L ? R, is d-regular if every vertex ? ? V has degree exactly d. Every d-regular bipartite graph has |L| = |R|. Prove that every d-regular bipartite graph has a matching of cardinality |L| by arguing that a minimum cut of the corresponding flow network has capacity |L|.
Answer Preview: We prove an asymptotically tight bound on the extremal density guaranteei…

, Chapter: 22 -Problem: 4 >> Prove or disprove: If a directed graph G contains cycles, then TOPOLOGICAL-SORT (G) produces a vertex ordering that minimizes the number of “bad” edges that are inconsistent with the ordering produced.
Answer Preview: This is not true Consider the graph GG consisting of vert…

, Chapter: 21 -Problem: 2 >> Prove that every node has rank at most ?lg n?.
Answer Preview: The concept of unionfind data structure is driven from Kruskals minimum spanning tree algorithm where two operations are required on the disjoint set …

, Chapter: 24 -Problem: 1 >> Find a feasible solution or determine that no feasible solution exists for the following system of difference constraints: Transcribed Image Text: X1 – X2 < 1, X1 – X4 < -4, 2, X2 – X3 < 1. X2 - X5 < X2 – X6 < 5, 10 , X3 – X6 X4 – X2 < 2, X5 – X1 < -1, X5 - X4 < 3, ?6 — ?? < -8. rinivis VI VI VI VI
Answer Preview: To find a feasible solution or determine …

, Chapter: 24 -Problem: 8 >> Let Ax ? b be a system of m difference constraints in n unknowns. Show that the Bellman-Ford algorithm, when run on the corresponding constraint graph, maximizes ?n1=1 xi subject to Ax ? b and xi ? 0 for all xi.
Answer Preview: BellmanFord correctly solves the system of difference constraints …

, Chapter: 24 -Problem: 11 >> Give an efficient algorithm to solve a system Ax ? b of difference constraints when all of the elements of b are real-valued and all of the unknowns xi must be integers.
Answer Preview: In graph theory a flow network also known as a transportation network is a directed graph wh…

, Chapter: 22 -Problem: 2 >> Give an adjacency-list representation for a complete binary tree on 7 vertices. Give an equivalent adjacency-matrix representation. Assume that vertices are numbered from 1 to 7 as in a binary heap.
Answer Preview: The time to compute the textoutdegreeoutdegree of every vertex is sumv i…

,

,

, Chapter: 25 -Problem: 6 >> Suppose we also wish to compute the vertices on shortest paths in the algorithms of this section. Show how to compute the predecessor matrix … from the completed matrix ? of shortest-path weights in O(n3) time.
Answer Preview: For each source vertex vivi we need to compute the shortestpaths tree for vivi To do thi…

, Chapter: 25 -Problem: 2 >> A graph G = (V, E) is ?-dense if |E| = ?(V 1+?) for some constant ? in the range 0 < ? ? 1. By using d-ary min-heaps in shortest-paths algorithms on ?-dense graphs, we can match the running times of Fibonacci-heap based algorithms without using as complicated a data structure.a. What are the asymptotic running times for INSERT, EXTRACT-MIN, and DECREASE-KEY, as a function of d and the number n of
Answer Preview: a The asymptotic running times for INSERT EXTRACTMIN and DECREASEKEY operations in a dary minheap are Od log n Od log n and Olog n respectively If we …

, Chapter: 26 -Problem: 1 >> An n ? n grid is an undirected graph consisting of n rows and n columns of vertices, as shown in Figure 26.11. We denote the vertex in the i th row and the j th column by (I, j). All vertices in a grid have exactly four neighbors, except for the boundary vertices, which are the points (I, j) for which i = 1, i = n, j = 1, or j = n. Given m ? n2 starting points?(x1, y1), (x2, y2), . . . , (xm, ym)?
Answer Preview: a Consider a network flow G V E with edge capacity and vertex capacity Keep the edge capacity constraint skew symmetry and flow conservation same Consider the new requirement for every there is a need …

, Chapter: 23 -Problem: 4 >> In this problem, we give pseudocode for three different algorithms. Each one takes a connected graph and a weight function as input and returns a set of edges T. For each algorithm, either prove that T is a minimum spanning tree or prove that T is not a minimum spanning tree. Also describe the most efficient implementation of each algorithm, whether or not it computes a minimum spanning tree. a.?M
Answer Preview: a This does return an textMSTMST To see this well show that we never remove an edge which must be part of a minimum spanning tree If we remove ee then …

,

, Chapter: 23 -Problem: 2 >> Professor Sabatier conjectures the following converse of Theorem 23.1. Let G = (V, E) be a connected, undirected graph with a real-valued weight function w defined on E. Let A be a subset of E that is included in some minimum spanning tree for G, let (S, V – S) be any cut of G that respects A, and let (u, ?) be a safe edge for A crossing (S, V – S). Then, (u, ?) is a light edge for the cut. Show t
Answer Preview: Let GG be the graph with 44 vertices u v w zuvwz Let the edges of the graph be u v u w w z…

, Chapter: 32 -Problem: 7 >> Give a linear-time algorithm to determine whether a text T is a cyclic rotation of another string T?. For example, arc and car are cyclic rotations of each other.
Answer Preview: Computational geometry is a mathematical field that i…

, Chapter: 26 -Problem: 2 >> We would like to implement a push-relabel algorithm in which we maintain a first in, first-out queue of overflowing vertices. The algorithm repeatedly discharges the vertex at the head of the queue, and any vertices that were not overflowing before the discharge but are overflowing afterward are placed at the end of the queue. After the vertex at the head of the queue is discharged, it is removed.
Answer Preview: Initially the vertices adjacent to ss are the only ones which are overflowing The implementation is …

, Chapter: 33 -Problem: 4 >> Professor Charon has a set of n sticks, which are piled up in some configuration. Each stick is specified by its endpoints, and each endpoint is an ordered triple giving its (x, y, z) coordinates. No stick is vertical. He wishes to pick up all the sticks, one at a time, subject to the condition that he may pick up a stick only if there is no other stick on top of it.a. Give a procedure that takes
Answer Preview: a To determine whether stick a is above below or unrelated to stick b one must compare the x y z coo…

, Chapter: 23 -Problem: 2 >> Suppose that we represent the graph G = (V, E) as an adjacency matrix. Give a simple implementation of Prim’s algorithm for this case that runs in O(V2) time.
Answer Preview: A Java program for Prims Minimum Spanning Tree MST algorithm The program is for adjacency matrix representation of the graph import javautil import ja…

, Chapter: 35 -Problem: 1 >> Show that even if we allow a clause to contain both a variable and its negation, randomly setting each variable to 1 with probability 1/2 and to 0 with probability 1/2 still yields a randomized 8/7-approximation algorithm.
Answer Preview: A googol is 10 to the 100th power which is 1 followed by 100 zeros A googol is larger than the …

, Chapter: 20 -Problem: 5 >> Modify the proto-vEB structure to support keys that have associated satellite data.
Answer Preview: The only modification necessary would be for th…

, Chapter: 34 -Problem: 10 >> Prove that if NP ? co-NP, then P ? NP.
Answer Preview: This statement is actually not true It is possible for NP coNP and P NP …

, Chapter: 26 -Problem: 2 >> Show how to implement the generic push-relabel algorithm using O(V) time per relabel operation, O(1) time per push, and O(1) time to select an applicable operation, for a total time of O(V2E).
Answer Preview: Initially the vertices adjacent to ss are the only ones which are overflowing The implementation is …

, Chapter: 35 -Problem: 1 >> Suppose that we are given a set of n objects, where the size si of the i th object satisfies 0 < si < 1. We wish to pack all the objects into the minimum number of unit-size bins. Each bin can hold any subset of the objects whose total size does not exceed 1.a. Prove that the problem of determining the minimum number of bins required is NP-hard. The first-fit heuristic takes each object in turn an
Answer Preview: The firstfit heuristic takes each object in turn and places it into the first bin that can accomodate it Requirements g supporting c17 Developed with gcc 730 GNU Make Developed with 421 If youd like t…

, Chapter: 24 -Problem: 8 >> Let G = (V, E) be a weighted, directed graph with nonnegative weight function w : E ? {0, 1, . . . ,W} for some nonnegative integer W. Modify Dijkstra's algorithm to compute the shortest paths from a given source vertex s in O(W V + E) time.
Answer Preview: Observe that if a shortestpath estimate is not then its at most V 1 W Why In order to have d we must have relaxed an edge u with ud By induction we ca…

, Chapter: 24 -Problem: 2 >> Find a feasible solution or determine that no feasible solution exists for the following system of difference constraints: Transcribed Image Text: X1 – X2 < 4, X1 – X5 < 5, X2 - X4 < -6, 1, X3 – X2 < X4 – X1 3, 5, X4 – X3 X4 – X5 < 10 , X5 – X3 < -4, X5 – X4 < -8. VI VI VI VI VI VI VI VI VI
Answer Preview: x1 x2 1 x1 x3 2 A feasible solution exists where x1 1 x2 2 and x3 3 Explanation There are an infinit…

, Chapter: 26 -Problem: 13 >> Suppose that you wish to find, among all minimum cuts in a flow network G with integral capacities, one that contains the smallest number of edges. Show how to modify the capacities of G to create a new flow network G? in which any minimum cut in G? is a minimum cut with the smallest number of edges in G.
Answer Preview: LetS TandX Ybe two cuts inGandG Letcbe the capacity function ofGOne way to definecis to add a small …

, Chapter: 20 -Problem: 7 >> Argue that if line 9 of PROTO-VEB-MINIMUM is executed, then the proto-vEB structure is empty.
Answer Preview: cells celltype markdown metadata source 202 A recursive structure celltype markdown metadata source 2021 Write pseudocode for the procedures PROTOVEBMAXIMUM and PROTOVEBPREDECESSOR celltype code execu…

, Chapter: 21 -Problem: 1 >> The off-line minimum problem asks us to maintain a dynamic set T of elements from the domain {1, 2, . . . ,n} under the operations INSERT and EXTRACT-MIN.We are given a sequence S of n INSERT and m EXTRACT-MIN calls, where each key in {1, 2, . . . ,n} is inserted exactly once. We wish to determine which key is returned by each EXTRACT-MIN call. Specifically, we wish to fill in an array extracted [
Answer Preview: a For the input sequence 4 8 E 3 E 9 2 6 E E E 1 7 E 5 the values in the answeed array would be 4 3 2 6 8 1 The following table shows the situation after the i th iteration of the for loop when we u…

, Chapter: 14 -Problem: 2 >> Can we maintain the black-heights of nodes in a red-black tree as attributes in the nodes of the tree without affecting the asymptotic performance of any of the red black tree operations? Show how, or argue why not. How about maintaining the depths of nodes?
Answer Preview: Yes we can maintain blackheights as attributes in the nodes of a redblack tree without affecting the asymptotic performance of the redblack tree operations We appeal to Theorem 141 because the blackhe…

, Chapter: 12 -Problem: 2 >> Given two strings a = a0a1 . . .ap and b = b0b1 . . .bq, where each ai and each bj is in some ordered set of characters, we say that string a is lexicographically less than string b if either 1. there exists an integer j, where 0 ? j ? min(p, q), such that ai = bi for all i = 0, 1, . . . , j – 1 and aj < bj, or2. p < q and ai = bi for all i = 0, 1, . . . , p.For example, if a and b are bit strings
Answer Preview: To sort the strings of S we first insert them into a radix tree and then use a preorder tree walk to …

, Chapter: 8 -Problem: 2 >> Explain why the worst-case running time for bucket sort is ?(n2). What simple change to the algorithm preserves its linear average-case running time and makes its worst-case running time O(n lg n)?
Answer Preview: The worstcase running time for the bucketsort algorithm occurs when the assumption of uniformly dis…

, Chapter: 15 -Problem: 4 >> Describe the subproblem graph for matrix-chain multiplication with an input chain of length n. How many vertices does it have? How many edges does it have, and which edges are they?
Answer Preview: The vertices of the subproblem graph are the ordered pairs …

, Chapter: 8 -Problem: 4 >> Show how to sort n integers in the range 0 to n3 - 1 in O(n) time.
Answer Preview: Treat the numbers as 3digit numbers in ra…

, Chapter: 21 -Problem: 3 >> Give a sequence of m MAKE-SET, UNION, and FIND-SET operations, n of which are MAKE-SET operations, that takes ?(m lg n) time when we use union by rank only.
Answer Preview: You need to find a sequence ofmoperations onnelements that takes…

, Chapter: 13 -Problem: 4 >> Professor Teach is concerned that RB-INSERT-FIXUP might set T.nil.color to RED, in which case the test in line 1 would not cause the loop to terminate when z is the root. Show that the professor’s concern is unfounded by arguing that RBINSERT- FIXUP never sets T.nil.color to RED.
Answer Preview: Colors are set to red only in cases 1 and 3 and in both situations it is zpp that is red…

, Chapter: 15 -Problem: 12 >> Suppose that you are the general manager for a major-league baseball team. During the off-season, you need to sign some free-agent players for your team. The team owner has given you a budget of $X to spend on free agents. You are allowed to spend less than $X altogether, but the owner will fire you if you spend any more than $X.You are considering N different positions, and for each position, P f
Answer Preview: Let pcost denote the cost and porp denote the VORP of player p We shall assume that all dollar amounts are expressed in units of 100000 Since the order of choosing players for the positions ds not mat…

, Chapter: 6 -Problem: 6 >> Each exchange operation on line 5 of HEAP-INCREASE-KEY typically requires three assignments. Show how to use the idea of the inner loop of INSERTION-SORT to reduce the three assignments down to just one assignment.
Answer Preview: Change the procedure to the following …

, Chapter: 15 -Problem: 8 >> We are given a color picture consisting of an m × n array A[1 . .m, 1 . . n] of pixels, where each pixel specifies a triple of red, green, and blue (RGB) intensities. Suppose that we wish to compress this picture slightly. Specifically, we wish to remove one pixel from each of the m rows, so that the whole picture becomes one pixel narrower. To avoid disturbing visual effects, however, we require
Answer Preview: a Let us set up a recurrence for the number of valid seams as a function ofm Suppose we are in the process of carving out a seam row by row starting from the first row Let the last pixel carved out be…

, Chapter: 26 -Problem: 4 >> Suppose that we have found a maximum flow in a flow network G = (V, E) using a push-relabel algorithm. Give a fast algorithm to find a minimum cut in G.
Answer Preview: We can find a minimum cut given a maximum flow found in G V E by a pushrelabel algorithm in OV time …

, Chapter: 22 -Problem: 3 >> Show that using a single bit to store each vertex color suffices by arguing that the BFS procedure would produce the same result if lines 5 and 14 were removed.
Answer Preview: This exercise changed in the third printing This solution reflects the change The …

, Chapter: 34 -Problem: 7 >> Let 2-CNF-SAT be the set of satisfiable boolean formulas in CNF with exactly 2 literals per clause. Show that 2-CNF-SAT 2 P. Make your algorithm as efficient as possible. Observe that x ? y is equivalent to ¬ x ? y. Reduce 2-CNF-SAT to an efficiently solvable problem on a directed graph.
Answer Preview: 2SAT is the problem of counting the num…

, Chapter: 29 -Problem: 2 >> Show that when the main loop of SIMPLEX is run by INITIALIZE-SIMPLEX, it can never return “unbounded.”
Answer Preview: If we were to convert this linear program to slack form the basic solution …

, Chapter: 16 -Problem: 2 >> Given an m × n matrix T over some field (such as the reals), show that (S, I) is a matroid, where S is the set of columns of T and A ? I if and only if the columns in A are linearly independent.
Answer Preview: We need to show three things to prove that S I is a matroid 1 S is finite Thats because …

, Chapter: 37 -Problem: 1 >> Attendees of a faculty party shake hands to greet each other, and each professor remembers how many times he or she shook hands. At the end of the party, the department head adds up the number of times that each professor shook hands. Show that the result is even by proving the handshaking lemma: if G = (V, E) is an undirected graph, then
Answer Preview: The Handshaking Lemma states that the sum of all the degrees of the vertices in a graph is equa…

, Chapter: 35 -Problem: 2 >> Let G = (V, E) be an undirected graph. For any k ? 1, define G(k) to be the undirected graph (V(k), E(k)), where V(k) is the set of all ordered k-tuples of vertices from V and E(k) is defined so that (?1, ?2, . . . , ?k) is adjacent to (w1, w2, . . . ,wk) if and only if for i = 1, 2, . . . ,k, either vertex ?i is adjacent to wi in G, or else ?i = wi.a. Prove that the size of the maximum clique in 
Answer Preview: a To prove that the size of the maximum clique in Gk is equal to the kth power of the size of the ma…

, Chapter: 28 -Problem: 6 >> Show that for all n ? 1, there exists a singular n × n matrix that has an LU decomposition.
Answer Preview: Vasco da Gama landed in Kozhikode Calicut Kerala on the Western sea coast of India on May 20 …

, Chapter: 15 -Problem: 2 >> Show, by means of a counterexample, that the following "greedy" strategy does not always determine an optimal way to cut rods. Define the density of a rod of length i to be pi/i, that is, its value per inch. The greedy strategy for a rod of length n cuts off a first piece of length i, where 1 ?  i ? n, having maximum density. It then continues by applying the greedy strategy to the remaining piece
Answer Preview: Here is a counterexample for the greedy strategy Let the given rod length be …

, Chapter: 36 -Problem: 5 >> Why didn’t we use the integral approximation (A.12) directly on P

Additional Information

Book:
Introduction to Algorithms
Isbn:
ISBN: 978-0262033848
Edition:
3rd edition
Author:
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Image:
1778.jpg

19 Reviews for Introduction to Algorithms Textbook Questions And Answers

Cash Taylor
Absolutely amazing. Very fast, sufficient and awesome! My tutor: Textbook answers was so kind to give me a report making sure where he got his sources and that my whole essay was not plagiarized. I love my tutor. From the bottom of my heart, thank you so very much!
Jamar Cortez
First Quality work each and every time. Its no wonder he has 600 completed orders!!!!
Landen Rush
This tutor is reliable and does excellent work. I am very satisfied with the work of homework_solution.
Rashad Watts
This tutor is outstanding!!!
Gemma Moon
Homework_Soultion: Always on time, Always complete, Always Flawless

Add a review

Your Rating

88042

Character Limit 400