Skip to content

Commit 8d098d8

Browse files
authored
Update DP4_GuitarFingering_Tetris_SuperMarioBros.java
1 parent fdf86ff commit 8d098d8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

DynamicProgramming/MIT-6.006-IntroToAlgosNotes/DP4_GuitarFingering_Tetris_SuperMarioBros.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,33 @@ Given sequence of n notes, find fingering for each note(single).
7777
We are looking at all sources to find the shortest path.
7878
7979
This can be converted to single source shortest path by using a dummy node and connecting it with all column 0 nodes with weight 0. Now, the source is this dummy node.
80+
81+
82+
83+
//TETRIS TRAINING
84+
- given seq of n peices
85+
- must drp from top
86+
- full rows don't clear
87+
- can you SURVIVE? ==> THIS IS THE PROBLEM TO BE SOLVED
88+
- width w is small
89+
- board is initially empty
90+
91+
92+
DP Approach -
93+
1. Subproblems - How to play? suffix[i:] with peices. Given the board skyline.
94+
number of subproblems = n.((h+1)^w)
95+
we have w columns and each column can have a min heigth=0 and max height=h
96+
total possibilties for height for each column = (h+1)
97+
num of columns = w
98+
total possibilties for height for all columns = (h+1)^w
99+
2. Guess - How to play and where to drop the peice?
100+
We can rotate the peiece in 4 ways
101+
We can drop the peice at w locations
102+
number of choices = 4.w
103+
3. Recurrence - survival is the problem. Use boolean or [0/1]
104+
when using [0/1] we can maximize the recurrence
105+
Total Time = (num of subproblems)*(time/subproblem)
106+
= n.((h+1)^w).(4.w)
107+
= theta(n.w.((h+1)^w))
108+
80109
*/

0 commit comments

Comments
 (0)