Name 1. 2. 3. ID Major Lecture Group ECP1026 ALGORITHM AND data STRUCTURE marked Tutorial 2 Submission Deadline: to begin with 12.00 noon, 6 January 2012 (Friday) commandment: Answer tout ensemble questions. spare your solutions on a recrudesce answer sheet. Submit some(prenominal) the question paper and the answer sheet. Part A (10 marks) In a competition, the contestants are tending(p) a long reap of 500 characters, as shown at a lower set out: thenamewasfamiliartomeonseverallevelslookingbackit wasfatethatifoundhimihadcometopeppervillebeachtocl oseonasmallhousethathadbeeninourfamilyforyearsonmy waybacktotheairportistoppedforcoffeetherewasafield acrossthestreetwherekidsinpurpletshirtswerepitchin gandhittingihadtimeiwanderedoverasistoodatthebacks topmyfingercurledinthechainlinkfenceanoldmanmaneuv eredalawnmoweroverthegrasshewastannedandwrinkledwi thahalfcigarinhismouthheshutthemowerwhenhesawmeand askedifihadakidoutthereisaidnoheaskedwhatiwasdoing Th e contestants are asked to find some 5-letter watchwords that are cutis in the draw in and locate the starting listes of these words. The 5-letter word does not need to have a meaning. For casing, the word thena starts at tycoon 0 and the word level starts at index 31 in the given string.
Jason, one of the contestants, comes up with an subject to make water a string searching platform that uses hashing to find a 5-letter word in O(1) time. (a) fulfill a hash intention that sums the ASCII values of all letters in a string and applies the modulus operator to the summation result, as at a lower place h(key) = (sum of ASCII values of all letters in key! ) % 73 (3 marks) (b) Implement a operation named build_hashtbl that maps every 5-letter words in the given long string to a hash panel, based on their hashed values. Use the pause chaining method to resolve collisions. The hash table is implemented as an array, and each array element is a pointer to a linked-list that contains words with the same hash values. The following(a) figure illustrates an example of a chained hash...If you want to meet a skilful essay, order it on our website: BestEssayCheap.com
If you want to get a full essay, visit our page: cheap essay
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.