```
COMPUTER SCIENCE 3100 -- DATA STRUCTURES + ALGORITHMS

Study Questions for the Final Exam

======================================================================
Chapter Eleven:  Search Trees

* What property or properties must a binary tree have in order
to be a binary SEARCH tree?

32
..
.        .
.                    .
.                                      .
16                                        48
..                                        ..
.      .                                 .      .
.            .                           .            .
.                    .                   .                    .
8                    24                 40                    56
.                     .
.                    .
.                   .
44                 60
..
.  .
58  62

* The figure above depicts a binary search tree.  Fill in the
figure below to depict the tree after the operations shown are
carried out.  Assume the operations are carried out in the
order shown, using the STANDARD ALGORITHMS explained in our
text book.  (Be especially careful to follow the standard when
you delete a node with two children.)  Where the tree below has
spaces for nodes that do not exist, just leave the spaces
blank.

Insert 21, Insert 20, Insert 22, Delete 32, Delete 48, Delete 56

__

.          .
.                        .
.                                      .

__                                       __
..                                       ..
.      .                                 .      .
.                    .                   .                    .

__                    __                 __                    __
..                    ..                 ..                    ..
.  .                  .  .               .  .                  .  .
.      .              .      .           .      .              .      .
.          .          .          .       .          .          .          .

__         __         __          __     __          __        __          __
..         ..         ..          ..     ..          ..        ..          ..
.  .       .  .       .  .        .  .   .  .        .  .      .  .        .  .

* Compute the average number of compares that would have to be
done to do an unsuccessful search in the binary search tree
below.
128
..
.          .
.                     .
.                              .
64                             192
.                               ..
.                               .      .
.                               .             .
32                              180           224
..                              .
.  .                            .
.    .                         .
.      .                       .
16      48                     164

* Be familiar with all the standard operations on binary search
trees.

* Be familiar with the *conclusions* (not all the derivations)
of the file averageSearchInBST in the class gopher space.
(Under Notes-->Trees).

* Draw a picture of the tree that would result from doing a
SINGLE LEFT rotation to the tree shown below.  Assume that the
node marked "B" is the pivot node.  Be sure to label the
subtrees T1, T2, and T3 in your picture.

B
..
.          .
.                        .
.                                   .
.                                        .
.                                        A
...                                       .
.   .                                     ...
.     .                                 .       .
.       .                             .             .
.   T1    .                         .                  .
.           .                        .                   .
...............                      ...                 ...
.   .               .   .
.     .             .     .
.       .           .       .
.   T2    .         .   T3    .
.           .       .           .
...............     ...............
.
.
.
N

* Be prepared to answer questions like the one above, only for
doing a SINGLE RIGHT, DOUBLE LEFT, or DOUBLE RIGHT rotation.
(see diagrams in the class gopher space: avlRot03.jpg and
avlRot04.jpg)

* Be able to do the above-mentioned rotations in the
"degenerate cases" of trees that have height 3 or 4. (see
diagrams in the class gopher space: avlRot01.jpg and
avlRot02.jpg)

* Be familiar with the contents of the gopher space notes on
AVL trees: filename avlTrees in Notes-->Trees.

* Be able to identify the pivot node for a given insertion into
an AVL tree.

Starting with an empty tree, show the results of doing each of
the following insertions into an AVL tree:  (Circle each part

Insert 2, Insert 4, Insert 6, Insert 8, Insert 10, Insert 5.

Also name, in the order done, the rotations you used to
balance the tree.

======================================================================
Chapter Twelve: Graphs

Discuss ways that directed or undirected graphs can be

Given information about a specific graph and/or a specific
graph operation, discuss the choice of representation of the
graph that would tend to make the operation most efficient.
(For example, the relative number of nodes and edges in a graph
can make a difference in the ways that are convenient to
represent it.)

Given a drawing of a graph and some information about the order
in which one generates the neighbors of a node, mark the nodes
according to the order they would be visited in a depth-first
search or a breadth-first search.  (see the files
graphBrdthSrch.jpg and graphDpthSrch.jpg under Notes-->Graphs
in the class gopher space.)

======================================================================
Chapter Fourteen: Divide and Conquer

Describe "improvements" that can be made to quicksort in order
to increase the probability that it will run in O(NlogN) time,
and that it will use no more than O(logN) stack space. (see
file qsortBetter in the Notes section of the class gopher
space.)

For comparisons and data moves, state the average case and
worst case "big-O" complexities of insertion sort, bubble sort,
selection sort, quick sort, heap sort, merge sort, radix sort,
and distribution sort.

Of heapsort, insertsort, mergesort, and quicksort, which is the
all-round best performer, and why?
======================================================================

```