This preview shows pages 1–8. 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 DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: / TLA ('3 “+71%”; FLWQL
Wm beet" {aye @9363. EEL 4851 Final
Pretest for Summer 99 NAME 90” hole 3 SS# 9Ava W Note: For all questions, an explanation of your answer allows me to give partial credit if the answer is
wrong. 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 data structure for Searching if we need to insert, remove and ﬁnd items. yl'mv/ 66erch ’Wae
4H Ogemimws M’Yé b. What is the advantage of using a heap instead of a list to implements a priority queue. il/lgév’i/{jg QWi/ foil/I65 ﬁg @65’96’3 i0 06% (av ’ilme 1/th
lit/V1 Fiéwemi‘kﬂ‘h‘ab. c. Why do we use AVL trees as opposed to using a simple binary search tree. In other words, why do
we rebalance the tree. a kqiqmwéivge WHi 9W6
a WIN/MM} Jﬂ‘mg Oi d. What is the best searching algorithm to use if the list of data is sorted. 6mm] 6mm @[LcyMB 45660993
+0 gov limesy §EQVCLn e. What is the best sorting algorithm to use if the elements to sort are already almost sorted. {Maxim} Geri 00”} gm Cain/«291E?
‘29]le LiSJF. 00/93 lift/MC? f. What is the best sorting algorithm to use if the elements to sort are very large and swapping them
takes a relatively long time. gaggle... amt @(m mowé
WWW/W {Jr We OKWQBC/WPW‘QW‘
{Wm go! We [4653. g. What basic concept or approach allowed sorting algorithms to go to 0(n log n) time complexity
from 0(n2 ) orjust below 0(n2) . DfVibM me [memgl/c Kﬂmqoa «GO/>1): Iqmo W QatC’ﬂgj’lj; ggw : 2300 W5 30 0m. h. Why is the hash function that simply adds all of the ASCII characters generally not good. {he W95 {'67 im; gmaHz 6W 94/ 6&7 W5
gflﬂmwi‘m 127*gi lOléa I“? you VWVC
WQYé TILWJF 10/5 lQWK'h6i'9 Hm fbe/ U)” ﬂi/lv\./0t/[) i. What is the advantage of using quadratic probing over linear probing.
\ v I w € + [WW/6’ [Jr ﬁrm?) q/ff‘fﬂcria”
LafﬁiiVOV), 1 j. What types of problems are considered to be in the set NP. globlgwé ll/Wl (“V1 b5 M (Pol/Mommi—
luwé W The al/rovﬁ‘hm al/W/é War/753
“Mg bggl )«xgwg, «raglan9 ww‘yi’lﬂg
WOW» azievmmeirc 57g li’l” l4ﬂ§ [Laifcﬂﬁ k. What types of problems are considered to be in the set NPComplete. ,4 QKOlOlﬂvm I9 I?) ﬂ/Pv (OWFlé‘lﬁ If: ﬂm/ [w (am be V6 5mﬁ€ ’i'O l? l lm @0 WOVMVH {Ant/fa 1. What is an undecidable problem. 0“ KYOE/tfw ('9 {smog/“lag m. What is tail recursion. \/.,.\/lﬂ€m (Ml/a‘vg‘ Q V‘(+]OW g lb‘g l/qé‘l' 'K/"lﬂlé7weml M4 HAG lewclfOVlQ lhﬁéé‘ Qwv‘ivmn (am 1&6)
gain/lily [@WJWi65 1L0 WOW ‘\/ecw§/'v€., Wm“): (besbcxﬂ ECIBM/wdﬂ/
2. Hashing. (4' (la) : [0 9‘ a. Suppose hash("Tom") = 1 and you are using quadratic probing, in what bucket will "Tom" be stored in. Explain you answers.
Answer V) 0 V‘ 6 [am mo+ {M} an 6WYIJ‘7 \ﬂwtl’Ié‘h (qu [2 Kgrgfw”
(tang/$5 (mil c. With the table size of 8 what is the largest number of items that can be inserted without the risk of not
ﬁnding a bucket. TL€0Y€+M¢HX Wave [9 m0 100M) gov mekﬂfg
ﬁve my} QYWQ hi“ git/266 f<8§oY
\J€ ‘TMW ﬂ,»an Ug (my; M€€H’ dﬂéﬂé+ 3
tji€vm69 d. Repeat part c with the table size of 7. I? The fab/6 6126/3 New PC ﬂ/ig
fab/c? té 4+ WA?“ )HQ QVV’FJF/ WC (4m
jammwc? a barbie} WU lac gyms. 50% @(7 : /5o3:> % 99 W6 Cay) )‘Vi §€V¥ 0’ Lf’H" H'éma + Jth OVyi‘MZ/> 3. AVL binary search trees. Given the following AVL tree 6 g
0 G /
<2) 0 0 0 if <9 a. Show the tree after inserting 5.5. // Vié ﬂ ghylé Yalaliom b. Show the original tree after inserting 4.5. e l } We 4 amth rolmli'w
//’77 / c. What condition do you look for to know when to do a double rotation or a single one. lg We iméwlg/“D wwle I"; lygl’wéém Th9
WOdé l8 Umbalawgl aw} ﬂag mexl”
W096 digiev ’lhé‘m a gamblE Y/Olq’llOL/l I?) 4. Heaps.
a. Insert the number 2.5 into the heap. Redraw the heap to the right. b. Remove the smallest number. Redraw the heap to the right. a @
® 5 h e
9 5. Shortest path. Find the shortest path from vertex 5 to each vertex using Dijkstra's algorithm.
Dijkstra's algorithm is the one we covered in class for ﬁnding the shortest path for weighted graphs. Know! 026+ M 7 b. Wha is the sequence of vertices that the Dijkstra's algorithm will process. 9/ 2/3/ Lb/ 6. Topological sort.
a. In parts a and b, if you can not perform the sort explain why. Perform a topological sort. Redraw the graph on the right. [6m mal Quad a lapelgpwmé Geri {C
llﬂé \9Vﬂdﬂb We a; fgg'lé, 7. a. Recall the Shell sort algorithm sorts by using increments. What condition must hold for a list to be h
sorted. This condition is in the form of an inequality. MW ' 0 é ENVY czii/ b. 3sort the following array. Elma _<'9 5 3 / 6 3 7! § Lr
' l
A A A
(13 03 5 C C 5 “ﬂex/é (91M ’5 Li‘7i“ ‘2 am) C 8. Show the array after the partitioning step and before the ﬁrst recursive call to Qsort. Use the median of
the ﬁrst, middle and last elements as the pivot. Indicate what parts of the array will be sorted by a
recursive call to Qsort. __
“F Answer: ...
View
Full
Document
This document was uploaded on 01/14/2012.
 Summer '09

Click to edit the document details