CS3 Test 2 Study Guide

Term 20053

Original guide from Prof. Heliotis

Here are the concepts you should be studying for the second exam.

Study Questions

1. What is the ideal pivot value for quick sort?

2. For which sorts could you define a "Big Theta" time complexity, i.e., where their worst- and best-case execution times are the same order?

3a. What universal assumption(s) do all sorting algorithms make about the data they're sorting?

3b. Which of the sorts listed above makes other assumptions about the data?

4. If a tree is recursively defined as a value and zero or more trees, there is one special tree that cannot be defined this way. Which is it?

5. I have a calculator that uses what is called "reverse Polish notation". For example, to calculate ( 5 + 32 ) / ( 13 * ( 0.7 + 2 ) ), I punch the following key sequence ("E" stands for "Enter"):

    5 E 3 2 + 1 3 E 0 . 7 E 2 + * /

Which binary tree traversal does this key ordering most closely represent? What is the "Enter" button doing?

6. When is an array a good choice for the implementation of a tree?

7. A data structure is defined as follows:

Have we defined a tree? Prove by contradiction.

8. Implement the graph of the cities of New York (with mileages) in three ways you know. Which one uses the least space? Assume characters are one byte, distances are 8-byte floating-point numbers, and object references are 4-byte pointers.