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 sciences
algorithms
Questions and Answers of
Algorithms
Suppose that the maze may or may not have a solution. a. Describe a linear-time algorithm that determines the minimum number of walls that need to be knocked down to create a solution. b. Describe an
Write a program to compute word ladders where single-character substitutions have a cost of 1, and single-character additions or deletions have a cost of p > 0, specified by the user. As mentioned at
a. Find the shortest path from A to all other vertices for the graph in Figure 9.82.b. Find the shortest unweighted path from B to all other vertices for the graph in Figure 9.82.
The input is a list of league game scores (and there are no ties). If all teams have at least one win and a loss, we can generally prove, by a silly transitivity argument, that any team is better
The input is a collection of currencies and their exchange rates. Is there a sequence of exchanges that makes money instantly? For instance, if the currencies are X, Y, and Z and the exchange rate
A student needs to take a certain number of courses to graduate, and these courses have prerequisites that must be followed. Assume that all courses are offered every semester and that the student
The object of the Kevin Bacon Game is to link a movie actor to Kevin Bacon via shared movie roles. The minimum number of links is an actor's Bacon number. For instance, Tom Hanks has a Bacon number
The clique problem can be stated as follows: Given an undirected graph G = (V, E) and an integer K, does G contain a complete subgraph of at least K vertices? The vertex cover problem can be stated
Assume that the Hamiltonian cycle problem is NP-complete for undirected graphs. a. Prove that the Hamiltonian cycle problem is NP-complete for directed graphs. b. Prove that the unweighted simple
The baseball card collector problem is as follows: Given packets P1, P2, . . . , PM, each of which contains a subset of the year's baseball cards, and an integer K, is it possible to collect all the
What is the worst-case running time of Dijkstra's algorithm when implemented with d-heaps (Section 6.5)?
a. Give an example where Dijkstra's algorithm gives the wrong answer in the presence of a negative edge but no negative-cost cycle. b. Show that the weighted shortest-path algorithm suggested in
Show that the greedy algorithm to minimize the mean completion time for multiprocessor job scheduling works.
Explain how to implement first fit and best fit in O(N logN) time.
Show the operation of all the bin-packing strategies discussed in Section 10.1.3 on the input 0.42, 0.25, 0.27, 0.07, 0.72, 0.86, 0.09, 0.44, 0.50, 0.68, 0.73, 0.31, 0.78, 0.17, 0.79, 0.37, 0.73,
Prove Theorem 10.7.The solution to the equation T(N) = aT(N/b) + Θ(Nk logp N), where a ≥ 1, b > 1, and p ≥ 0 is
Prove Theorem 10.8. If Σki =1 αi < 1, then the solution to the equation T(N) = Σki =1 T(αi N) + O(N) is T(N) = O(N).
N points are placed in a unit square. Show that the distance between the closest pair is O(N−1/2).
Argue that for the closest-points algorithm, the average number of points in the strip is O( √N).
What is the asymptotic running time of quickselect, using a median-of-medianof- three partitioning strategy?
Show that quickselect with median-of-median-of-seven partitioning is linear. Why is median-of-median-of-seven partitioning not used in the proof?
Complete the analysis of the sampling algorithm described at the end of Section 10.2.3, and explain how the values of δ and s are chosen.
Show how the recursive multiplication algorithm computes XY, where X = 1234 and Y = 4321. Include all recursive computations.
Show how to multiply two complex numbers X = a + bi and Y = c + di using only three multiplications.
a. Show that XLYR + XRYL = (XL + XR) (YL + YR) − XLYL − XRYR b. This gives an O(N1.59) algorithm to multiply N-bit numbers. Compare this method to the solution in the text.
Why is it important that Strassen's algorithm does not use commutativity in the multiplication of 2 × 2 matrices?
Two 70×70 matrices can be multiplied using 143,640 multiplications. Show how this can be used to improve the bound given by Strassen's algorithm.
What is the optimal way to compute A1A2A3A4A5A6, where the dimensions of the matrices are A1: 10 × 20, A2: 20 × 1, A3: 1 × 40, A4: 40 × 5, A5: 5 × 30, A6: 30 × 15?
A file contains only colons, spaces, newlines, commas, and digits in the following frequency: colon (100), space (605), newline (100), comma (705), 0 (431), 1 (242), 2 (176), 3 (59), 4 (185), 5
Show that none of the following greedy algorithms for chained matrix multiplication work. At each stepa. Compute the cheapest multiplication.b. Compute the most expensive multiplication.c. Compute
Show the optimal binary search tree for the following words, where the frequency of occurrence is in parentheses: a (0.18), and (0.19), I (0.23), it (0.21), or (0.19).
Write a routine to reconstruct the shortest paths from the algorithm in Section 10.3.4.
Figure 10.75 shows a routine to flip a coin, assuming that random returns an integer (which is prevalent in many systems). What is the expected performance of the skip list algorithms if the random
Part of the encoded file must be a header indicating the Huffman code. Give a method for constructing the header of size at most O(N) (in addition to the symbols), where N is the number of symbols.
a. Use the exponentiation algorithm to prove that 2340 ≡ 1 (mod 341). b. Show how the randomized primality test works for N = 561 with several choices of A.
Two point sets are homometric if they yield the same distance set and are not rotations of each other. The following distance set gives two distinct point sets: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
Extend the reconstruction algorithm to find all homometric point sets given a distance set.
Show the result of α-β pruning of the tree in Figure 10.76.
The one-dimensional circle packing problem is as follows: You have N circles of radii r1, r2, . . . , rN. These circles are packed in a box such that each circle is tangent to the bottom of the box
Suppose that the edges in an undirected graph G satisfy the triangle inequality: cu,v + cv,w ≥ cu,w. Show how to compute a traveling salesman tour of cost at most twice optimal.
You are a tournament director and need to arrange a round robin tournament among N = 2k players. In this tournament, everyone plays exactly one game each day; after N − 1 days, a match has occurred
a. Prove that in a round robin tournament it is always possible to arrange the players in an order pi1 , pi2 , . . . , piN such that for all 1 ≤ j < N, pij has won the match against pij+1.b.
A convex polygon is a polygon with the property that any line segment whose endpoints are on the polygon lies entirely within the polygon. The convex hull problem consists of finding the smallest
Consider the problem of right-justifying a paragraph. The paragraph contains a sequence of words w1, w2, . . . , wN of length a1, a2, . . . , aN, which we wish to break into lines of length L. Words
The longest increasing subsequence problem is as follows: Given numbers a1, a2, . . . , aN, find the maximum value of k such that ai1 < ai2 < · · · < aik, and i1 < i2 < · · · < ik. As an
The longest common subsequence problem is as follows: Given two sequences A = a1, a2, . . . , aM, and B = b1, b2, . . . , bN, find the length, k, of the longest sequence C = c1, c2, . . . , ck such
One form of the knapsack problem is as follows: We are given a set of integers A = a1, a2, . . . , aN and an integer K. Is there a subset of A whose sum is exactly K? a. Give an algorithm that solves
You are given a currency system with coins of (decreasing) value c1, c2, . . . , cN cents. a. Give an algorithm that computes the minimum number of coins required to give K cents in change. b. Give
Consider the problem of placing eight queens on an (eight-by-eight) chess board. Two queens are said to attack each other if they are on the same row, column, or (not necessarily main) diagonal. a.
Show that if the symbols are sorted by frequency, Huffman's algorithm can be implemented in linear time.
In the game of chess, a knight in row R and column C may move to row 1 ≤ R' ≤ B and column 1 ≤ C' ≤ B (where B is the size of the board) provided that either |R - R'| = 2 and |C - C'| = 1 or
Consider the recursive algorithm in Figure 10.80 for finding the shortest weighted path in an acyclic graph, from s to t.a. Why does this algorithm not work for general graphs? b. Prove that this
Let A be an N-by-N matrix of zeros and ones. A submatrix S of A is any group of contiguous entries that forms a square. a. Design an O(N2) algorithm that determines the size of the largest submatrix
Othello played on a 6-by-6 board is a forced win for black. Prove this by writing a program. What is the final score if play on both sides is optimal?
When do M consecutive insertions into a binomial queue take less than 2M time units?
a. Show how to implement the merge operation on splay trees so that any sequence of N−1 merges starting from N single-element trees takes O(N log2 N) time. b. Improve the bound to O(N logN).
In Chapter 5, we described rehashing: When a table becomes more than half full, a new table twice as large is constructed, and the entire old table is rehashed. Give a formal amortized analysis, with
What is the maximum depth of a Fibonacci heap?
A deque with heap order is a data structure consisting of a list of items, on which the following operations are possible:push(x): Insert item x on the front end of the deque.pop(): Remove the front
Suppose that in an attempt to save time, we splay on every second tree operation. Does the amortized cost remain logarithmic?
Using the potential function in the proof of the splay tree bound, what is the maximum and minimum potential of a splay tree? By how much can the potential function decrease in one splay? By how much
As a result of a splay, most of the nodes on the access path are moved halfway towards the root, while a couple of nodes on the path move down one level. This suggests using the sum over all nodes of
Suppose a binomial queue of N = 2k − 1 elements is built. Alternately perform M insert and deleteMin pairs. Clearly, each operation takes O(logN) time. Why does this not contradict the amortized
Show that the amortized bound of O(logN) for the skew heap operations described in the text cannot be converted to a worst-case bound, by giving a sequence of operations that lead to a merge
Extend skew heaps to support the decreaseKey operation in O(logN) amortized time.
Show that the amortized time of a zig-zig splay is at most 3(Rf (X) − Ri(X)).
By changing the potential function, it is possible to prove different bounds for splaying. Let the weight function W(i) be some function assigned to each node in the tree, and let S(i) be the sum of
Show that if the items are sorted, then a treap can be constructed in linear time, even if the priorities are not sorted.
Abstractly, generalize the k-d heap so that only levels that branch on key #1 have two children (all others have one). a. Do we need links? b. Clearly, the basic algorithms still work; what are the
Show that using a stack instead of a queue in the previous exercise is bad, by giving a sequence that leads to Ω(N) cost per operation. This is the left-to-right single-pass merge.
Modify the splay tree to support queries for the kth smallest item.
Prove that the height of a red-black tree is at most 2 logN, and that this bound cannot be substantially lowered.
Show that every AVL tree can be colored as a red-black tree. Are all red-black trees AVL?
Draw a suffix tree and show the suffix array and LCP array for the following input strings: a. ABCABCABC b. MISSISSIPPI
Once the suffix array is constructed, the short routine shown in Figure 12.50 can be invoked from Figure 12.32 to create the longest common prefix array.a. In the code, what does rank[i] represent?b.
Showing 500 - 600
of 575
1
2
3
4
5
6