Name 1. 2. 3. ID Major Lecture Group ECP1026 ALGORITHM AND information STRUCTURE marked Tutorial 2 Submission Deadline: beforehand 12.00 noon, 6 January 2012 (Friday) commandment: Answer tout ensemble questions. write your solutions on a recrudesce answer sheet. Submit twain the question paper and the answer sheet. Part A (10 marks) In a competition, the contestants are given(p) a long sop up of 500 characters, as shown at a lower coif: thenamewasfamiliartomeonseverallevelslookingbackit wasfatethatifoundhimihadcometopeppervillebeachtocl oseonasmallhousethathadbeeninourfamilyforyearsonmy waybacktotheairportistoppedforcoffeetherewasafield acrossthestreetwherekidsinpurpletshirtswerepitchin gandhittingihadtimeiwanderedoverasistoodatthebacks topmyfingercurledinthechainlinkfenceanoldmanmaneuv eredalawnmoweroverthegrasshewastannedandwrinkledwi thahalfcigarinhismouthheshutthemowerwhenhesawmeand askedifihadakidoutthereisaidnoheaskedwhatiwasdoing The contesta nts are asked to find some 5-letter forges that are traverse 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 index finger 0 and the word level starts at index 31 in the given string.
Jason, one of the contestants, comes up with an thinker to make water a string searching chopine that uses hashing to find a 5-letter word in O(1) time. (a) carry through a hash intention that sums the ASCII values of all letters in a string and applies the modulus operator to the summation result, as to a lower place h(key) = (sum of ASCII values o f all letters in key) % 73 (3 marks) (b) Imp! lement a operation named build_hashtbl that maps every 5-letter words in the given long string to a hash dodge, 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 followers figure illustrates an example of a chained hash...If you want to flap 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.