All Matches
Solution Library
Expert Answer
Textbooks
Search Textbook questions, tutors and Books
Oops, something went wrong!
Change your search query and then try again
Toggle navigation
FREE Trial
S
Books
FREE
Tutors
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Hire a Tutor
AI Study Help
New
Search
Search
Sign In
Register
study help
computer science
introduction to algorithms
Questions and Answers of
Introduction to Algorithms
Write a nonrecursive version of OS-SELECT.
Rewrite the MERGE procedure so that it does not use sentinels, instead stopping once either array L or R has had all its elements copied back to A and then copying the remainder of the other array
For a given polygon P and a point q on its boundary, the shadow of q is the set of points r such that the segment q̅r is entirely on the boundary or in the interior of P. As Figure 33.10
Prove equation (12.3). (12.3).
Write recursive versions of TREE-MINIMUM and TREE-MAXIMUM.
Write the TREE-PREDECESSOR procedure.
Write pseudocode for RIGHT-ROTATE.
If we insert a set of n items into a binary search tree, the resulting tree may be horribly unbalanced, leading to long search times. As we saw in Section 12.4, however, randomly built binary search
Rewrite the code for INTERVAL-SEARCH so that it works properly when all intervals are open.
Give a memoized version of LCS-LENGTH that runs in O(mn) time.
Use the substitution method to show that the solution to the recurrence (15.6) is Ω(2n).
a. The incidence matrix for an undirected graph G D (V, E) is a |V| × |E| matrix M such that Mνe = 1 if edge e is incident on vertex ν, and Mνe = 0 otherwise. Argue that a set of columns of M is
Show the results of deleting C, P, and V , in order, from the tree of Figure 18.8(f). Figure 18.8
Write pseudocode for B-TREE-DELETE.
The binomial tree Bk is an ordered tree (see Section B.5.2) defined recursively. As shown in Figure 19.6(a), the binomial tree B0 consists of a single node. The binomial tree Bk consists of two
Chapter 18 introduced the 2-3-4 tree, in which every internal node (other than possibly the root) has two, three, or four children and all leaves have the same depth. In this problem, we shall
Write pseudocode for the procedures PROTO-VEB-MAXIMUM and PROTO-VEBPREDECESSOR.
Modify vEB trees to support duplicate keys.
This problem investigates D. Willard's "y-fast tries" which, like van Emde Boas trees, perform each of the operations MEMBER, MINIMUM, MAXIMUM, PREDECESSOR, and SUCCESSOR on elements drawn from a
The least common ancestor of two nodes u and ν in a rooted tree T is the node w that is an ancestor of both u and ν and that has the greatest depth in T. In the off-line least-common-ancestors
Rewrite the procedure DFS, using a stack to eliminate recursion.
Just as with ordinary serial algorithms, we sometimes want to implement randomized multithreaded algorithms. This problem explores how to adapt the various performance measures in order to handle the
Put the single-pair shortest-path linear program from (29.44)–(29.46) into standard form.
Complete the proof of Lemma 29.4 by showing that it must be the case that c = c′ and ν = ν′.
If we express the linear program in (29.24)–(29.28) in the compact notation of (29.19)–(29.21), what are n, m, A, b, and c?
Give three feasible solutions to the linear program in (29.24)–(29.28). What is the objective value of each one?
Write down the dual of the maximum-flow linear program, as given in lines (29.47)–(29.50) on page 860. Explain how to interpret this formulation as a minimum-cut problem.
Rewrite the linear program for maximum flow (29.47)–(29.50) so that it uses only O(V + E) constraints.
Show that the dual of the dual of a linear program is the primal linear program.
In this problem, we consider a variant of the minimum-cost-flow problem from Section 29.2 in which we are not given a demand, a source, or a sink. Instead, we are given, as before, a flow network and
Show that a set of n line segments may contain Θ(n2) intersections.
Prove that in the procedure GRAHAM-SCAN, points p1 and pm must be vertices of CH (Q).
Show that we could have used a satisfying assignment as a certificate in an alternative proof of Lemma 34.5. Which certificate makes for an easier proof?
The proof of Lemma 34.6 assumes that the working storage for algorithm A occupies a contiguous region of polynomial size. Where in the proof do we exploit this assumption? Argue that this assumption
Give an example of a graph for which APPROX-VERTEX-COVER always yields a suboptimal solution.
Recall the knapsack problem from Section 16.2. There are n items, where the i th item is worth νi dollars and weighs wi pounds. We are also given a knapsack that can hold at
Prove the generalization of equation (B.3), which is called the principle of inclusion and exclusion:
Show that the conditions of Theorem C.8 imply that Similarly, show that the conditions of Corollary C.9 imply that
Show that for 0 ≤ k ≤ n, where H (x) is the entropy function (C.7).
Show that choosing α = ln (r/μ) minimizes the right-hand side of inequality (C.47).
Prove that Var [aX] = a2Var [X] from the definition (C.27) of variance.
Use induction on all integers k such that 0 ≤ k ≤ n/2 to prove inequality (C.6), and use equation (C.3) to extend it to all integers k such that 0 ≤ k ≤ n.
Rewrite the INSERTION-SORT procedure to sort into nonincreasing instead of nondecreasing order.
Prove equation (3.16).
Use the master method to show that the solution to the binary-search recurrence T (n) = T (n/2) + Θ(1) is T (n) = Θ(lg n).Exercise 2.3-5Referring back to the searching problem (see Exercise 2.1-3),
Prove that COUNTING-SORT is stable.
Rewrite ENQUEUE and DEQUEUE to detect underflow and overflow of a queue.
Give a recursive version of the TREE-INSERT procedure.
Write an iterative version of RANDOMIZED-SELECT.
Exercise 10.3-4 asked how we might maintain an n-element list compactly in the first n positions of an array. We shall assume that all keys are distinct and that the compact list is also sorted, that
Compute the values (d, x, y) that the call EXTENDED-EUCLID(899, 493) returns.
Prove that if Alice’s public exponent e is 3 and an adversary obtains Alice’s secret exponent d, where 0 < d < Φ(n), then the adversary can factor Alice’s modulus n in time polynomial in
Consider the following change to line 3 of the procedure MODULAR-LINEARE-QUATION-SOLVER:3 x0 = x′(b/d) mod (n/d)Will this work? Explain why or why not.
This problem compares the efficiency of three methods for computing the nth Fibonacci number Fn, given n. Assume that the cost of adding, subtracting, or multiplying two numbers is O(1),
Use an aggregate analysis to show that the running time of KMP-MATCHER is Θ(n).
Use a potential function to show that the running time of KMP-MATCHER is Θ(n).
What does EXTENDED-EUCLID (Fk+1, Fk) return? Prove your answer correct.
Prove that if a and b are any positive integers such that a | b, then (x mod b) mod a = x mod a for any x. Prove, under the same assumptions, that x = y (mod b) implies x = y (mod a) for any integers
Construct the string-matching automaton for the pattern P = aabab and illustrate its operation on the text string T = aaababaabaababaab.
Compute the prefix function for the pattern ababbabbabbababbabb.
Suppose that all characters in the pattern P are different. Show how to accelerate NAIVE-STRING-MATCHER to run in time O(n) on an n-character text T .
Draw a state-transition diagram for a string-matching automaton for the pattern ababbabbababbababbabb over the alphabet ∑ = {a, b}.
Repeat Exercise C-8.47, implementing the postordermethod of the AbstractTree class.
Repeat Exercise C-8.47, implementing the AbstractBinaryTree’s inordermethod.
In Section 11.1.4 we claim that the subMap method of a binary search tree, as implemented in Code Fragment 11.6, executes in O(s+h) time where s is the number of entries contained within the submap
Modify our in-place quick-sort implementation of Code Fragment 12.6 to be a randomized version of the algorithm, as discussed in Section 12.2.1.
Implement the B-tree data structure, assuming a block size of 1024 and integer keys. Test the number of “disk transfers” needed to process a sequence of map operations.
Write a Java class that implements all the methods of the sorted map ADT by means of an (a,b) tree, where a and b are integer constants passed as parameters to a constructor.
Write a Java class that simulates the best-fit, worst-fit, first-fit, and next-fit algorithms for memory management. Determine experimentally which method is the best under various sequences of
Describe an efficient external-memory algorithm that determines whether an array of n integers contains a value occurring more than n/2 times.
Consider the page caching problem where the memory cache can hold m pages, and we are given a sequence P of n requests taken from a pool of m+1 possible pages. Describe the optimal strategy for the
Another possible external-memorymap implementation is to use a skip list, but to collect consecutive groups of O(B) nodes, in individual blocks, on any level in the skip list. In particular, we
Describe a modified version of the B-tree insertion algorithm so that each time we create an overflow because of a split of a node w, we redistribute keys among all of w’s siblings, so that each
Change the rules that define red-black trees so that each red-black tree T has a corresponding (4,8) tree, and vice versa.
Describe an efficient external-memory algorithm for removing all the duplicate entries in an array list of size n.
Draw the result of inserting, into an initially empty order-7 B-tree, entries with keys (4,40,23,50,11,34,62,78,66,22,90,59,25,72,64,77,39,12), in this order.
Describe, in detail, algorithms for adding an item to, or deleting an item from, an (a,b) tree.
Julia just bought a new computer that uses 64-bit integers to address memory cells. Argue why Julia will never in her life be able to upgrade the main memory of her computer so that it is the
Write a program that builds the routing tables for the nodes in a computer network, based on shortest-path routing, where path distance is measured by hop count, that is, the number of edges in a
One way to construct a maze starts with an n×n grid such that each grid cell is bounded by four unit-length walls. We then remove two boundary unit-length walls, to represent the start and finish.
Perform an experimental comparison of two of the minimum spanning tree algorithms discussed in this chapter (Kruskal and Prim-Jarnik). Develop an extensive set of experiments to test the running
Develop a Java implementation of the Prim-Jarnik algorithm for computing the minimum spanning tree of a graph.
Design an experimental comparison of repeated DFS traversals versus the Floyd-Warshall algorithm for computing the transitive closure of a directed graph.
Extend the class of Exercise P-14.75 to support the update methods of the graph ADT.In Exercise P-14.75Implement the simplified graph ADT described in Exercise P-14.73, using the adjacency list
Implement the simplified graph ADT described in Exercise P-14.73, using the adjacency list structure.In ExerciseUse an adjacencymatrix to implement a class supporting a simplified graph ADT that does
Implement the simplified graph ADT described in Exercise P-14.73, using the edge list structure.In ExerciseUse an adjacencymatrix to implement a class supporting a simplified graph ADT that does not
Use an adjacencymatrix to implement a class supporting a simplified graph ADT that does not include update methods. Your class should include a constructor method that takes two collections—a
An old MST method, called Baruvka?s algorithm, works as follows on a graph G having n vertices and m edges with distinct weights: Prove that this algorithm is correct and that it runs in O(mlogn)
Our implementation of shortestPathLengths in Code Fragment 14.13 relies on use of ?infinity? as a numeric value, to represent the distance bound for vertices that are not (yet) known to be reachable
Give an example of a weighted directed graph G with negative-weight edges, but no negative-weight cycle, such that Dijkstra’s algorithm incorrectly computes the shortest-path distances from some
Give an example of an n-vertex simple graph G that causes Dijkstra’s algorithm to run in Ω(n2 logn) time when its implemented with a heap.
Design an efficient algorithm for finding a longest directed path from a vertex s to a vertex t of an acyclic weighted directed graph G. Specify the graph representation used and any auxiliary data
Let G be a weighted directed graph with n vertices. Design a variation of Floyd-Warshall’s algorithm for computing the lengths of the shortest paths from each vertex to every other vertex in O(n3)
Say that an n-vertex directed acyclic graph G is compact if there is some way of numbering the vertices of G with the integers from 0 to n−1 such that G contains the edge (i, j) if and only if i
An Euler tour of a directed graph G with n vertices and m edges is a cycle that traverses each edge of G exactly once according to its direction. Such a tour always exists if G is connected and the
Provide an implementation of the BFS algorithm that uses a FIFO queue, rather than a level-by-level formulation, to manage vertices that have been discovered until the time when their neighbors are
Show that if T is a BFS tree produced for a connected graph G, then, for each vertex v at level i, the path of T between s and v has i edges, and any other path of G between s and v has at least i
Explain why there are no forward nontree edges with respect to a BFS tree constructed for a directed graph.
Explain why all nontree edges are cross edges, with respect to a BFS tree constructed for an undirected graph.
Write a method, components(G), for undirected graph G, that returns a dictionary mapping each vertex to an integer that serves as an identifier for its connected component. That is, two vertices
Showing 1 - 100
of 1549
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Last