chapter_num
int64
1
6
question_num
int64
1
57
question
stringlengths
37
897
6
24
Burrows‑Wheeler transform. The Burrows‑Wheeler transform (BWT) is a transformation that is used in data compression algorithms, including bzip2 and in high‑throughput sequencing in genomics. Write a SuffixArray client that computes the BWT in linear time, as follows: Given a string of length \(N\) (terminated by a special end‑of‑file character $ that is smaller than any other character), consider the \(N \times N\) matrix in which each row contains a different cyclic rotation of the original text string. Sort the rows lexicographically. The Burrows‑Wheeler transform is the rightmost column in the sorted matrix. For example, the BWT of mississippi$ is ipssm$pissii. The Burrows‑Wheeler inverse transform (BWI) inverts the BWT. For example, the BWI of ipssm$pissii is mississippi$. Also write a client that, given the BWT of a text string, computes the BWI in linear time.
6
25
Circular string linearization. Write a SuffixArray client that, given a string, finds the cyclic rotation that is the smallest lexicographically in linear time. This problem arises in chemical databases for circular molecules, where each molecule is represented as a circular string, and a canonical representation (smallest cyclic rotation) is used to support search with any rotation as key. (See Exercise 6.27 and Exercise 6.28.)
6
26
Longest \(k\)-repeated substring. Write a SuffixArray client that, given a string and an integer \(k\), finds the longest substring that is repeated \(k\) or more times.
6
27
Long repeated substrings. Write a SuffixArray client that, given a string and an integer \(L\), finds all repeated substrings of length \(L\) or more.
6
28
\(k\)-gram frequency counts. Develop and implement an ADT for preprocessing a string to support efficiently answering queries of the form “How many times does a given \(k\)-gram appear?” Each query should take time proportional to \(k \log N\) in the worst case, where \(N\) is the length of the string.
6
29
If capacities are positive integers less than \(M\), what is the maximum possible flow value for any \(st\)-network with \(V\) vertices and \(E\) edges? Give two answers, depending on whether or not parallel edges are allowed.
6
30
Give an algorithm to solve the max‑flow problem for the case that the network forms a tree if the sink is removed.
6
31
True or false. If true provide a short proof, if false give a counterexample: a. In any max‑flow, there is no directed cycle on which every edge carries positive flow. b. There exists a max‑flow for which there is no directed cycle on which every edge carries positive flow. c. If all edge capacities are distinct, the max‑flow is unique. d. If all edge capacities are increased by an additive constant, the min cut remains unchanged. e. If all edge capacities are multiplied by a positive integer, the min cut remains unchanged.
6
32
Complete the proof of Proposition G: Show that each time an edge is a critical edge, the length of the augmenting path through it must increase by 2.
6
33
Find a large network online that you can use as a vehicle for testing flow algorithms on realistic data. Possibilities include transportation networks (road, rail, or air), communications networks (telephone or computer connections), or distribution networks. If capacities are not available, devise a reasonable model to add them. Write a program that uses the interface to implement flow networks from your data. If warranted, develop additional private methods to clean up the data.
6
34
Write a random‑network generator for sparse networks with integer capacities between 0 and 220. Use a separate class for capacities and develop two implementations: one that generates uniformly distributed capacities and another that generates capacities according to a Gaussian distribution. Implement client programs that generate random networks for both weight distributions with a well‑chosen set of values of \(V\) and \(E\) so that you can use them to run empirical tests.
6
35
Write a program that generates \(V\) random points in the plane, then builds a flow network with edges (in both directions) connecting all pairs of points within a given distance \(d\) of each other, setting each edge’s capacity using one of the random models described in the previous exercise.
6
36
Basic reductions. Develop Ford–Fulkerson clients for finding a max‑flow in each of the following types of flow networks: * Undirected * No constraint on the number of sources or sinks or on edges entering the source or leaving the sink * Lower bounds on capacities * Capacity constraints on vertices
6
37
Product distribution. Suppose that a flow represents products to be transferred by trucks between cities, with the flow on edge \(u\!-\!v\) representing the amount to be taken from city \(u\) to city \(v\) in a given day. Write a client that prints out daily orders for truckers, telling them how much and where to pick up and how much and where to drop off. Assume that there are no limits on the supply of truckers and that nothing leaves a given distribution point until everything is delivered.
6
38
Job placement. Develop a Ford–Fulkerson client that solves the job‑placement problem, using the reduction in Proposition J. Use a symbol table to convert symbolic names to integers for use in the flow network.
6
39
Construct a family of bipartite matching problems where the average length of the augmenting paths used by any augmenting‑path algorithm to solve the corresponding max‑flow problem is proportional to \(E\).
6
40
\(st\)-connectivity. Develop a Ford–Fulkerson client that, given an undirected graph \(G\) and vertices \(s\) and \(t\), finds the minimum number of edges in \(G\) whose removal will disconnect \(t\) from \(s\).
6
41
Disjoint paths. Develop a Ford–Fulkerson client that, given an undirected graph \(G\) and vertices \(s\) and \(t\), finds the maximum number of edge‑disjoint paths from \(s\) to \(t\).
6
42
Find a nontrivial factor of 37703491.
6
43
Prove that the shortest‑paths problem reduces to linear programming.
6
44
Could there be an algorithm that solves an NP‑complete problem in an average time of \(N \log N\), if \(P \neq NP\)? Explain your answer.
6
45
Suppose that someone discovers an algorithm that is guaranteed to solve the boolean satisfiability problem in time proportional to \(1.1^N\). Does this imply that we can solve other NP‑complete problems in time proportional to \(1.1^N\)?
6
46
What would be the significance of a program that could solve the integer linear programming problem in time proportional to \(1.1^N\)?
6
47
Give a poly‑time reduction from vertex cover to 0‑1 integer linear inequality satisfiability.
6
48
Prove that the problem of finding a Hamiltonian path in a directed graph is NP‑complete, using the NP‑completeness of the Hamiltonian‑path problem for undirected graphs.
6
49
Suppose that two problems are known to be NP‑complete. Does this imply that there is a poly‑time reduction from one to the other?
6
50
Suppose that \(X\) is NP‑complete, \(X\) poly‑time reduces to \(Y\), and \(Y\) poly‑time reduces to \(X\). Is \(Y\) necessarily NP‑complete? Answer: No, since \(Y\) may not be in NP.
6
51
Suppose that we have an algorithm to solve the decision version of boolean satisfiability, which indicates that there exists an assignment of truth values to the variables that satisfies the boolean expression. Show how to find the assignment.
6
52
Suppose that we have an algorithm to solve the decision version of the vertex‑cover problem, indicating that there exists a vertex cover of a given size. Show how to solve the optimization version of finding the vertex cover of minimum cardinality.
6
53
Explain why the optimization version of the vertex‑cover problem is not necessarily a search problem.
6
54
Suppose that \(X\) and \(Y\) are two search problems and \(X\) poly‑time reduces to \(Y\). Which of the following can we infer? a. If \(Y\) is NP‑complete then so is \(X\). b. If \(X\) is NP‑complete then so is \(Y\). c. If \(X\) is in \(P\), then \(Y\) is in \(P\). d. If \(Y\) is in \(P\), then \(X\) is in \(P\).
6
55
Suppose that \(P \neq NP\). Which of the following can we infer? e. If \(X\) is NP‑complete, then \(X\) cannot be solved in polynomial time. f. If \(X\) is in \(NP\), then \(X\) cannot be solved in polynomial time. g. If \(X\) is in \(NP\) but not NP‑complete, then \(X\) can be solved in polynomial time. h. If \(X\) is in \(P\), then \(X\) is not NP‑complete.