Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Number your problem answers clearly, such as Problem ( 1 . a ) , ( 1 . b ) , ( 1 . c )

Number your problem answers clearly, such as Problem (1.a),(1.b),(1.c),(1.d),(1.e), Problem 2,
Problem (2.a),(2.b),...,(4.d), and arrange the answers to the problems in order. Use only a
Word file (.docx) to answer the questions; PDF files will be graded without feedback. Failure to
use a Word file will result in non-feedback or a deduction of 10 points.
If you attach a PDF page in your Word file for solutions, please leave a few lines blank after
your solution page to allow for comments. You will not get any feedback if there is difficulty.
The total number of points for this assignment, As01, is 60.
You can use only logical operators, relational operators, boolean expressions, if, if-else, if-elseif, nest-if, and while statements. You can use statements to input x and y and output their
quotient and remainder.
1.[20 pts.] Extend the iterative version of the division function division(x, y) to compute
x/y using the addition operator, where x and y are integers, and the output is x = q * y + r,
q and r are integers. Write a program to compute x/y iteratively. (For credits, please copy
and paste your program into a Word file) for submission. You also need to submit your
program, which allows us to execute it with another set of inputs.)
2.[20 pts.] To improve the iterative version, write a recursive function division(x, y) to
compute x/y using the addition operator, where x and y are integers, and the output is x =
q * y + r, q, and r are integers. Write a program to compute x/y iteratively. (For credits,
please copy and paste your program into a Word file) for submission. You also need to
submit your program, which allows us to execute it with another set of inputs.)
3.[10 pts.] For problem 1, what is your input size? How many iterations do you need to
compute x/y? Justify your solutions.
4.[10 pts.] For problem 2. What is your input size? How many recursive calls do you need
to compute x/y? Justify your solutions.
Your test data will be the following set {(X, Y)}. Your output should be as follows: x = q*y + r.

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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students explore these related Databases questions