Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can I get help with this? Problem 1. (25%) You are given a string of n characters [1...n), which you believe to be a corrupted

can I get help with this? image text in transcribed
Problem 1. (25%) You are given a string of n characters [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 sl. can be reconstructed as a sequence of valid words. The running time should be O(n), assuming calls a dict take a unit time. (6) 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 from 11 to 40 sequentially. (1)Show the structure of H and 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 s, 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases 11th British National Conference On Databases Bncod 11 Keele Uk July 7 9 1993 Proceedings Lncs 696

Authors: Michael F. Worboys ,Anna F. Grundy

1993rd Edition

3540569219, 978-3540569213

More Books

Students also viewed these Databases questions

Question

Who was the first woman prime minister of india?

Answered: 1 week ago

Question

Explain the concept of going concern value in detail.

Answered: 1 week ago

Question

Define marketing.

Answered: 1 week ago

Question

What are the traditional marketing concepts? Explain.

Answered: 1 week ago