Question: Can I get help with the first two problems? Problem 1. (25%) You are given a string of n characters x[1...n), which you believe to

 Can I get help with the first two problems? Problem 1.
(25%) You are given a string of n characters x[1...n), which you
Can I get help with the first two problems?

Problem 1. (25%) You are given a string of n characters x[1...n), which you believe to be a corrupted text document in which all punctation has vanished so that it looks something like itwasthebestoftimes..."). You wish to reconstruct the document using a dictionary, which is available in the form of a Boolean function dict[.): for any given string w, dict(W) = true if wis a valid word, and dict(w) = false otherwise. (a) Given a dynamic programming algorithm that determines whether the string [. can be reconstructed as a sequence of valid words. The running time should be O(n), assuming calls a dict take a unit time. (b) In the event that the string is valid, make your algorithm output the corresponding sequence of words. Problem 2. (25%) This problem is about binomial heap: (a)Suppose a binomial heap H has a total of n nodes. Prove that H has at most log n) +1 binomial trees. (b) Prove that the union operation of two binomial heaps takes O(logn) steps. (c) The binomial heap H, which starts from empty is senerated by inserting the odd numbers from 11 to 40 sequentially, and the heap H, which starts from empty also, is generated by inserting the even numbers from 11 to 40 sequentially. (1) Show the structure of H, and H. (2) Show the structure of the union of Hand Hz. Problem 3. (50%) The knapsack problem is that given a set of positive integers (01...,an), and a knapsack of size 8, find a subset A of {Q1,...,} such that the sum of elements in A is the largest, but at most s. Part 1. Use the dynamic programming method to design an algorithm for the knapsack problem. Prove the correctness of your algorithm. Show the computational time of your algorithm carefully. Part 2. Use C++ to implement the function below int knapsack int 'a, //the input integers int n, //the number of input integers ints, //knapsack size int *subset, //subset elements int &size_of_subset //the number of items in the subset Test your program for the following knapsack problem: Input list: 5, 23, 27, 37, 48, 51, 63, 67, 71, 75, 79, 83, 89, 91, 101, 112, 121, 132, 137, 141, 143, 147, 153, 159, 171, 181, 190, 191 with knapsack size 762. Print out a subset with the sum of its elements so that the sum has the closest distance to 762. Also print out your source code Problem 1. (25%) You are given a string of n characters s/1...n), which you believe to be a corrupted text document in which all punctation has vanished so that it looks something like "twasthebestoftimes..."). You wish to reconstruct the document using a dictionary, which is available in the form of a Boolean function dict.): for any civen string w, dict() = true if wis a valid word, and dict() = false otherwise. (a) Given a dynamic programming algorithm that determines whether the string [. can be reconstructed as a sequence of valid words. The running time should be O(n). Assuming calls a dict take a unit time. (b) In the event that the string is valid, make your algorithm output the corresponding sequence of words. Problem 2. (25%) This problem is about binomial heap: (a)Suppose a binomial heap H has a total of n nodes. Prove that H has at most log n + 1 binomial trees. (b) Prove that the union operation of two binomial heaps takes O(logn) steps. c) The binomial heap H, which starts from empty, is generated by inserting the odd numbers from 11 to 40 sequentially, and the heap H, which starts from empty also, is generated by inserting the even numbers from 11 to 40 sequentially. (1)Show the structure of Hand H. (2) Show the structure of the union of H, and H. Problem 3. (50%) The knapsack problem is that given a set of positive integers {01. , an), and a knapsack of size , find a subset A of {@,,...) such that the sum of elements in A is the largest, but at most s. Part 1. Use the dynamic programming method to design an algorithm for the knapsack problem Prove the correctness of your algorithm. Show the computational time of your algorithm carefully. Part 2. Use C++ to implement the function below int knapsack( int "a, //the input integers int n, //the number of input integers int s, //knapsack size int "subsct, //subset elements int &size of subset //the number of items in the subset Test your program for the following knapsack problem: Input list: 5, 23, 27, 37, 48, 51, 63, 67, 71, 75, 79, 83, 89, 91, 101, 112, 121, 132, 137, 141, 143, 147, 153, 159, 171, 181, 190, 191 with knapsack size 762. Print out a subset with the sum of its elements so that the sum has the closest distance to 762. Also print out your source code. Problem 1. (25%) You are given a string of n characters x[1...n), which you believe to be a corrupted text document in which all punctation has vanished so that it looks something like itwasthebestoftimes..."). You wish to reconstruct the document using a dictionary, which is available in the form of a Boolean function dict[.): for any given string w, dict(W) = true if wis a valid word, and dict(w) = false otherwise. (a) Given a dynamic programming algorithm that determines whether the string [. can be reconstructed as a sequence of valid words. The running time should be O(n), assuming calls a dict take a unit time. (b) In the event that the string is valid, make your algorithm output the corresponding sequence of words. Problem 2. (25%) This problem is about binomial heap: (a)Suppose a binomial heap H has a total of n nodes. Prove that H has at most log n) +1 binomial trees. (b) Prove that the union operation of two binomial heaps takes O(logn) steps. (c) The binomial heap H, which starts from empty is senerated by inserting the odd numbers from 11 to 40 sequentially, and the heap H, which starts from empty also, is generated by inserting the even numbers from 11 to 40 sequentially. (1) Show the structure of H, and H. (2) Show the structure of the union of Hand Hz. Problem 3. (50%) The knapsack problem is that given a set of positive integers (01...,an), and a knapsack of size 8, find a subset A of {Q1,...,} such that the sum of elements in A is the largest, but at most s. Part 1. Use the dynamic programming method to design an algorithm for the knapsack problem. Prove the correctness of your algorithm. Show the computational time of your algorithm carefully. Part 2. Use C++ to implement the function below int knapsack int 'a, //the input integers int n, //the number of input integers ints, //knapsack size int *subset, //subset elements int &size_of_subset //the number of items in the subset Test your program for the following knapsack problem: Input list: 5, 23, 27, 37, 48, 51, 63, 67, 71, 75, 79, 83, 89, 91, 101, 112, 121, 132, 137, 141, 143, 147, 153, 159, 171, 181, 190, 191 with knapsack size 762. Print out a subset with the sum of its elements so that the sum has the closest distance to 762. Also print out your source code Problem 1. (25%) You are given a string of n characters s/1...n), which you believe to be a corrupted text document in which all punctation has vanished so that it looks something like "twasthebestoftimes..."). You wish to reconstruct the document using a dictionary, which is available in the form of a Boolean function dict.): for any civen string w, dict() = true if wis a valid word, and dict() = false otherwise. (a) Given a dynamic programming algorithm that determines whether the string [. can be reconstructed as a sequence of valid words. The running time should be O(n). Assuming calls a dict take a unit time. (b) In the event that the string is valid, make your algorithm output the corresponding sequence of words. Problem 2. (25%) This problem is about binomial heap: (a)Suppose a binomial heap H has a total of n nodes. Prove that H has at most log n + 1 binomial trees. (b) Prove that the union operation of two binomial heaps takes O(logn) steps. c) The binomial heap H, which starts from empty, is generated by inserting the odd numbers from 11 to 40 sequentially, and the heap H, which starts from empty also, is generated by inserting the even numbers from 11 to 40 sequentially. (1)Show the structure of Hand H. (2) Show the structure of the union of H, and H. Problem 3. (50%) The knapsack problem is that given a set of positive integers {01. , an), and a knapsack of size , find a subset A of {@,,...) such that the sum of elements in A is the largest, but at most s. Part 1. Use the dynamic programming method to design an algorithm for the knapsack problem Prove the correctness of your algorithm. Show the computational time of your algorithm carefully. Part 2. Use C++ to implement the function below int knapsack( int "a, //the input integers int n, //the number of input integers int s, //knapsack size int "subsct, //subset elements int &size of subset //the number of items in the subset Test your program for the following knapsack problem: Input list: 5, 23, 27, 37, 48, 51, 63, 67, 71, 75, 79, 83, 89, 91, 101, 112, 121, 132, 137, 141, 143, 147, 153, 159, 171, 181, 190, 191 with knapsack size 762. Print out a subset with the sum of its elements so that the sum has the closest distance to 762. Also print out your source code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!