0% found this document useful (0 votes)
56 views2 pages

hw5 PDF

This document contains instructions for assignments related to fundamental algorithms. It includes exercises to solve involving merge sort, binary search trees, hashing with chaining, and more. Students are asked to determine time complexities as functions of input size n, draw a binary search tree with given vertices and values, and illustrate inserting a new node into the tree. It encourages students to have many ideas, as most will be wrong, but learning which to discard is important.

Uploaded by

Aashish D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views2 pages

hw5 PDF

This document contains instructions for assignments related to fundamental algorithms. It includes exercises to solve involving merge sort, binary search trees, hashing with chaining, and more. Students are asked to determine time complexities as functions of input size n, draw a binary search tree with given vertices and values, and illustrate inserting a new node into the tree. It encourages students to have many ideas, as most will be wrong, but learning which to discard is important.

Uploaded by

Aashish D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Fundamental Algorithms, Assignment 5

Due March 4/5, in Recitation

I wasnt sure anymore and I will tell you, it is a strange process


to feel ones mind changing, allowing ideas into your brain which
it had once considered unthinkable. I cannot say its painful, or
particularly pleasurable, but that it requires a certain relaxation
of the hold one keeps over oneself, and is to that degree both a
thrill and a horror.
from The Chess Garden, by Brooks Hansen

1. Some exercises in which n is NOT the data size but we want the answer
in terms of n. (Answers in -land.)

(a) How long does MERGE-SORT on n2 items take?


(b) Suppose that when n = 2m , ANNA takes time (m2 2m ). How long
does it take as a function of n.
(c) Suppose that when n = 2m , BOB takes time (5m ). How long
does it take as a function of n.
(d) How long does COUNTING-SORT take to sort n2 items with each
item in the range 0 to n3 1.
(e) How long does RADIX-SORT take to sort n2 items with each item
in the range 0 to n3 1 and base n is used.

2. Consider hashing with chaining using as hash function the sum of


the numerical values of the letters (A=1,B=2,...,Z=26) mod 7. For
example, h(JOE)= 10+15+5mod7 = 2. Starting with an empty table
apply the following operations. Show the state of the hash table after
each one. (In the case of Search tell what places were examined and
in what order.)
Insert COBB
Insert RUTH
Insert ROSE
Search BUZ
Insert DOC
Delete COBB

3. Consider a Binary Search Tree T with vertices a, b, c, d, e, f, g, h and


ROOT [T ] = a and with the following values (N means NIL)
vertex a b c d e f g h
parent N e e a d g c a
left h N N e c N f N
right d N g N b N N N
key 80 170 140 200 150 143 148 70

Draw a nice picture of the tree. Illustrate INSERT[i] where key[i]=100.

If you want to have good ideas you must have many ideas. Most
of them will be wrong, and what you have to learn is which ones
to throw away.
Linus Pauling

You might also like