FinalWithSolSu98 - / TLA ('3 “+71%”; FLWQL Wm...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 8
This is the end of the preview. Sign up to access the rest of the 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 find 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 fig @65’96’3 i0 06% (av ’ilme 1/th lit/V1 Fiéwemi‘kfl‘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} Jfl‘mg Oi d. What is the best searching algorithm to use if the list of data is sorted. 6mm] 6mm @[LcyMB 45660993 +0 gov limes-y §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 Kflmqoa «GO/>1): Iqmo W QatC’flgj’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; gmaH-z 6W 94/ 6&7 W5 gflflmwi‘m 127*gi lOléa I“? you VWVC WQYé TILWJF 10/5 lQWK'h6i'9 Hm fbe/ U)” fli/lv\./0t/[) i. What is the advantage of using quadratic probing over linear probing. \ v I w € + [WW/6’ [Jr firm?) q/ff‘fflcria” LaffiiiVOV), 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/rovfi‘hm al/W/é War/753 “Mg bggl )«xgwg, «raglan-9 ww‘yi’lflg WOW» azievmmeirc 57g li’l” l4fl§ [Laifcflfi k. What types of problems are considered to be in the set NP-Complete. ,4 QKOlOlflvm I9 I?) fl/Pv (OWFlé‘lfi If: flm/ [w (am be V6 5mfi€ ’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. \/.,.\/lfl€m (Ml/a‘vg‘ Q V‘(+]OW g lb‘g l/qé‘l' 'K/"lfllé7weml M4 HAG lewclfOVlQ lhfiéé‘ Qwv‘ivmn (am 1&6) gain/lily [@WJWi65 1L0 WOW ‘\/ecw§/'v€., Wm“): (besbcxfl ECIBM/wdfl/ 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 \flwtl’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 finding a bucket. TL€0Y€+M¢HX Wave [9 m0 100M) gov mekflfg five my} QYWQ hi“ git/266 f<8§oY \J€ ‘TMW fl,»an Ug (my; M€€H’ dfléflé+ 3 tji€vm69 d. Repeat part c with the table size of 7. I? The fab/6 6126/3 New PC fl/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é fl 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} flag 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 finding 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 llflé \9Vfldflb 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. 3-sort the following array. Elma _-<'9 -5 -3 -/ -6 -3 -7! -§ -Lr ' l A A A (13 03 5 C C 5 “flex/é (91M ’5 Li‘7i“ ‘2 am) C 8. Show the array after the partitioning step and before the first recursive call to Qsort. Use the median of the first, 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.

Page1 / 8

FinalWithSolSu98 - / TLA ('3 “+71%”; FLWQL Wm...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online