Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q 1 [ 1 4 ] Suppose a and b are constant integer arrays with domain { 0 , . . , n } where

Q1[14] Suppose a and b are constant integer arrays with domain
{0,..,n} where n1 with a increasing )
and b decreasing ). You may assume
that a(0)b(0) and a(n)>b(n). We need to find where the arrays cross.
In particular we want to find the largest value for p where a(p)b(p)
f=(:a(p')b(p')??a(p'+1)>b(p'+1):)
Use the method of binary search.
(a)[6] Give a loop invariant I.
I is
(b)[2] Let g=((:I:)=>f) and m=(:a'=a??b'=b??I':) Give an initializa-
tion command that refines m.
m
(c)[2] Give a guard expression A such that (:notA:)=>g skip
A is
(d)[2] Give a loop body command that refines h=(:A??I=>I'???a'=a??b'=b:)
and decreases a bound expression.
h
(e)[2] Give a bound expression with which your loop can be shown to
terminate.
image text in transcribed

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago