Algorithm lab
Change an example and start the program to follow the algorithm step by step
Dynamic programming
cat → cuts
One move inserts, deletes or replaces one symbol. Matching symbols stay as they are.planet · panel → pane
You may skip letters. The ones you keep must appear in their original order in both words.Greedy algorithms
banana → 100110110
Walk from the root to a letter. A left branch gives 0 and a right branch gives 1. Those bits form the letter’s code.Strings
banana
“ana” starts at indices 1 and 3.abracadabra
“abra” occurs twice. After the first match, the final “a” shifts the pattern three places.AXRAABRA
Find ABRA in AXRAABRA. On the first try, RA already matches. See why those two letters let the pattern move three places.ushers
Read up to the e. Two words end here together, she and he.барабан
Start at either б. How many letters in a row match?анананас
Try to find ананас. Which letters can you keep if the match breaks?лиса→1083
The letter л has the code 1083. Each new letter changes the number for the word so far.кот и котик
One кот stands alone and another hides inside котик. How can we find both?2 × (3 + 4) − 5
Which operation comes first? The brackets put addition before multiplication.ан < анан < …
The word банан has five endings. In alphabetical order, ан comes first.б→ба→бан
Follow the letters of банан. Each step extends the piece you have already read.топот
Move outwards from п. First you meet two о’s, then two т’s.какао→акаок
Move the first letter to the end. Which rotation would come first in a dictionary?н + ан→нан
Look for нан inside банан. Join the letters on the tree edges as you go.мамамама
Two identical pieces sit side by side. Can you spot shorter repeats here too?Connectivity and spanning trees
Combinatorial search and networks