Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q2 Proof of algorithm is correct with weak induction SP(x,n) // SP stands for slow power FP(x,n) // FP stands for fast power These algorithms

Q2 Proof of algorithm is correct with weak induction

  • SP(x,n) // SP stands for "slow power"
  • FP(x,n) // FP stands for "fast power"

These algorithms both take two parameters: a non-zero real number called x, and a natural number called n. The algorithms do not perform any error checking of the values passed to them. They are simply assumed to be correct. These algorithms both return a real number which is xn

Here is pseudocode for the algorithms:

SP(x,n)

result = 1

for (i=1; i<=n; i++) result = result *x

return result

FP(x,n)

if n==1 return x

if n is even return FP(x*x, n/2)

else return x*FP(x*x,(n-1)/2)

In this question you will use strong induction to prove that the algorithm works correctly.

In other words, you will prove that for all n and for all x - {0} FP(x,n) = xn

  1. Predicate Function (1 mark)

Your conjecture has already been stated in symbolic form:

It is a statement of the form n P(n)

What is the predicate function P(n)?

  1. Proof: Base cases (4 marks)

  1. Proof: Inductive step setup (2 marks)

This is the beginning of the inductive step where you are stating the assumptions in the inductive step and what you will be proving in that step. As you do so, identify the inductive hypothesis.

  1. Proof: Inductive step (14 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

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

Oracle PL/SQL Programming Database Management Systems

Authors: Steven Feuerstein

1st Edition

978-1565921429

More Books

Students also viewed these Databases questions

Question

Know the three main dimensions of the service environment.

Answered: 1 week ago

Question

Understand the roles of signs, symbols, and artifacts.

Answered: 1 week ago