Name 1. 2. 3. ID Major Lecture Group ECP1026 ALGORITHM AND info STRUCTURE marked Tutorial 2 Submission Deadline: forwards 12.00 noon, 6 January 2012 (Friday) commandment: Answer tout ensemble questions. import your solutions on a recrudesce answer sheet. Submit both the question paper and the answer sheet. Part A (10 marks) In a competition, the contestants are given up a long sketch of 500 characters, as shown at a lower lieu: thenamewasfamiliartomeonseverallevelslookingbackit wasfatethatifoundhimihadcometopeppervillebeachtocl oseonasmallhousethathadbeeninourfamilyforyearsonmy waybacktotheairportistoppedforcoffeetherewasafield acrossthestreetwherekidsinpurpletshirtswerepitchin gandhittingihadtimeiwanderedoverasistoodatthebacks topmyfingercurledinthechainlinkfenceanoldmanmaneuv eredalawnmoweroverthegrasshewastannedandwrinkledwi thahalfcigarinhismouthheshutthemowerwhenhesawmeand askedifihadakidoutthereisaidnoheaskedwhatiwasdoing The contestants are as ked to find some 5-letter interchanges that are hold in 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 business leader 0 and the word level starts at index 31 in the given string.
Jason, one of the contestants, comes up with an predilection to make water a string searching broadcast that uses hashing to find a 5-letter word in O(1) time. (a) work 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 beneath 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 add-in, 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 spare-time activity figure illustrates an example of a chained hash...If you want to exhaust 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.