## Final review page for CS241: Data Structures -- Spring 2015

1. Disclaimers:
1. Not all of these questions will appear on the final.
2. Not all of the questions on the final appear here.
2. First, make sure you can answer the questions on the midterm review page... especially if your midterm score was less than satisfying! There will be questions from the first half of the term on the final!
3. Sample questions from the second half of the course:
1. Binary tree/ Binary Search Tree/heap
1. What is the definition of a binary tree?
2. Given that definition, if you store 3 values in a binary tree, how many binary trees are in it total? How many empty trees?
3. Write a method, ht, that returns the ht of a binary tree.
4. Write a method, size, that returns the number of non-null sub trees in a tree
5. What is the definition of a BST?
6. What is the definition of a heap?
7. How does a heap represent the binary tree?
8. Write pseudocode for tree sort.
9. Write pseudocode for heap sort.
2. N-nary tree
1. What is the definition of an nary tree?
2. Define an nary tree class including a constructor
3. Write a method to traverse an n-ary tree, send toString to each root, and sout it with indentation showing its depth
4. Write ht and size (see above)
5. Write pseudocode for displaying an nary tree graphically
6. Given a Board class with `BoardList generateNextLegalBoards(Board)`, creates an entire gametree!
3. Dynamic programming
1. What is the Needleman-Wunsch algorithm used for?
2. Write it! Pseudocode is fine.
3. What is its running time?
4. Why is this called dynamic programming?
5. Write pseudocode for generating Fibonacci numbers using dynamic programming.
4. Cellular automata
1. What are the rules of Conway's life?
2. How to you make the board a torus? Write code!
3. What's wrong with this loop?
``````
for each cell {
count nbrs
update state
}``````
5. Space and time
1. How can you trade space for time? Give an example.
2. How can you trade time for space? Give an example.
3. Write a Board class for tic tac toe that represents the board as a 2D array of ints (1 for X, -1 for O, 0 for empty)
4. Write a method that is passed a Board and returns a unique int representing that Board.
4. Finally, here's the final exam I gave the last time I taught cs241.