Design a dynamic programming algorithm to find the value

Assignment Help Data Structure & Algorithms
Reference no: EM13326591

1. Implement the Boyer-Moore algorithm using any programming language you prefer. Your program should ask the user to enter a text and a pattern, then output the following: (a) bad-symbol table (b) good suffix table (c) the searching result (whether the pattern is in the text or not) Please make sure that the good suffix table is generated correctly. Use the following examples to test your program before submitting your assignment.

Examples:

Good suffix table for the pattern BAOBAB
k = 1 d2 = 2; k = 2, d2 = 5; k = 3 d2 = 5; k = 4 d2 = 5; k = 5 d2 = 5
Good suffix table for the pattern AACCAC
k = 1 d2 = 2; k = 2, d2 = 3; k = 3 d2 = 6; k = 4 d2 = 6; k = 5 d2 = 6
Good suffix table for the pattern AACCAA
k = 1 d2 = 1; k = 2, d2 = 4; k = 3 d2 = 4; k = 4 d2 = 4; k = 5 d2 = 4
Good suffix table for the pattern 10000
k = 1 d2 = 3; k = 2, d2 = 2; k = 3 d2 = 1; k = 4 d2 = 5
Good suffix table for the pattern 01010
k = 1 d2 = 4; k = 2, d2 = 4; k = 3 d2 = 2; k = 4 d2 = 2


2. Design a greedy algorithm to solve the activity selection problem. Suppose there are a set of activities: a1, a2, ... an that wish to use a lecture hall. Each activity ai has a start time siand a finish time fi. A lecture hall can be used by only one activity at a time. Two activities can be scheduled in the same lecture hall if they are non-conflicting (fi<= sj or fj<= si) Your algorithm should find out the minimum number of lecture halls needed to hold all the activities. Write a program to implement your algorithm. For example: if the activities you need to schedule have the following start times and finish times,


4 7
6 9
7 8
1 3
1 4
2 5
3 7

then the output of your program is "the minimum number of lecture halls required is 3". Also indicate which activity will be scheduled in which lecture hall.

3. Write a program to solve the Longest Common Subsequence problem using dynamic programming as discussed in class. For example, if the input is X = ABCBDAB and Y = BDCABA, then the output of your program should be BCBA.

4.  Suppose you need to create a work plan, and each week you have to choose a job to undertake. The set of possible jobs is divided into low-stress and high-stress jobs.

If you select a low-stress job in week i, then you get a revenue of li dollars; if you select a high-stress job, you get a revenue of hi dollars. The catch, however, is that in order for you to take on a high-stress job in week i, it's required that you rest in weeki - 1 because you need a full week of prep time to get ready for the stress level (It's okay to choose a high-stress job in week 1.) On the other hand, you can take a low-stress job in weeki even if you have done a job (of either type) in week i-1.

So, given a sequence of n weeks, a plan is speci?ed by a choice of "low-stress", "high-stress" or "none" for each of the n weeks, with the constraint that if "high-stress" is chosen for week i> 1, then "none" must be chosen for week i - 1. The value of the plan is determined in the natural way; for each i, you add li to the value if you choose "low-stress" in week i, and you add hi to the value if you choose "high-stress" in week i. (You add 0 if you choose "none" in week i.)

Example: Suppose n=4, and the values of li and hiare given by the following table. Then the plan of the maximum value would be to choose "none" in week 1, a high stress job in week 2, and low-stress jobs in weeks 3 and 4. The value of this plan would be 0+50+10+10=70.
i Week 1 Week 2 Week 3 Week 4

l 10 1 10 10
h 5 50 5 1

Design a dynamic programming algorithm to find the value of the optimal plan. Implement your algorithm using any programming language you prefer. Describe the recurrence relation used by your algorithm at the top of your program or in a separate file.

Reference no: EM13326591

Questions Cloud

Evaluate account balances : Shiras Distributing Company had the following account balances - the company completed the following summary transactions.
What is its maximum height above the ground : A gray kangaroo can bound across level ground with each jump carrying it 8.1m from the takeoff point. What is its maximum height above the ground
Implement the boyer-moore algorithm using any program : Implement the Boyer-Moore algorithm using any programming language you prefer.
What is the temperature of the aluminum disk : A thick, vertical iron pipe has an inner diameter of 0.077 m. A thin aluminum (? = 23x10-6 (C°)-1) disk, What is the temperature of the aluminum disk when the disk falls into the pipe
Design a dynamic programming algorithm to find the value : Design a dynamic programming algorithm to find the value of the optimal plan. Implement your algorithm using any programming language you prefer. Describe the recurrence relation used by your algorithm at the top of your program or in a separate f..
Find the magnitude and direction of the net force : If the central charge shown below is displaced 0.350 nm to the right while the other charges are held in place, find the magnitude and direction of the net force
Which the business must comply in making a decision : For the business below discuss the entity that represents the best choice for each business, taking control, taxation, and liability issues into consideration. Identify laws and regulations each business must consider in starting the business, and id..
What is its frequency of vibration : A vibration sensor, used in testing a washing machine, consists of a cube of aluminum 1.50 cm on edge mounted on one end of a strip of spring steel (like a hacksaw blade) that lies in a vertical plane. what is its frequency of vibration
What is the maximum emf generated in it : A coil of area 0.100 m2 is rotating at 70.0 rev/s with the axis of rotation perpendicular to a 0.200 T magnetic field. If the coil has 700 turns, what is the maximum emf generated in it

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Working with physicists that hav an inert lattice structure

working with Physicists that hav an inert lattice structure, and they use this for placing charged particles at regual spacing along a straight line

  Creating decision tree

Premium Airlines has currently offered to settle claims for a class action suit, which was originated for alleged price fixing of tickets. The settlement is stated as follows. Create a decision tree for this condition.

  What is meant by application service provider

What is meant by Application Service Provider? What factors drive their emergence? How does Jamcracker fit in ASP space? Describe the Jamcracker business model.

  What is the worst case of avl tree?

the binary tree can look like a linked list in the worst case. What is the worst case of AVL tree? To get an idea, do the following: What is the minimum # of nodes in each of the AVL trees with heights 2, 3, 4, and 5?Explain please.

  Creating algorithm to implement function

Create an Algorithm to implement the given function and explain how the required task can be achieved in a step by step process.

  Hierarchy chart and design the logic

Draw the hierarchy chart and design the logic for a program that calculates the projected cost of an automobile trip. Assume that the user's car travels 20 miles per gallon of gas. Design a program that prompts the user for a number of miles drive..

  Creating a database with asp.net

Make a database with a table called "MyUsers" and "MyRole" The table should have the following columns.

  Discussion on data mining techniques

The tax authorities working for many governments are often confronted with challenge of detecting tax evasion and fraud. Suppose you work at income tax department.

  Calculate the cost of sorting relation in seconds

Assume a flash storage device is used instead of disk, and it has seek time of 1 microsecond and transfer rate of 40 MB per second. Recompute the cost of sorting the relation in seconds.

  Solving information technology question

XYZ Corporation has a small office with eighty users in California. The office employs a file and print server that caters to user requests.

  Conduct time complexity analysis of the algorithm

Conduct time complexity analysis of the algorithm and hand test your algorithm using your allocated 10-element long list of alphabetic characters as an illustrative/working example

  Devise algorithm to generate access control matrix

Devise an algorithm that generates an access control matrix A for any given history matrix H of the Chinese Wall model. A significant portion of the grade for this problem involves your justification of your algorithm.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd