New Semester
Started
Get
50% OFF
Study Help!
--h --m --s
Claim Now
Question Answers
Textbooks
Find textbooks, questions and answers
Oops, something went wrong!
Change your search query and then try again
S
Books
FREE
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
Tutors
Online Tutors
Find a Tutor
Hire a Tutor
Become a Tutor
AI Tutor
AI Study Planner
NEW
Sell Books
Search
Search
Sign In
Register
study help
computer science
introduction to algorithms
Introduction to Algorithms 3rd edition Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest - Solutions
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
Modify the data structures in this section to support duplicate keys.
Write pseudocode for PROTO-VEB-DELETE. It should update the appropriate summary bit by scanning the related bits within the cluster. What is the worstcase running time of your procedure?
Modify vEB trees to support keys that have associated satellite data.
Modify the data structures in this section to support keys that have associated satellite data.
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.
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
Write pseudocode for a procedure that creates an empty van Emde Boas tree.
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?
Modify the proto-vEB structure to support duplicate keys.
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
Modify the proto-vEB structure to support keys that have associated satellite data.
Suppose that instead of ↑√u clusters, each with universe size ↓√u, we constructed vEB trees to have u1/k clusters, each with universe size u1-1/k, where k > 1 is a constant. If we were to modify the operations appropriately, what would be
Write pseudocode for a procedure that creates a proto-νEB(u) structure.
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)?
Argue that if line 9 of PROTO-VEB-MINIMUM is executed, then the proto-vEB structure is empty.
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?
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
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.
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.
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
Write a nonrecursive version of FIND-SET with path compression.
Prove that every node has rank at most ⌊lg n⌋.
During the execution of CONNECTED-COMPONENTS on an undirected graph G = (V, E) with k connected components, how many times is FIND-SET called? How many times is UNION called? Express your answers in terms of |V|, |E|, and k.
Make a 3-by-3 chart with row and column labels WHITE, GRAY, and BLACK. In each cell (I, j), indicate whether, at any point during a depth-first search of a directed graph, there can be an edge from a vertex of color i to a vertex of color j. For each possible edge, indicate what edge types it can
How can the number of strongly connected components of a graph change if a new edge is added?
Given an adjacency-list representation of a directed graph, how long does it take to compute the out-degree of every vertex? How long does it take to compute the in-degrees?
Show how depth-first search works on the graph of Figure 22.6. Assume that the?for?loop of lines 5-7 of the DFS procedure considers the vertices in alphabetical order, and assume that each adjacency list is ordered alphabetically. Show the discovery and finishing times for each vertex, and show the
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?,
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.
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
Professor Bacon claims that the algorithm for strongly connected components would be simpler if it used the original (instead of the transpose) graph in the second depth-first search and scanned the vertices in order of increasing finishing times. Does this simpler algorithm always produce correct
The transpose of a directed graph G = (V, E) is the graph GT = (V, ET), where ET = {(ν, u) ∈ V × V : (u, ν) ∈ E}. Thus, GT is G with all its edges reversed. Describe efficient algorithms for computing GT from G, for both the adjacencylist and
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?
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.
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.
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
The square of a directed graph G = (V, E) is the graph G2 = (V, E2) such that (u, ν) ∈ E2 if and only G contains a path with at most two edges between u and ν. Describe efficient algorithms for
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.
The diameter of a tree T = (V, E) is defined as maxu,ν∈V δ(u, ν), that is, the largest of all shortest-path distances in the tree. Give an efficient algorithm to compute the diameter of a tree, and analyze the running time of your algorithm.
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
Let G = (V, E) be a connected, undirected graph. Give an O(V + E)-time algorithm to compute a path in G that traverses each edge in E exactly once in each direction. Describe how you can find your way out of a maze if you are given a large supply of pennies.
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.
A directed graph G = (V, E) is singly connected if u ⤳ ν implies that G contains at most one simple path from u to ν for all vertices u, ν ∈ V. Give an efficient algorithm to determine whether or not a directed graph is singly connected.
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,
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
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.
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
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
For a sparse graph G = (V, E), where |E| = Θ(V), is the implementation of Prim’s algorithm with a Fibonacci heap asymptotically faster than the binary-heap implementation? What about for a dense graph, where |E| = Θ(V2)? How must the sizes |E| and |V| be related for the Fibonacci-heap
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.
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?
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.
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.
Kruskal’s algorithm can return different spanning trees for the same input graph G, depending on how it breaks ties when the edges are sorted into order. Show that for each minimum spanning tree T of G, there is a way to sort the edges of G in Kruskal’s algorithm so that the algorithm returns T.
Let T be a minimum spanning tree of a graph G, and let L be the sorted list of the edge weights of T. Show that for any other minimum spanning tree T′ of G, the list L is also the sorted list of edge weights of T′.
Professor Borden proposes a new divide-and-conquer algorithm for computing minimum spanning trees, which goes as follows. Given a graph G = (V, E), partition the set V of vertices into two sets V1 and V2 such that |V1| and |V2| differ by at most 1. Let E1 be the set of edges that are incident only
Let T be a minimum spanning tree of a graph G = (V, E), and let V′be a subset of V. Let T′be the subgraph of T induced by V′, and let G′ be the subgraph of G induced by V′. Show that if T′ is connected, then T′ is a minimum spanning tree of G′.
Find a feasible solution or determine that no feasible solution exists for the following system of difference constraints: 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 VI
Find a feasible solution or determine that no feasible solution exists for the following system of difference constraints: 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
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
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.
Can any shortest-path weight from the new vertex ν0 in a constraint graph be positive? Explain.
Modify the Bellman-Ford algorithm so that it sets ν.d to -∞ for all vertices ν for which there is a negative-weight cycle on some path from the source to ν.
Give an efficient algorithm to count the total number of paths in a directed acyclic graph. Analyze your algorithm.
Let G = (V, E) be a directed graph with weight function w : E ⇾ R, and let n = |V|. We define the mean weight of a cycle c = 〈e1, e2, . . . , ek〉 of edges in E to beLet μ* = minc μ(c), where c ranges over all directed cycles in G. We call a cycle c for which μ (c) = μ* a minimum
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).
Let G = (V, E) be a weighted, directed graph with no negative-weight edges. Let s ∈ V be the source vertex, and suppose that we allow v.π to be the predecessor of ν on any shortest path to ν from source s if ν ∈ V – {s} is reachable from s, and NIL otherwise. Give an example of such a
Let G = (V, E) be a weighted, directed graph with weight function w : E → ℝ. Give an O(V E)-time algorithm to find, for each vertex ν ∈ V , the value δ∗(ν) = minu∈V {δ(u, ν)}.
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.
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
Suppose that a weighted, directed graph G = (V, E) has a negative-weight cycle. Give an efficient algorithm to list the vertices of one such cycle. Prove that your algorithm is correct.
Let G = (V, E) be a weighted, directed graph with positive weight function w : E → {1, 2, . . . ,W} for some positive integer W, and assume that no two vertices have the same shortest-path weights from source vertex s. Now suppose that we define an unweighted, directed graph G′ = (V ∪ V′,
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.
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.
Suppose that we are given a weighted, directed graph G = (V, E) in which edges that leave the source vertex s may have negative weights, all other edge weights are nonnegative, and there are no negative-weight cycles. Argue that Dijkstra's algorithm correctly finds shortest paths from s in this
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.
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.
What is the purpose of adding the new vertex s to V , yielding V′?
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.
Why do we require that wi i = 0 for all 1 ≤ i ≤ n?
Suppose that w(u, ν) ≥ 0 for all edges (u, ν) ∈ E. What is the relationship between the weight functions w and ŵ?
Show that matrix multiplication defined by EXTEND-SHORTEST-PATHS is associative.
Suppose that we modify the way in which equation (25.7) handles equality: Is this alternative definition of the predecessor matrix ? correct? d*-1) + d&-1) if d < (k-1) (k –1) –1) (k) Tij kj 7 (k–1) + d (k–1) if d-1) > d&-1) + akj 'ik
Suppose that we run Johnson’s algorithm on a directed graph G with weight function w. Show that if G contains a 0-weight cycle c, then ŵ(u, ν) = 0 for every edge (u, ν) in c.
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.
We can also compute the vertices on shortest paths as we compute the shortest-path weights. Define π(m)ij as the predecessor of vertex j on any minimum-weight path from i to j that contains at most m edges. Modify the EXTEND-SHORTEST-PATHS and SLOW-ALL-PAIRS-SHORTEST-PATHS procedures to compute
Give an O(VE)-time algorithm for computing the transitive closure of a directed graph G = (V, E).
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.
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 +
Modify FASTER-ALL-PAIRS-SHORTEST-PATHS so that it can determine whether the graph contains a negative-weight cycle.
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
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
Extend the flow properties and definitions to the multiple-source, multiple-sink problem. Show that any flow in a multiple-source, multiple-sink flow network corresponds to a flow of identical value in the single-source, single-sink network obtained by adding a supersource and a supersink, and vice
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).
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?
Show that if we always discharge a highest overflowing vertex, we can make the push-relabel method run in O(V3) time.
Suppose that at some point in the execution of a push-relabel algorithm, there exists an integer 0 < k ≤ |V| − 1 for which no vertex has ν.h = k. Show that all vertices with ν.h > k are on the source side of a minimum cut. If such a k exists, the gap heuristic updates every vertex ν
State the maximum-flow problem as a linear-programming problem.
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
Showing 700 - 800
of 1549
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Last
Step by Step Answers