Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java program Note: You can use excel or another plotting package to plot your graphs. Part A: 120 marks 1) Implement the GCD (Greater CommonDivisor)

java program image text in transcribed
Note: You can use excel or another plotting package to plot your graphs. Part A: 120 marks 1) Implement the GCD (Greater CommonDivisor) Algorithm Input: Two positive integers, m and n Output: The GCD of m and n While (r+-mmod n) #0 men Output 2) Check the correctness of the algorithm for the following values of mand : (m.n): (14, 18) (56, 40) (63,97) (210, 54) (1240.735) Output m, n, ged(m, n). You may want to verify your results by hand or risk losing marks if your results are incorrect 3) Modify your implementation of ged(m, n) to create a function gedlterations(m, n) that returns the number of times the while loop is executed. 4) Generate pairs of positive integers (m,n) using a nested loop as shown below, Record and plot the results. On the same graph, plot the function 2 Plog nl // Create an array max with indices 0 to 100. Initialized to zeroes. form 1 to 100 for n=1 to m max[n] = maximum(max[n), gedlterations(m, n)) // Plot n going from 1 to 100 on the x axis, and two curves y=max[n] and y= 2 log nl. 5) So... looking at the graph you generated, what observations can you make? In particular, what do you notice about the relationship between the two curves (e.g., no apparent relationship, intersecting, not intersecting, one always greater, always equal, etc.)

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

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions

Question

Determine the location y of the centroid of the area. a y a D D X

Answered: 1 week ago

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Explain the procedure for valuation of shares.

Answered: 1 week ago

Question

Which months of this year 5 Mondays ?

Answered: 1 week ago

Question

Define Leap year?

Answered: 1 week ago