Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3. (a) Explain what is meant by a specification and an implementation [10 marks] (b) Write an algorithm which inputs an array A[1...n and returns
3. (a) Explain what is meant by a specification and an implementation [10 marks] (b) Write an algorithm which inputs an array A[1...n and returns the same array with the elements in reverse order. Examples of use include: output input: A 15,8,1, 7, 2,9 (4,3,2,1] 9,2, 7, 1,8,5) (1,2,3,4 Your algorithm should work in-situ (i.e., an in-place algorithm that does not use any other array). (15 marks] (c) Rewrite the following algorithm so that the variable FOUND is not used (i.e., the value of the variable FOUND should be computed from other variables in the algorithm). Input: Array Ai...n), item M Output: true, if M in A, false otherwise FOUND + false PTR+1 while not FOUND and PTR <>
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