\( \newcommand{\blah}{blah-blah-blah} \newcommand{\eqb}[1]{\begin{eqnarray*}#1\end{eqnarray*}} \newcommand{\eqbn}[1]{\begin{eqnarray}#1\end{eqnarray}} \newcommand{\bb}[1]{\mathbf{#1}} \newcommand{\mat}[1]{\begin{bmatrix}#1\end{bmatrix}} \newcommand{\nchoose}[2]{\left(\begin{array}{c} #1 \\ #2 \end{array}\right)} \newcommand{\defn}{\stackrel{\vartriangle}{=}} \newcommand{\rvectwo}[2]{\left(\begin{array}{c} #1 \\ #2 \end{array}\right)} \newcommand{\rvecthree}[3]{\left(\begin{array}{r} #1 \\ #2\\ #3\end{array}\right)} \newcommand{\rvecdots}[3]{\left(\begin{array}{r} #1 \\ #2\\ \vdots\\ #3\end{array}\right)} \newcommand{\vectwo}[2]{\left[\begin{array}{r} #1\\#2\end{array}\right]} \newcommand{\vecthree}[3]{\left[\begin{array}{r} #1 \\ #2\\ #3\end{array}\right]} \newcommand{\vecfour}[4]{\left[\begin{array}{r} #1 \\ #2\\ #3\\ #4\end{array}\right]} \newcommand{\vecdots}[3]{\left[\begin{array}{r} #1 \\ #2\\ \vdots\\ #3\end{array}\right]} \newcommand{\eql}{\;\; = \;\;} \definecolor{dkblue}{RGB}{0,0,120} \definecolor{dkred}{RGB}{120,0,0} \definecolor{dkgreen}{RGB}{0,120,0} \newcommand{\bigsp}{\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;} \newcommand{\plss}{\;\;+\;\;} \newcommand{\miss}{\;\;-\;\;} \newcommand{\implies}{\Rightarrow\;\;\;\;\;\;\;\;\;\;\;\;} \newcommand{\prob}[1]{\mbox{Pr}\left[ #1 \right]} \newcommand{\exval}[1]{\mbox{E}\left[ #1 \right]} \newcommand{\variance}[1]{\mbox{Var}\left[ #1 \right]} \)


How to prep for Exam 1


 

About the exam:

 

How to prep:

 


Sample questions

 

One set of sample questions are the non-programming module exercises, or slightly modified versions of them.

See sample quiz questions for examples of multiple-choice questions

Here are examples of questions that need written answers:

  1. Show that it's possible to have two functions \(f(n)\) and \(g(n)\) where neither \(f(n) = O(g(n)) \) nor \(g(n) = O(f(n)) \) is true.
  2. Insertion-sort is generally faster than Mergesort for small arrays such as \(n \leq 10\). Write pseudocode to show how you can integrate Insertion-sort into Mergesort so that all array segments of length at most 10 get sorted by Insertion-sort.
  3. Use an example to explain the difference between a Map and a Set.
  4. Insert the following numbers into a Binary Search Tree in the order given: 50, 30, 70, 20, 40, 60, 80. Then show the steps in deleting 30.
  5. Show with an example, how doubleRotateLeftChild works in an AVL tree.
  6. What role does a stack play in a multi-way tree?
  7. If 30,000 English words are to be stored in a hashtable, write pseudocode for insertion, assuming the hashtable uses arrays instead of linked lists.
  8. Explain why a full trie has \(O(n)\) interior nodes.
  9. If, in the Rabin-Karp algorithm with a pattern of size \(m\) and text of size \(n\), the first signature calculation in the text takes \(O(m)\) and each subsequent signature calculation in the text takes \(O(\log m)\), how long does the whole algorithm take?
  10. Construct a DFA for the regular expression \((A|B)^*(AB|BA)\).
Note:
  • The above sample questions are only a guideline. Do NOT read anything into the particular topics selected above.
  • Answers to the above questions will not be provided, nor will the TAs do these in the lab. The idea is for you to develop confidence in answering the questions yourself.