This preview shows pages 1–6. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: EEL 4851 Final Summer 1999
Tuesdays and Thursdays 8:00 AM NAME tew IVOV) SS# Note: For all questions, an explanation of your answer allows me to give partial credit if the answer is
wrong. 7 1. Short questions. For each question you must explain your answer. Write neatly. I can not give you
credit if I can not read your answer. a. What is the best sorting algorithm for sorting a list where the items are in a ﬁle and it takes a long 27X fﬂck time to swap the items.
§€(€CJ[{OV\ gor’i €00 éwafg
QKMAD éﬂmymffé b. What is the advantage of using a heap instead of a binary search tree to implements a priority queue. baby we QCﬁiyl/I) IQMJr 1mm“ ﬂee
l/mé 6t [MW 6V (vn§+am+ git/MC f \ﬂag
move 0V CY, 4190 a. heaf/ 9mm: {{rrs w
Campidrc “55/ Ca“ be 65mm) in a. QIWf/de/ayn c. When balancing an AVL tree why do we sometimes need a single rotation and other times a double. iQ the Vool’riolpe 1‘5 jwé‘l‘ be law He met
4 Wk VmLal'x‘ow W! 9a. [4 ft 1'5 0?
[eve/9 below ’Hiew V6 M665 a glv/mlci‘roiuﬁ'ow gm emu {Wet :> acme WatW h. If I use a hash table with 1,000 buckets to store social security numbers (9 digit number) will the
sum of all of the digits make a good hash function? I l0 wan/2w *4 999% r) Van/oz 70
V‘myé (“7 foo 9mm”. Jaﬁﬂyam We 450;:
1217967: llqa< 1000 19er smallest {s "622%: ail/62% wed/:er I
Van/06 (#ZRwlllLB) 9M! (Poor i. What is the advantage of using double hashing over quadratic probing? elmzmm we 96mm (MW
Kroblzm. j. What is the best sorting algorithm if the list is almost sorted. i‘456vhotn Qari. pwir dLOQ. “471+
We a Wait ime a; 00)). k. What did the Shell sort algorithm do to achieve an average running time of less than 001 2 ) ? équ? {hex/146 de MOi' ivyeﬂaev. 1. What did the Quick sort and Merge sort algorithms do to achieve a running time of 0(n log n) ? gterbC am} €0hfh€V QX(S00)Q+)000 < I000
7‘
QOV W‘eV/am/o 0V VON/it'immw m. Will there ever be a sorting algorithm that performs better than 0(n log n) ? Why ? _ We :H’ Wat, gnu/em ’Haai‘ )/sz £1663
patio/0w) Camfaw‘éoné. 60 749%
[0M l/Wi~ d9 bgﬂzv. Q i, 4/90 (7646?: 61W ’HAc ivb/z inag 0n)?! 3 Vial/hf? 34 E“ 1* Theorem Them 2. Hashing.
a. Suppose hash("Tom") = 0 and 1 s /
SK 6461/} Explain you answers. If so where and if not explain why. b. Derive a good hash function to a/ 1'9 0Q 926 7 m3 7 13 (gm/“6 6M3 hem vrmgf gm} ma ewwty bM/T‘fh you are using quadratic probing, can "Tom" be inserted into the table?
ﬁ—a Lian): (ball/100 + 1'28 W05 7 WWW";
{93 0
how3 0 I use with a table size of 1,000 bucket used to store social security numbers. Show the ﬁmction or equation. Tkevz ave WWM/ 0M2 fmdolg W/
[‘9 {'0 ’i’aA’6 Hz. [629+ 3 ﬁyﬁs a? 5‘ CJM/dé 7)”)91’7L Wuwbélﬁ Vavyé ;’ 5,. not be found even if one exits. use a function that uses quadrat Quadratic probing has the problem that when the table gets more than half full an empty bucket ma 477
I Y
Since linear probing will always ﬁnd an empty bucket if one exits, can I
ic probing when the table is less than half full and linear probing when the table is more than half full? Explain why. 4/0, He bﬁékl chimw l/Vlw9i‘rKY‘OViBQ M WMZYWu/y 90 H” Gina/1’3 al/W/9/W6 The 9mm ““ 29le This
0‘“. +05 i’ab/é 9126. 04+ ML gov a New
QM mg: i tom [8 ééf‘jqw 3.9m 1’ I W
W G)
gx/
e) E”?
99 yea
@ 3. AVL binary search trees.
Given the following AVL tree show the tree after inserting 8. o gomﬁ MW 4+ 7%
"l0",
(/OQH 4+ M€X+ 3 anlLt'Qfg 0 ‘9
f) / a {3/3/ 7. 7% 7 :9 ﬂag
@ 0 View “My\ aw} {+9 9\
[gvelQ bow” (70 wz Maeé
3 “ aawbzf V0+af.‘oh.
09 V . @
@ @5 “a
J
@ Sq). /
@/ ‘ ® ifW‘a (L) \/ 4. Heaps. Refer to the following heap that this Jahle’ represents. Recall that the C++ language has the left
\ ' most component as index 0 not 1. H I l 0 I 23%557g410urf/2f) 5 l a. What number is the parent of the 8? . . ..——~_\ ,— II I/
[k b. What number rs the left chrld ofthe 8? / % /> I 0 ‘ c. What number is the right child of the 8? N _,,_ l (
1/ 6/ ’2 " )5
5 X d. To the right draw the heap that this table represents. ‘ 5. Shortest path. Find the shortest path from vertex 5 to each vertex using Dijkstra's algorithm.
1 S Dijkstra‘s algorithm is the one we covered in class for ﬁnding the shortest path for weighted graphs. K
J "Q" 15 @ b. What is the sequence of vertices that the Dijkstra's algorithm will process. v5, \/7/ V4 VR,VI/\/L+/\/’s/V8 (5, Z 6. Graph representation.
a. Draw the graph that this data structure represents. 0\ [01/ ...
View
Full
Document
This document was uploaded on 01/14/2012.
 Summer '09

Click to edit the document details