Page 1 of 1

Show work please, thank you! I will give thumbs up

Posted: Tue Sep 07, 2021 7:53 am
by answerhappygod
Show work please, thank you! I will give thumbs up
Show Work Please Thank You I Will Give Thumbs Up 1
Show Work Please Thank You I Will Give Thumbs Up 1 (41.52 KiB) Viewed 108 times
1. (10 points) Design an algorithm for computing [n] for any positive integer n. Besides assignment and comparison, your algorithm may only use the four basic arithmetical operations. 2. (10 points) Design an algorithm to find all the common elements in two sorted lists of numbers. For example, for the lists 2, 5, 5, 5 and 2, 2, 3, 5, 5, 7, the output should be 2, 5, 5.What is the maximum number of comparisons your algorithm makes if the lengths of the two given lists are m and n, respectively? 3. (10 points) Describe the standard algorithm for finding the binary representation of a positive decimal integer in pseudocode. 4. (10 points) Consider the following algorithm for finding the distance between the two closest elements in an array of numbers. Make as many improvements as you can in this algorithmic solution to the problem. If you need to, you may change the algorithm altogether, if not, improve the implementation given. ALGORITHM MinDistance(A[O. . n - 1]) //Input: Array Afo. .n - 1] of numbers //Output: Minimum distance between two of its elements dmin + 00 for i + O to n - 1do for j = 0 to n - 1 do if i =/= j and A[1] - A[][<dmin dmin + A - Al return dmin 5. (10 points) Design an algorithm for checking whether two given words are anagrams, i.e., whether one word can be obtained by permuting the letters of the other. For example, the words tea and eat are anagrams.