The gcd program of Example 1.20 might also be written int main() { int i = getint(),
Question:
The gcd program of Example 1.20 might also be written
int main() {
int i = getint(), j = getint();
while (i != j) {
if (i > j) i = i % j;
else j = j % i;
}
putint(i);
}
Does this program compute the same result? If not, can you fix it? Under what circumstances would you expect one or the other to be faster?
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 58% (12 reviews)
The difference between the two programs is in the two assignment statements i i j and j j i versus i ...View the full answer
Answered By
SUMAN DINDA
I LIKE TO TEACH STUDENTS. SO, I START MYSELF AS A PRIVATE TUTOR. I TEACH STUDENTS OF DIFFERENT CLASSES. I HAVE ALSO DONE BACHELOR OF EDUCATION DEGREE(B.ED). DURING THIS COURSE I HAD TO TEACH IN A SCHOOL. SO I HAVE A GOOD EXPERIENCE IN TEACHING.
5.00+
1+ Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
Expanding on Example 1.25, trace an interpretation of the gcd program on the inputs 12 and 8. Which syntax tree nodes are visited, in which order? Example 1.25 Many interpreters use an annotated...
-
Jim McNerney is racking up quite a record at 3M. Now, can he rev up its innovation machine? Jim McNerney was one of those boys: up early in the morning climbing trees while everybody else in the...
-
The Hartley (1946) and PolitzSimmons (1949) method. Suppose that all calls are made during Monday through Friday evenings. Each respondent is asked whether he or she was at home at the time of the...
-
Graph the exponential equation. Then state the inverse function in logarithmic form and graph it. Then state the domain and range of each function. = ()* = to Domain: Range: Inverse: Domain: Range:...
-
What is elaboration theory and how it would help you design a training program. ?
-
The capacitance of two parallel conductors of length L and radius r, separated by a distance d in air, is given by where / is the permittitivity of air ( = 8.854 10 -12 F/m). Create a cell array of...
-
Suppose that country A has 20,000 worker-hours available for production and that it initially has the technology given by case 4 of Exercise 1. data from case 4 of the exercise 1 Derive its PPF and...
-
The AB Partnership pays its only liability (a $100,000 mortgage) on April 1 of the current year and terminates that same day. Alison and Bob were equal partners in the partnership but have...
-
The graph of a function f is given. (Enter your answers as comma-separated lists.) x (a) At what numbers a does lim f(x) not exist? a= x-a (b) At what numbers a is f not continuous? a = (c) At what...
-
ADA Pharmaceutical Company produces three drugs: Diomycin, Homycin, and Addolin belonging to the analgesic (pain-killer) family of medication. Since its inception four years ago, ADA has used a...
-
Imperative languages like Fortran and C are typically compiled, while scripting languages, in which many issues cannot be settled until run time, are typically interpreted. Is interpretation simply...
-
Both interpretation and code generation can be performed by traversal of a syntax tree. Compare these two kinds of traversals. In what ways are they similar/different?
-
Although future trends are difficult to predict with certainty, describe your thoughts as to what new developments in the topics covered in this chapter could possibly take place as we move through...
-
There is much talk today about the demise of development planning. Many observers assert that development planning has been a failure. List and explain some of the major reasons for plan failures....
-
What are the principal sources of government revenues in developing countries? Why are many taxes so difficult to collect? Discuss.
-
Summarize the arguments for and against the establishment of state-owned enterprises (SOEs) in developing nations. Do you think that SOEs should be encouraged or discouraged? What are the arguments...
-
What are the links among educational systems, labor markets, and employment determination in many developing countries? Describe the process of educational job displacement.
-
A married man (born 3 November 1934) died on 8 July 2020. He received a retirement pension of 14,930 between 6 April 2020 and the date of his death. His wife (born 12 August 1940) had no income...
-
In October 2011, the average house price in the United States was $242,300. In October 2004, the average price was $289,600. What was the annual change in the average selling price?
-
The cost curve for the city water supply is C(Q) = 16 + 1/4 Q2, where Q is the amount of water supplied and C(Q) is the cost of providing Q acre-feet of water. (An acre-foot is the amount of water...
-
True or False? All recursive algorithms need a base case, even if it is Do nothing.
-
Design a maze in which there are starting positions that return Trapped when the starting position is Open.
-
True or false? If false, correct the statement. A recursive solution should be used when: 1. computing time is critical. 2. the nonrecursive solution would be longer and more difficult to write. 3....
-
es Hart, Attorney at Law, experienced the following transactions in Year 1, the first year of operations: 1. Accepted $16,600 on April 1, Year 1, as a retainer for services to be performed evenly...
-
Dahlia Corporation has a current accounts receivable balance of $439,516. Credit sales for the year just ended were $5,503,810. a. What is the receivables turnover? Note: Do not round intermediate...
-
Why does the organizational structure hold political significance? Provide an in-depth analysis of this concept using examples from both academic literature and real-world instances. Additionally,...
Study smarter with the SolutionInn App