6QA16BA1d01 - CSE 100 Midterm Examination W.A Burkhard May...

Info icon This preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
Image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
Image of page 5

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

View Full Document Right Arrow Icon
Image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSE 100 Midterm Examination W.A. Burkhard May 1, 1997 1. This is a closed book examination; one study sheet is allowed. 2. Please check the entire examination immediately to ensure that your copy has all six pages. 3. Put your name on all pages of the examination. 4. All questions have equal mark value. 5. Neatness counts. r 6. You must clearly show your work; take time to prepare a legible answer. 7. Good luck and have fun!’ SOLLATloNS name oce or c5100 login 1 6. 2 7. 3 8. 4 9. 5 10. total Table Data Type: Hashing name For the hashing problem, use the hashing functions h1(x)=x'/.11 and h2(x)=(x'/.10)+1 for a table of size eleven. 1. Insert the following sequence of key values into an empty table using Ordered hashing: 11, 69*, 81, 36, 55, 40, 15, 60 Show your work here . hi hi i H: o 7— 6"): 3 81; 4 35: 3 7 55'. O bmmps \\ '40: “7 \5; ‘1! e 503 5 lamps \5‘ MC; ’3. S3“ : filwlfl <6 M: A 0 u WA Table Data Type: Hashing name 3. What is the average unsuccessful search length for the following double hashing table? The key space is the set of non—negative integers. Show your work here \ Z 3 ‘i first: sec 0: 1 1 \1 j. prom. la ”04$ 4—. ““043 TOTAL, : 94HO+Lt+H+1l 4.A If good unsuccessful search lengths are required, should pass bits or ordered hashing be used? The following graph may be of use. 6 ”The. Gown-1% clean/was. 0n Unsuccessful Search Lengths : _._._——_ -—- FAW’ rm. Swu“ i99~di©7¥hdfim 4 X P935 bi‘l’s Q‘we, inc-+4?» {3%‘Pvfi—unhbé‘. $41.. {VA’QL lOméiwo “FM/17"“ >/ K OWN/ma, hashing L: lea/“Hm. ------ expected pass-b'fl — expected ordered hashing (— search lengths O.“ 0 2 0.1 “.6 01 L0 loadan factor 4.B Can ordered hashing and pass bits be used together obtaining unsuccessful search lengths better than either by itself? Answer yes or no and argue why your answer is correct. Eyes or D110 The pass \o\+ fies-4w; doe/c my?” omilfm‘ {QM/k orcLMed “hiking ‘mgpAfi‘q‘m W (hangs, We 5U?“ PM ‘57": p»; inst/tack. Miscellaneous name 5. The following tree arises within the Floyd—Williams heap algorithm. Position the tree nodes within the array 23456789 suitable for the Floyd-Williams algorithm. 6.A Within a two—dimensional triangular array, where is index (3,6) located? 1 (3:43): 5.51 3. : is t 6.B Which index is associated with location 48 within a two-dimensional array? 0 4 Z" 4 2. ‘ 7. (21} 4. (LI) : ‘1‘% 3 wzvfi- +\~e V'fimk ‘tncw' i: - 2 (”WWW l7?) s W l L L ‘ '9 ' (3) \o) C_______.._.————- 7. Derive the expression for the expected number of items visited while doing a successful search within a linear list of n items. h 1 l+L+3+ lvvir l/l __ n+1 a», i wwmynnia Q 2‘75:- h “=2 N, N (More) Run—Time Performance name __ 8. How many times is the x assignment statement executed? for(inti=1;i<=n;i++) for(intj i;j<=n;j++) inJEj] 35; TV X assign NM szM }s Mégwfivaé m V\ V“ I ‘ .1 E, 1 : : ,(h‘L+j—) : HQ?) +tv~nag, ‘151 Jz‘i 2,: 9. What is the O run-time for this fragment? for(inti=1;i<=n;i++) for(intj=n/i;j>=1;j-—) X[i1[j1=35; 11“- . Y'} 13L ‘ “/2. 1:2 \ 0/3 C++ Programming name 10. We are to implement the “update” method for a double table implementation of our expanded Table class which is listed below. template <class DATA> class Table { DATA at +kb\b a public: ‘ 3 " Table ( ) ; m-E Y\ 3 H $32, ()4 +ab\€ bool insert ( const DATA 8: ) ' x j ’ l 4. m r In my» 4: ‘ bool fetch ( DATA 2; ) const ; m 5 I] M \ ° “fin“- bool update (rconst DATA & ) ; bool remove ( DATA & ) ; l The update method provides a mechanism to change data that has already been inserted in the table without having first to remove the previous version of the data and then inserting the new version. Your implementation must not use these two functions either! The update method locates the proper record within ' the table using the data “key;” it then stores its DATA parameter within the same slot that contained the previous version of the data. If no such record is found in the table, update operates just as the insert method would; The update return value is true if it can store its “new version” DATA parameter within the table; otherwise it returns false. template <c1ass DATA> bool DoubleTab1e<DATA> :: update ( const DATA & data ) { . . \ lh‘t start = index : (““5‘ j“¢¢\ &W 070 fl ‘9 ‘m-t $+ep :: (Mosxcsneéh $afi’k G7; (n~1\ 'i‘ 1 :3 While ( l “talolel: ‘mdmcjds EMF-tam fig +a‘oltt‘molex] l: cicc‘i”:\\) 5L Male/x = (Mela/>4 + S'drep') '79 YX 3 ii ( saw»: =2 ‘maw‘x (‘v‘rw‘n am 3 // Cam we: it ( +o~b\tl.\ndw1.isE~pmH \ Tm-H- 3 // mam-Mm comm ‘i‘ nblal: lnéqu] ; $°J§ a 3 Y{.+wrn true 3, C++ Programming name 10. We are to implement the “update” method for a double table implementation of our expanded Table class which is listed below. template <class DATA> class Table { DATA *¥ +o.\o\e, ‘ publlc: 3 ' Table () ; ‘m—t n - u 939' or +56% bool insert ( const DATA 8: ) ; ' bool fetch ( DATA 85 ) const ; bool update ( const DATA Kc ) ; bool remove ( DATA & ) ; 1va m 3 // hum‘eex 0'? meme. } The update method provides a mechanism to change data that has already been inserted in the table without having first to remove the previous version of the data and then inserting the new version. Your " implementation must not use these two functions either! The update method locates the proper record within the table using the data “key;” it then stores its DATA parameter within the same slot that contained the previous version of the data. If no such record is found in the table, update operates just as the insert method would. The update return value is true if it can store its “new version” DATA parameter within the table; otherwise it returns false. template <c1ass DATA> bool DoubleTable<DATA> :: update ( const DATA & data ) { . ‘ufl, start = index :: (““3‘3“¢é\&m 070 Y“ 69 in": sup : (Msxgnees exec—rot "‘2a (n-a\ + 1' 93 Wh‘xle ( E ‘lmHQ C 'mdtflj . '\ S EMptg‘W 932i +o.\o\t [Melba] }: Acctth index = (Mela/7L + seep) '79 n 3 it -( S‘iort =:- ‘lhabfx‘\ fc-‘rw'n -¥Q\5¢ w: // can‘t» updati ‘3 ll hm Fa“ if? ( +¢~\Q\ti \ndQ/‘t 1 r ‘l'a EMF*‘3(\ \ YYx-t-t‘ 3 // Mfi‘in'fi‘hin (‘Comfl'l “t ablet )némj : Cleg‘c c\ 3 ‘(t‘thrn true, ‘, ...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern