Dynamic Programming: Glossary
Dynamic Programming: Glossary
Bottom-up programming: In bottom-up programing, the sub-problems are created first and then assembled without worrying about how they'll work together in the end result. It's like Legos. If you build something like a jumbo Lego Ferris wheel and you have one extra car, you just don't use it in your final result.
This method is good for scenarios where there are a lot of unknowns or the big picture view isn't very clear. Dynamic programming and bottom-up programming are best friends.
Greedy algorithm: The greedy algorithm will choose what appears to be the optimal choice in the moment. Sometimes it gets the best solution and sometimes it just gets a solution. If you want the best solution all the time, then dynamic programming is just the thing.
Memoization: Not memorization. This is the computer optimization technique of storing calculated results that will be reused later. It's like memorization, but spelled differently to be more confusing. Memoize that.
Optimal substructure: A problem has optimal substructure if you can find optimal solutions to all of its sub-problems.
A sub-problem has an optimal solution if there's only one right answer. For example, a lot of bacon and eggs could mean different things, so there's no optimal solution. However, all the bacon and eggs you have doesn't leave room for more than one solution. Do you understand?
Permutation: One of many possible ways to order or arrange things. For example, you might put your day in this order: eat, play Call of Duty, eat, take out trash, clean room (if there's time). Your mom might have a slightly different permutation: eat, take out trash, clean room, play that stupid shooting game (if there's time).
Recursion: A programming situation where a function or procedure calls itself. It's like you telling yourself what to do…but without all the furtive glances from the other people on the bus.
Stack: A stack is a data structure that stores intermediate results of a routine until the routine finishes and they need to be unstacked (destacked? disenstacked?). They get retrieved in the reverse order that they went in, so the first item in will be the last item out.
For example, if the values that go into the stack are
4, 23.67, green goat, and false
then they come off the stack as:
false, green goat, 23.67, and 4.
Sub-assembly: A sub-assembly is a part of the assembled end result that itself also needs to be put together. If a car is the end result, its sub-assemblies could include the engine, the transmission, and speakers with enough bass to rattle other sub-assemblies right off the car next to you at a stoplight.
Top-down programming: Top-down programming starts with a high-level requirement, the big picture view. Usually, a main procedure serves as the outline of the program that will call more detailed program modules, functions, or procedures.