Express efficient algorithms clearly for the below problem. Also, explain the asymptotic behavior of the algorithm. Assume a list of building blocks. Each block is a cube with a given size, and has ontop, a list of all the other blocks that can be placed directly on top of it. You are also given a number k. Determine whether or not you can build a tower with block 0 at the bottom and block 1 at the top using no more than k blocks. If so, we want to know the height of the shortest such tower. Example: given 0: 8, ontop=2,3 1: 15, ontop=0 2: 11, ontop=1,3,4 3: 10, ontop=0,1,2 4: 7 ontop=1 if k were 2 the answer would be no. if k were 4 the answer would be yes, with height 33 (block0 then block3 then block1)
Express efficient algorithms clearly for the below problem. Also, explain the asymptotic behavior of the algorithm.
Assume a list of building blocks. Each block is a cube with a given size, and has ontop, a list of all the other blocks that can be placed directly on top of it. You are also given a number k. Determine whether or not you can build a tower with block 0 at the bottom and block 1 at the top using no more than k blocks. If so, we want to know the height of the shortest such tower.
Example: given
0: 8, ontop=2,3 1: 15, ontop=0 2: 11, ontop=1,3,4 3: 10, ontop=0,1,2 4: 7 ontop=1
if k were 2 the answer would be no.
if k were 4 the answer would be yes, with height 33 (block0 then block3 then block1)
Step by step
Solved in 2 steps