Answered step by step
Verified Expert Solution
Question
1 Approved Answer
( 5 points ) Design an algorithm for computing | ? ? n 2 ? ? ? | for any positive integer n . Besides
points Design an algorithm for computing for any positive integer Besides assignment
and comparison, your algorithm may only use the four basic arithmetical operations.
points Design an algorithm to find all the common elements in two sorted lists of numbers. For
example, for the lists and the output should be What is the maximum
number of comparisons your algorithm makes if the lengths of the two given lists are and
respectively?
points Describe the standard algorithm for finding the binary representation of a positive
decimal integer in pseudocode.
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 MinDistanceAn
Input: Array of numbers
Output: Minimum distance between two of its elements
dmin larr
for ilarr to do
for jlarr to do
if and dminlarr
dminlarr
return dmin
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started