Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

X+X+2 {x-Y>0} 1. (a) Explain the notation: {Pre} Code Post} [10 marks) (b) Which of the following statements are true? In each case you should

image text in transcribed

X+X+2 {x-Y>0} 1. (a) Explain the notation: {Pre} Code Post} [10 marks) (b) Which of the following statements are true? In each case you should be able to justify your argument informally. i. {x>Y} "YY21 ii. {x is even X+X+1 {v is odd} "Y 2 *x " [10 marks) (c) Write an algorithm, as a procedure, in pseudo-code which: inputs an array A[1...n and an item M; returns the index (position) of the item M if it occurs in A, otherwise returns 0. Examples of its application include input: A output 17,11,3, 2 7 16, 3 10 [6,5, 1, 2,9 1 Your algorithm should not perform useless comparisons. [20 marks] (d) Give an appropriate loop invariant for your algorithm in Part (c). [10 marks]

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_2

Step: 3

blur-text-image_3

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

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions

Question

305 mg of C6H12O6 in 55.2 mL of solution whats the molarity

Answered: 1 week ago