Data Structures and Algorithms

Test 3 Study Guide

The tests in this course may contain any material covered in lecture up until this point, although much stronger emphasis will be placed on material for which you have received graded feedback. This page contains a collection of exercises that you may wish to complete to prepare yourself.

Lists

You should be able to describe the List ADT, describe several implementations of lists, and give code for methods of the lists we defined in lab.

  1. Name three list implementations.
  2. For each implementation, give the worst-case time complexity of inserting at front, inserting at back, and retrieving an element.
  3. How does a CircularArrayList avoid moving each element in its array when insertAtFront is called?

Trees

  1. Define the following terms with respect to tree data structures:
    • Leaf
    • Height
    • Binary tree
    • Binary search tree
    • AVL tree
    • Max heap
  2. Draw a diagram showing the “rotate left” operation on binary trees. When is it impossible to rotate a binary tree to the left?
  3. Write pseudocode for the AVL rebalancing algorithm.
  4. Is the following statement true or false? If true, give a justification. If false, give a counterexample. “All BSTs are heaps.”
  5. Consider the following tree: