Compare the execution times of the two versions of program

Assignment Help Computer Engineering
Reference no: EM132103874

Problem 1

The binomial coefficient, binom(n,m), occurs frequently in mathematics. This value can be computed recursively as follows:

binom(n,m) = binom(n-1,m) + binom(n-1,m-1), where 0 = m = n, binom(n,0) = 1, and binom(n,n) = 1.

Write a C program to compute binom(n,m) recursively. The values for n and m should be passed as command-line arguments with appropriate error checking.

Measure the execution time of your program as you vary the values of m and n. Plot this execution time as a function of n with different lines for various values of m. You should measure the execution time for each data point at least five times. Choose values of m and n such that your execution time ranges from less than a second to more than 30 seconds. What relationship do you see between m, n, and the execution time?

Problem 2.

Repeat Problem 1, but compute binom(n,m) iteratively, that is, without recursion. Measure the execution time of your program and compare the execution times of the two versions of the program. Which one is faster? Why?

Reference no: EM132103874

Questions Cloud

Can you reduce the stalls for this code : Re-arrange the loop without unrolling. You can move individual instructions, however the output of this dummy loop should be exactly the same.
Why does dna synthesis use rna primase : Why does DNA synthesis use RNA primase instead of DNA primase?
Purchase computers for nick business : Jason, who is very knowledgeable regarding computers, agrees to purchase computers for Nick's business.
What circumstances would cause you to do those things : Why would you worry about doing any privilege escalation or leaving backdoors? What circumstances would cause you to do either of those things?
Compare the execution times of the two versions of program : Write a C program to compute binom(n,m) recursively. The values for n and m should be passed as command-line arguments with appropriate error checking.
What are the characteristics of an ideal memory : What are the characteristics of an ideal memory? Explain the concept of locality of reference both with respect to instructions and data.
Access to elements that have been inserted into the queue : Access to elements that have been inserted into the queue is limited to inspection and removal of the elements with smallest and largest priority only.
Calculate the number of mantissa digits : Using a technique explained in the class, calculate the number of mantissa digits and the unit round-off on the machine that you will use for this course.
What are some examples of marketing activities : What are some examples of "marketing" activities that are associated with the Summer Olympics? How does global marketing

Reviews

Write a Review

Computer Engineering Questions & Answers

  Developing an object-oriented model for bookstore

The bookstore wishes you to develop an object-oriented model for the new bookstore information management system.

  Creating a package delivery system

CS-224: Object Oriented Programming & Design Methodologies Assignment. For this assignment, you will be creating a package delivery system. You need to think in terms of objects. The first object is the delivery truck that can store 50 liters of pe..

  What is the polymorphic assingment

Why do C++'s capabilites of (polymorphism, encapsulation, inheritance) make programming difficult?what is the polymorphic assingment.

  Write a program to read and add polynomials

Write a program to read and add polynomials. You should define a class Term that contains the exponent and coefficient. This class should implement operator.

  Create logic for program that calculates due date for a bill

Create the logic for a program that calculates the due date for a bill. Prompt the user for the month, day, and year a bill is received.

  State which schedules are legal and which are illegal

For the same transactions, give a complete list of all values that x might have at the end, and state which are legal and which are illegal.

  What are the benefits and limitations of the relational

what are the benefits and limitations of the relational database model for business applications today? respond to at

  You have been hired by tmi to design an application using

you have been hired by tmi to design an application using shell script programs. tmi case projects needs you to design

  Calculate size of the database that you created in question

Calculate the size of the database that you created in question F. Provide size estimates for the initial size of the database as well as for the database in one year's time.

  Write a program that displays a graphical user interface

Write a program that displays a graphical user interface (Windows form) that allows multiple names, e-mail addresses, and local phone numbers to be entered.

  How much should a user know about computers and software

How much should a user know about computers and software in order to man-age a systems development project team?

  Find out why and decide whether you agree with the stance

Many object-oriented programmers are opposed to using multiple inheritance. Find out why and decide whether you agree with this stance.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd