Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

More Books

Students also viewed these Databases questions