Devise a dp algorithm which determines the minimal number

Assignment Help Computer Engineering
Reference no: EM133285085

a). Given a list of stock ticker prices p1, p2, . . . , pn, devise an O(n 2 ) algorithm that finds the longest (not necessarily consecutive) streak of prices that increase or stays the same. For example, given the prices 2, 5, 2, 6, 3, 3, 6, 7, 4, 5, there is the streak 2, 5, 6, 6, 7 of prices that increase or stay the same, but an even longer streak is 2, 2, 3, 3, 4, 5. Similarly, given the prices 1, 9, 2, 4, 3, 5, 8, 7, 7, 9, there can be multiple longest streaks: 1, 2, 3, 5, 7, 7, 9 or 1, 2, 4, 5, 7, 7, 9. In your solution, finding one longest streak is enough. Extra Credit Challenge: by using both dynamic programming and binary search, you can solve this problem in O(n log n) time.

b). You are given an n × m Hershey's bar. Your goal is to devise an algorithm A that takes as input (n, m) and returns the minimal number of cuts needed to divide the bar into perfect squares of either 1x1, 2x2, 3x3, . . ., jxj. With each cut, you can split the bar either horizontally or vertically. The first cut will split the Hershey's bar into two sub-bars; after that each cut splits one remaining sub-bar into two. For example, A(2, 3) = 2 because 2x3 → (2x2, 1x2) → (2x2, 1x1, 1x1).

Question 1. Hint: Notice that no matter the rectangle input n × m, it is always possible to make a perfect square in the first cut. But this strategy will fail. It is possible to find an example input size for which the strategy of picking the cut which creates the largest square leads to extra cuts in total.

Question 2. You can not have fraction, after each cut, the generated rectangles will have integer dimensions (width and height are integer values).

Question 3. Devise a DP algorithm which determines the minimal number of cuts.

Question 4. If your solution has run-time θ(n 3 ), your solution is acceptable. Discuss the runtime of your algorithm, and show that run-time is equal or below θ(n 3 ).

Reference no: EM133285085

Questions Cloud

Is a multicore processor likely to improve game-playing : COM 123 Lebanon High School, Lebanon Is a multicore processor likely to improve game-playing performance in this scenario? Explain
Create your own metaphor or simile for a word : Create your own metaphor or simile for a word or concept of your choice OR for one of the following: Love, Hate, Friendship, Grief, Pride, Anxiety
How much more scalable is b over a under the condition : How much more scalable is B over A under the above conditions? See the parallel execution times - Can system B be slower than system A
How does claudine combat the pejorative stereotypes : How does Claudine combat the pejorative stereotypes that have been perpetuated against African Americans since the days of slavery
Devise a dp algorithm which determines the minimal number : CIS Syracuse University You can not have fraction, after each cut, the generated rectangles will have integer dimensions (width and height are integer values).
What is the role of the gallbladder : A 32 year-old-female who recently delivered twins presents with colicky type pain, URQ pain radiating to the shoulder. What is the role of the gallbladder
What is the meaning of static const in cpp : What is the difference between "class" and "struct" in C/CPP and What is an interface? 5- Do you have to initialize a variable in a method
What are the security vulnerabilities of authentication : CSS 222 Eastern Gateway Community College what are the benefits of this authentication scheme and what are the security vulnerabilities of this authentication
What features of this framework help in addressing a problem : DAT 475 Southern New Hampshire University Discuss the components of the plan-do-check-act framework and What features of this framework help in addressing

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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