Docsity

MCS 360: Data Structures - Review of Chapter 7, Study notes of Data Structures and Algorithms

Toggle sidebar
bg1
MCS 360 Introduction to Data Structures Spring 2003
Review of Chapter 7
1. Give an example of a sequence and an element searched for in this sequence where interpolation search
outperforms binary search. Also give an example of a sequence where interpolation search does not
work better than binary search.
2. Consider the sequence 18 12 3 21 33 27 30.
(a) Insert the elements in the sequence into a binary search tree.
(b) Delete 21 from the binary search tree.
(c) Delete 18 from the binary search tree.
3. Give the code to compute the balance of a tree, using the definitions
typedef struct node tree;
struct node
{
int info;
tree *left;
tree *right;
};
and the prototype
void write_balance ( tree *t );
/* writes the info and balance of every node in postorder traversal */
4. Give the code to compute a left rotate in a binary tree. Use the definition of the tree as in the above
question. Illustrate the left rotate with an example.
5. Consider the sequence 29 5 30 55 59 5 42 29 3 25 61 46 50.
(a) Insert all numbers in the sequence in a top-down multiway tree of order 3.
(b) Insert all numbers in the sequence in a 2-3 B-tree.
6. Suppose you had to design a hash function selecting digits from a zip code to store data from people
all living in Chicago. Would you start with the least or most significant digit? Justify your answer.
FINAL EXAM is in Burnham Hall 0208 on Wednesday 7 May 2003 from 8:00 till 10:00AM.
In case of a scheduling conflict with another final exam, please let me know as soon as possible so we can
schedule a make up.
Observe the university rules concerning incompletes. An incomplete can only be granted if all of the
following conditions are satisfied:
1. The student is in good standing and needs only a final exam to complete the course. In particular, this
means that no midterms are skipped, attendance to the discussion sessions was documented by quiz
scores, and all projects received a satisfactory grade.
2. Some event (for which adequate documentation can be provided) prevented the student from making
a makeup final exam.
Note that these rules are from the university, and that the administration needs to approve incompletes.
Jan Verschelde, May 2, 2003 UIC, Dept of Math, Stat & CS Review 3, page 1

Partial preview of the text

Download MCS 360: Data Structures - Review of Chapter 7 and more Study notes Data Structures and Algorithms in PDF only on Docsity!

MCS 360 Introduction to Data Structures Spring 2003

Review of Chapter 7

  1. Give an example of a sequence and an element searched for in this sequence where interpolation search outperforms binary search. Also give an example of a sequence where interpolation search does not work better than binary search.
  2. Consider the sequence 18 12 3 21 33 27 30.

(a) Insert the elements in the sequence into a binary search tree. (b) Delete 21 from the binary search tree. (c) Delete 18 from the binary search tree.

  1. Give the code to compute the balance of a tree, using the definitions

typedef struct node tree; struct node { int info; tree *left; tree *right; };

and the prototype

void write_balance ( tree t ); / writes the info and balance of every node in postorder traversal */

  1. Give the code to compute a left rotate in a binary tree. Use the definition of the tree as in the above question. Illustrate the left rotate with an example.
  2. Consider the sequence 29 5 30 55 59 5 42 29 3 25 61 46 50.

(a) Insert all numbers in the sequence in a top-down multiway tree of order 3. (b) Insert all numbers in the sequence in a 2-3 B-tree.

  1. Suppose you had to design a hash function selecting digits from a zip code to store data from people all living in Chicago. Would you start with the least or most significant digit? Justify your answer.

FINAL EXAM is in Burnham Hall 0208 on Wednesday 7 May 2003 from 8:00 till 10:00AM.

In case of a scheduling conflict with another final exam, please let me know as soon as possible so we can schedule a make up.

Observe the university rules concerning incompletes. An incomplete can only be granted if all of the following conditions are satisfied:

  1. The student is in good standing and needs only a final exam to complete the course. In particular, this means that no midterms are skipped, attendance to the discussion sessions was documented by quiz scores, and all projects received a satisfactory grade.
  2. Some event (for which adequate documentation can be provided) prevented the student from making a makeup final exam.

Note that these rules are from the university, and that the administration needs to approve incompletes.

Jan Verschelde, May 2, 2003 UIC, Dept of Math, Stat & CS Review 3, page 1