If two words share all the same letters with the same frequency for each letter they are called anagrams. For example “listen” and “silent” are anagrams. You are given an array ALPHA which has indexes 0 to 25 all with a starting value of zero, where each index represents a letter in the alphabet. For example ALPHA[0] represents ‘a’ and ALPHA[3] represents ‘d’. You are given a function LTR2NUM(character) which returns the corresponding position in the alphabet of the letter input, for example LTR2NUM(z) = 25 and LTR2NUM(a) = 0.
Construct an algorithm that reads a collection of letters WORD and increments the corresponding index in ALPHA for each letter found in WORD. For example if there is a single ‘d’ in WORD then ALPHA[3] should equal 1 when the algorithm is finished
Construct an algorithm that outputs True if each index in ALPHA is equal to zer
Assume now that the two algorithms from a) and b) are functions, fillalpha(WORD) and isallzero(ALPHA). The function fillalpha returns the array constructed by the algorithm in part a, for example, fillalpha(aabbz) = [2, 2, 0, ……, 1].
Construct an algorithm that takes two collections containing letters that make up distinct words and outputs true if these words are anagrams and false if they are not

Extended Response12 MarksCommunity
16 Uses37 Views1 Like
Login or Create an Account to view the mark scheme, comment, and add to a test