Question: 2. Speaking about the brute-force string-matching algorithm, how many comparisons (both successful and unsuccessful) are made in searching for cach of the following patters in
2. Speaking about the brute-force string-matching algorithm, how many comparisons (both successful and unsuccessful) are made in searching for cach of the following patters in the binary text of 1000 ones? a. 00001 b, 10000 c. 01010 3. The partition problem is also a classic problem: given n positive integers, partition them into two disjoint subsets with the same sum of their elements. (Of course, the problem does not always have a solution.) Design an exhaustive search algorithm for this problem and discuss its time efficiency. Try to minimize the number of subsets the algorithm needs to generate. 4. Perform graph traversal by DFS and BFS, respectively, for the following graph. Start from vertex a and resolve ties by vertex alphabetical order. a. Construct the corresponding search tree. b. Give the order in which vertices were visited for the first time. Chapter 4 - 1. Illustrate steps of sorting the list: P, R, O, G, R, A, M a. by selection sort b. by insertion sort 2. Solve the topological sorting problem for the graph above (Chapter 3 No. 4): a. Using the DFS-based algorithm b. Using the source-removal algorithm 3. Write pseudocode for a recursive algorithm for generating all 2" bit strings of length n. Discuss its time efficiency. 4. Pages 156-157: #10 5. Apply quickselect to find the median of the list of numbers: 12,8, 17, 9, 36, 21, 31. Illustrate each algorithm step by listing element and index changes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
