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
Ask a Question
Search
Search
Sign In
Register
study help
computer science
introduction to algorithms
Questions and Answers of
Introduction to Algorithms
For each function f (n) and time t in the following table, determine the largest size n of a problem that can be solved in time t, assuming that the algorithm to solve the problem takes f (n)
Give an example of an application that requires algorithmic content at the application level, and discuss the function of the algorithms involved.
Give a real-world example that requires sorting or a real-world example that requires computing a convex hull.
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
Suppose that we are given a directed acyclic graph G = (V, E) with real-valued edge weights and two distinguished vertices s and t. Describe a dynamic-programming approach for finding a longest
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.
Suppose that we wish to add the operation PRINT-SET(x), which is given a node x and prints all the members of x’s set, in any order. Show how we can add just a single attribute to each node in a
There are two types of professional wrestlers: "babyfaces" ("good guys") and "heels" ("bad guys"). Between any pair of professional wrestlers, there may or may not be a rivalry. Suppose we have n
Show that edge (u, ν) isa. a tree edge or forward edge if and only if u.d < ν.d < ν.f < u.f,b. a back edge if and only
Professor Newman thinks that he has worked out a simpler proof of correctness for Dijkstra’s algorithm. He claims that Dijkstra’s algorithm relaxes the edges of every shortest path in the graph
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
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.
Let f be a flow in a network, and let α be a real number. The scalar flow product, denoted αf, is a function
Suppose that a flow network G = (V, E) violates the assumption that the network contains a path s ⤳ ν ⤳ t for all vertices ν ∈ V. Let u be a vertex for which there is no path s ⤳ u ⤳ t.
Prove that, after the procedure INITIALIZE-PREFLOW (G, s) terminates, we have s.e ≤ − |f*|, where f* is a maximum flow for G.
Show that splitting an edge in a flow network yields an equivalent network. More formally, suppose that flow network G contains edge (u, ν), and we create a new flow network
Prove that the summations in equation (26.6) equal the summations in equation (26.7).(26.6)(26.7) |f ↑ f'l Συ6,) + fG, ν) - f' (ν, s)) - Σf(v, s) + f'0, s) - f'6, v)) Ξ νeV νEV Σ16)
How can we use the output of the Floyd-Warshall algorithm to detect the presence of a negative-weight cycle?
What does the matrix used in the shortest-paths algorithms correspond to in regular matrix multiplication? 888 8 8 • 88
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
Let G = (V, E) be a weighted, directed graph that contains no negative-weight cycles. Let s ∈ V be the source vertex, and let G be initialized by INITIALIZE-SINGLE-SOURCE (G, s). Prove that there
A sequence is bitonic if it monotonically increases and then monotonically decreases, or if by a circular shift it monotonically increases and then monotonically decreases. For example the sequences
Professor Gaedel has written a program that he claims implements Dijkstra’s algorithm. The program produces ν.d and ν.π for each vertex ν ∈ V. Give an O(V + E)-time algorithm to check the
A scaling algorithm solves a problem by initially considering only the highest-order bit of each relevant input value (such as an edge weight). It then refines the initial solution by looking at the
Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 U.S. dollar buys 49
A d-dimensional box with dimensions (x1, x2, . . . ,xd) nests within another box with dimensions (y1, y2, . . . ,yd) if there exists a permutation π on {1, 2, . . . ,d} such that xπ(1) < y1,
Let (u, ν) be a minimum-weight edge in a connected graph G. Show that (u, ν) belongs to some minimum spanning tree of G.
Show that we can use a depth-first search of an undirected graph G to identify the connected components of G, and that the depth-first forest contains as many trees as G has connected components.
Give a counterexample to the conjecture that if a directed graph G contains a path from u to ν, then any depth-first search must result in ν.d ≤ u.f.
Give a counterexample to the conjecture that if a directed graph G contains a path from u to ν, and if u.d < ν.d in a depth-first search of G, then ν is a descendant of u in the depth-first
The incidence matrix of a directed graph G = (V, E) with no self-loops is a |V| Ã |E| matrix B = (bij) such
Most graph algorithms that take an adjacency-matrix representation as input require time Ω(V2), but there are some exceptions. Show how to determine whether a directed graph G contains a
Give an example of a directed graph G = (V, E), a source vertex s ∈ V, and a set of tree edges Eπ ⊆ E such that for each
Argue that in a breadth-first search, the value u.d assigned to a vertex u is independent of the order in which the vertices appear in each adjacency list. Using Figure 22.3 as an example, show that
Show that using a single bit to store each vertex color suffices by arguing that the DFS procedure would produce the same result if line 3 of DFS-VISIT was removed.
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.
A depth-first forest classifies the edges of a graph into tree, back, forward, and cross edges. A breadth-first tree can also be used to classify the edges reachable from the source of the search
Consider the function α′(n) = min {k : Ak(1) ≥ lg(n + 1)}. Show that α′(n) ≤ 3 for all practical values of n and, using Exercise 21.4-2,
Suggest a simple change to the UNION procedure for the linked-list representation that removes the need to keep the tail pointer to the last object in each list. Whether or not the weighted-union
Professor Dante reasons that because node ranks increase strictly along a simple path to the root, node levels must monotonically increase along the path. In other words, if x.rank > 0 and x.p is
Show that any sequence of m MAKE-SET, FIND-SET, and LINK operations, where all the LINK operations appear before any of the FIND-SET operations, takes only O(m) time if we use both path compression
Professor Gompers suspects that it might be possible to keep just one pointer in each set object, rather than two (head and tail), while keeping the number of pointers in each list element at two.
Using Exercise 21.4-2, give a simple proof that operations on a disjoint-set forest with union by rank but without path compression run in O(m lg n) time.Exercise 21.4-2Prove that every node has rank
Adapt the aggregate proof of Theorem 21.1 to obtain amortized time bounds of O(1) for MAKE-SET and FIND-SET and O(lg n) for UNION using the linked-list representation and the weighted-union heuristic.
In the depth-determination problem, we maintain a forest F = {Ti} of rooted trees under three operations:MAKE-TREE (ν) creates a tree whose only node
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
Suppose we perform a sequence of n operations on a data structure in which the i th operation costs i if i is an exact power of 2, and 1 otherwise. Use aggregate analysis to determine the amortized
Redo Exercise 17.1-3 using an accounting method of analysis.17.1-3Suppose we perform a sequence of n operations on a data structure in which the i th operation costs i if i is an exact power of 2,
Modern computers use a cache to store a small amount of data in a fast memory. Even though a program may access large amounts of data, by storing a small subset of the main memory in the cache-a
Consider a modification to the activity-selection problem in which each activity ai has, in addition to a start and finish time, a value νi. The objective is no longer to maximize the number of
Professor Gekko has always dreamed of inline skating across North Dakota. He plans to cross the state on highway U.S. 2, which runs from Grand Forks, on the eastern border with Minnesota, to
Show that if (S, I) is a matroid, then (S, I′) is a matroid, where I′ = {A′ . S − A′ contains some maximal A ∈ I} .That is, the maximal independent sets of (S, I′) are just the
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.
Explain why, in the proof of Lemma 16.2, if x.freq = b.freq, then we must have a.freq = b.freq = x.freq = y.freq.
Give a dynamic-programming algorithm for the activity-selection problem, based on recurrence (16.2). Have your algorithm compute the sizes c[I, j] as defined above and also produce the
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
The Rinky Dink Company makes machines that resurface ice rinks. The demand for such products varies from month to month, and so the company needs to develop a strategy to plan its manufacturing given
A certain string-processing language allows a programmer to break a string into two pieces. Because this operation copies the string, it costs n time units to break a string of n characters into two
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
Imagine that you wish to exchange one currency for another. You realize that instead of directly exchanging one currency for another, you might be better off making a series of trades through other
Suppose that in the rod-cutting problem of Section 15.1, we also had limit li on the number of pieces of length i that we are allowed to produce, for i = 1, 2, . . . ,n. Show that the
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?
In the euclidean traveling-salesman problem, we are given a set of n points in the plane, and we wish to find the shortest closed tour that connects all n points. Figure 15.11(a) shows the solution
Consider a modification of the rod-cutting problem in which, in addition to a price pi for each rod, each cut incurs a fixed cost of c. The revenue associated with a solution is now the sum of
A palindrome is a nonempty string over some alphabet that reads the same forward and backward. Examples of palindromes are all strings of length 1, civic, racecar, and aibohphobia (fear of
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
Show that equation (15.4) follows from equation (15.3) and the initial condition T(0) = 1.(15.4) (1
VLSI databases commonly represent an integrated circuit as a list of rectangles. Assume that each rectangle is rectilinearly oriented (sides parallel to the x- and y-axes), so that we represent a
Observe that whenever we reference the size attribute of a node in either OSSELECT or OS-RANK, we use it only to compute a rank. Accordingly, suppose we store in each node its rank in the subtree of
We define the Josephus problem as follows. Suppose that n people form a circle and that we are given a positive integer m ≤ n. Beginning with a designated first person, we proceed around the
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,
Suppose that a node x is inserted into a red-black tree with RB-INSERT and then is immediately deleted with RB-DELETE. Is the resulting red-black tree the same as the initial red-black tree? Justify
Professors Skelton and Baron are concerned that at the start of case 1 of RB-DELETE-FIXUP, the node x.p might not be black. If the professors are correct, then lines 5-6 are wrong. Show that x.p must
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
During the course of an algorithm, we sometimes find that we need to maintain past versions of a dynamic set as it is updated. We call such a set persistent. One way to implement a persistent set is
An alternative method of performing an in order tree walk of an n-node binary search tree finds the minimum element in the tree by calling TREE-MINIMUM and then making n - 1 calls to TREE-SUCCESSOR.
Show that the function ƒ(x) = 2x is convex.
In this problem, we prove that the average depth of a node in a randomly built binary search tree with n nodes is O(lg n). Although this result is weaker than that of Theorem 12.4, the technique we
Describe a binary search tree on n nodes such that the average depth of a node in the tree is Θ(lg n) but the height of the tree is ω(lg n). Give an asymptotic upper bound on the height of an
Suppose we have stored n keys in a hash table of size m, with collisions resolved by chaining, and that we know the length of each chain, including the length L of the longest chain. Describe a
a. Assuming uniform hashing, show that for i = 1,2, . . . ,n, the probability is at most 2-k that the i th insertion requires strictly more than k probes.b. Show that
Professor Olay is consulting for an oil company, which is planning a large pipeline running east to west through an oil field of n wells. The company wants to connectFigure 9.2 Professor Olay
In this problem, we use indicator random variables to analyze the RANDOMIZED SELECT procedure in a manner akin to our analysis of RANDOMIZED-QUICKSORT in Section 7.4.2.As in the quicksort analysis,
Show how quicksort can be made to run in O(n lg n) time in the worst case, assuming that all elements are distinct.
A compare-exchange operation on two array elements A[i] and A[j], where i < j, has the form COMPARE-EXCHANGE (A, i, j)1 If A[i] > A[j]2 exchange A[i]
Show how to sort n integers in the range 0 to n3 - 1 in O(n) time.
Suppose that we were to rewrite the for loop header in line 10 of the COUNTING SORT as10 for j = 1 to A.lengthShow that the algorithm still works properly. Is the modified algorithm stable?
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)?
In this problem, we prove a probabilistic Ω(n lg n) lower bound on the running time of any deterministic or randomized comparison sort on n distinct input elements. We begin by examining a
The analysis of the expected running time of randomized quicksort in Section 7.4.2 assumes that all element values are distinct. In this problem, we examine what happens when they are
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
Show that there are at most ⌈n=2h+1⌉ nodes of height h in any n-element heap.
A d-ary heap is like a binary heap, but (with one possible exception) non-leaf nodes have d children instead of 2 children.a. How would you represent a d-ary heap in an array?b. What
We can build a heap by repeatedly calling MAX-HEAP-INSERT to insert the elements into the heap. Consider the following variation on the BUILD-MAX-HEAP
Suppose we want to create a random sample of the set {1, 2, 3, . . . , n}, that is, an m-element subset S, where 0 ≤ m ≤ n, such that
Suppose that n balls are tossed into n bins, where each toss is independent and the ball is equally likely to end up in any bin. What is the expected number of empty bins? What is the expected number
Professor Armstrong suggests the following procedure for generating a uniform random permutation:PERMUTE-BY-CYCLIC (A)1. n = A.length2. let B[1. . n] be a new array3. offset = RANDOM (1, n)4. for i =
Suppose that you are given a flow network G, and G has edges entering the source s. Let f be a flow in G in which one of the edges (ν, s) entering the source has f (ν, s) = 1. Prove that there must
Consider the following multithreaded algorithm for performing pairwise addition on n-element arrays A[1 . . n] and B[1. . n], storing the sums in C[1. . n].SUM-ARRAYS (A, B, C)a. Rewrite
Suppose that we spawn P-FIB(n – 2) in line 4 of P-FIB, rather than calling it as is done in the code. What is the impact on the asymptotic work, span, and parallelism?
Showing 1100 - 1200
of 1549
First
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16