Question

You are a brick layer, and you're trying to build a wall out of bricks. Each...

You are a brick layer, and you're trying to build a wall out of bricks. Each brick i has height 1 but can have variable length Li .

At every step, someone hands you a brick & you have the option of either adding it to the current layer of bricks or starting a new layer of bricks on top of the old layer. Once you start a new layer of bricks, you can't add bricks to lower layers.

Each layer needs to be longer than or the same length as the one above it.

Your objective is to make this wall as tall as possible.

Give an efficient algorithm for finding the way to make a maximum wall if you must follow a predetermined sequence of bricks. (You know the sequence in advance but cannot change it). More credit for faster, correct algorithms. Note: A "greedy" algorithm won't work.

For this question, please define any subproblems and definitions you are using, state the Recurrence relation for the entries including all base cases (and explain why it's a correct recurrence relation), give the pseudocode for the alg, and analyze its Running time.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

There are points that make possible in O(n).ˆ

consider laying the bricks from i...n.ˆ

To find the max height the subproblem can reach the is not at all enough.

There are equivalent ways to get same height, but some of them have different lengths at the bottom most layer.

ˆMinimizing the length of the bottommost layer is enough; the configuration with smallest bottommost layer will have maximum height;

To deal with the min length instead of the max height leads to a natural O(n2) dynamic programming algorithm.

We have an O(n) algorithm with an observation about how one of the indices can works.

Add a comment
Know the answer?
Add Answer to:
You are a brick layer, and you're trying to build a wall out of bricks. Each...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You are considering opening a series of ice cream shops along a long, straight beach. There...

    You are considering opening a series of ice cream shops along a long, straight beach. There are n potential locations where you could open a shop, and the distance of these locations from the start of the beach are, in meters and in increasing order, d1, d2, d3, ...., dn; you may assume all of the di are integers. The constraints are as follows: • At each location you may open at most one ice cream shop. • The expected...

  • Name: Integumentary System Case Study: Jon's Story (Each question is worth 0.5 pts) At 63 years...

    Name: Integumentary System Case Study: Jon's Story (Each question is worth 0.5 pts) At 63 years old, Jon was retiring early by most people's standards, but he felt it was time and he was looking forward to it. His mind wandered as he raked the dry remnants of his front yard. The African summer had been hotter than usual but he had always worked outdoors and the warmth of the sun on his face felt good. Jon had grown up...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT