Final review page for CS241: Data Structures -- Spring 2017

  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:
    1. O and Θ
      1. What is the definition of O?
      2. Does O(n) -> O(n^2)? I.e. if an algorithm is O(n) does that mean it is also O(n^2)? Explain why.
      3. What is the definition of Θ?
      4. Does Θ(n) -> Θ(n^2)? Explain.
      5. What does "divide & conquer" have to do with the log n term in the various log n algorithms?
      6. What is the running time of: some sort? Where "some" is one of: bubble, shell, insertion, merge, quick, tree, heap, selection, insertion, oracle, counting/table, random
      7. The previous question assumed we meant "average" running time. Why do we need to think about worst case running times as well in special cases?
    2. Write pseudocode for: some sort. Where "some" is one of: bubble, shell, insertion, merge, quick, tree, heap, selection, insertion, oracle, counting/table, random
    3. Hashtable
      1. Why is look-up O(1)?
      2. What does H: K->V mean? Hint: H, is a hashmap, K is a key, V is a value
      3. What is Java's hashtable called?
    4. clone
      1. What is the difference between a shallow copy and a deep copy? Write a snippet of code to illustrate.
      2. Given: this.x = that.x; in a constructor, is this that same as: x = that.x;? Explain.
      3. Assuming you have written clone(), or a constructor that acts like it; how do you test to make sure you have really made a deep copy? Give an example.
    5. 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.
    6. 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!
    7. 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.
    8. 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
        		}
    9. 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. Here's a final exam from 2015.
  5. Finally, here's an exam from 2013.