In the art gallery guarding problem we are given a line L that represents a long hallway in an art gallery. We are also given a set X = {x0,x1,…,xn−1} of real numbers that specify the...
Recent Questions
1. Let three integer arrays, A, B, and C, be given, each of size n. Given an arbitrary integer k, design an O(n2 logn)-time algorithm to determine if there exist numbers, a in A, b in B, and c in C,...
1. Describe an efficient greedy algorithm for making change for a specified value using a minimum number of coins, assuming there are four denominations of coins (called quarters, dimes, nickels,...
1. Create a class that implements a standard trie for a set of strings. The class should have a constructor that takes a list of strings as an argument, and the class should have a method that tests...
1. Give an efficient algorithm for deleting a string from a compressed trie and analyze its running time.2. Describe an algorithm for constructing the compact representation of a suffix trie, given...
1. Describe an efficient algorithm to find the longest palindrome that is a suffix of a string T of length n. Recall that a palindrome is a string that is equal to its reversal. What is the running...
1. Modify the simplified Boyer-Moore algorithm presented in this chapter using ideas from the KMP algorithm so that it runs in O(n+m) time.2. Let T be a text string of length n. Describe an...
The Knuth-Morris-Pratt pattern-matching algorithm can be modified to run faster on binary strings by redefining the failure function as:where j denotes the complement of the jth bit of P. Describe...
Say that a pattern P of length m is a circular substring of a text T of length n > m if P is a (normal) substring of T, or if P is equal to the concatenation of a suffix of T and a prefix of T, that...
1. Give a justification of why the computeFailKMP method (Code Fragment 13.4) runs in O(m) time on a pattern of length m.2. Let T be a text of length n, and let P be a pattern of length m. Describe...
Redo the previous problem, adapting the Boyer-Moore pattern-matching algorithm to implement a method findLastBoyerMoore(T,P).Exercises C-13.16Adapt the brute-force pattern-matching algorithm so as...
1. Create a class that implements a prefix trie for a string. The class should have a constructor that takes a string as an argument, and a method for pattern matching on the string.2. Given a...
1. Describe an example of a text T of length n and a pattern P of length m such that the brute-force pattern-matching algorithm achieves a running time that is Ω(nm).2. Adapt the brute-force...
1. What is the best way to multiply a chain of matrices with dimensions that are 10×5, 5×2, 2×20, 20×12, 12×4, and 4×60? Show your work.2. In Figure 13.14, we illustrate that GTTTAA is a longest...
1. Draw a compressed trie for the strings given in the previous problem.2. Draw the compact representation of the suffix trie for the string:3. Draw the frequency array and Huffman tree for the...
1. Compute a table representing the Knuth-Morris-Pratt failure function for the pattern string “cgtacgttcgtac”.2. Draw a standard trie for the following set of strings:
Compute a map representing the last function used in the Boyer-Moore patternmatching algorithm for characters in the pattern string:
Repeat Exercise R-13.3 for the Knuth-Morris-Pratt algorithm, not counting the comparisons made to compute the failure function.Exercises R-13.3Draw a figure illustrating the comparisons done by...
Repeat the previous problem for the Boyer-Moore algorithm, not counting the comparisons made to compute the last(c) function.Exercises R-13.3Draw a figure illustrating the comparisons done by...
1. List the prefixes of the string P =”aaabbaaa” that are also suffixes of P.2. What is the longest (proper) prefix of the string “cgtacgttcgtacg” that is also a suffix of...
1. Implement an animation of one of the sorting algorithms described in this chapter, illustrating key properties of the algorithm in an intuitive manner.2. Design and implement two versions of the...
Show the longest common subsequence array L for the two strings:What is a longest common subsequence between these strings?
1. Implement an in-place version of insertion-sort and an in-place version of quicksort. Perform benchmarking tests to determine the range of values of n where quick-sort is on average better than...
1. Implement a nonrecursive, in-place version of the quick-sort algorithm, as described at the end of Section 12.2.2.2. Experimentally compare the performance of in-place quick-sort and a version of...
As a generalization of the previous problem, revisit Exercise C-11.45, which involves performing general selection queries on a dynamic set of values.Exercise C-11.45Describe a modification to the...
Suppose we are interested in dynamically maintaining a set S of integers, which is initially empty, while supporting the following two operations:We will store each element of the set in one of two...
We can make the quick-select algorithm deterministic, by choosing the pivot of an n-element sequence as follows:Show that this deterministic quick-select algorithm runs in O(n) time by answering the...
Show that randomized quick-sort runs in O(nlogn) time with probability at least 1−1/n, that is, with high probability, by answering the following:
Space aliens have given us a method, alienSplit, that can take a sequence S of n integers and partition S in O(n) time into sequences S1,S2,…,Sk of size at most ⌈n/k⌉ each, such that the...
1. Show how to use a deterministic O(n)-time selection algorithm to sort a sequence of n elements in O(nlogn)-worst-case time.2. Given an unsorted sequence S of n comparable elements, and an integer...
1. Our quick-select implementation can be made more space-efficient by initially computing only the counts for sets L, E, and G, and creating only the new subset that will be needed for recursion....
1. Perform a series of benchmarking tests on a version of merge-sort and quick-sort to determine which one is faster. Your tests should include sequences that are “random” as well as “almost”...
1. Given a set of n integers, describe and analyze a fast method for finding the ⌈logn⌉ integers closest to the median.2. Bob has a set A of n nuts and a set B of n bolts, such that each nut in A...
Galante Kennel uses tenant-days as its measure of activity; ananimal housed in the kennel for one day is counted as onetenant-day. During May, Kennel budgeted for 3,900 tenant-days, butits actual...
Imagine yourself undertaking the risk of investing in bonds as debt obligations. Please detail, describe, and comment on the three major sources of bond investing risk? What role do rating services...
A friend wants to work for 2 years then return to school fulltime for a masterAc€?cs degree. OPTION A: He can invest $1,000/month ina mutual fund that earns 6% annually, for 2 years. But he...
The research paper draft represents a substantially completed paper, and should include the abstract, table contents, preliminary reference list, and the majority of the body, text, and content of...
A friend says that she expects to earn 13.00% on her protfoliowith a beta of 2.25. You have a two-asset portfolio including stockx and a risk-free security. The expecgted return of stock x is10.00%...
A friend says that she expects to earn 13.00% on her portfoliowith a beta of 1.50. You have two-asset portfolio including stock Xand a risk-free security. The expected return on stock X is 11.00%and...
Fresh Fruit, INC. has a $1000 par value bond that is currentlyselling for $911. It has an annual coupon rate of 11.70 %, paidsemiannually, and has 28-years remaining until maturity. What wouldthe...
Recent Comments