Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Often mathematical functions are used to express the runtime of algorithm. You are being given five different algorithms, whose runtimes are expressed by the following

  1. Often mathematical functions are used to express the runtime of algorithm. You are being given five different algorithms, whose runtimes are expressed by the following functions. Each function varies with N, where N is data size.

T1(N) = N2.5, T2(N) = NlgN (lgN = log2N = log(N)/log(2) ), T3(N) = (1.25)N, T4(N) = N4 and T5(N) = NN

Arrange the algorithms from best to worst (assume N values should be sufficiently large so that you can compare different runtimes).



  1. Write a C++ program to implement each of those functions, and generate a table by varying N from N = 10 to N = 100 in steps of 10 (i.e.) N = 10, 20, 30, 40 etc.

The program should output the following:

N T1(N) T2(N) T3(N) T4(N) T5(N)

10 .. .. ..

20 .. .. .. .. ..

Etc.

.. are computed values from the code.

Make sure to have the return type for each function is float and input N is integer.


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

Mastering Influxdb Database A Comprehensive Guide To Learn Influxdb Database

Authors: Cybellium Ltd ,Kris Hermans

1st Edition

B0CNGGWL7B, 979-8867766450

Students also viewed these Databases questions

Question

What is an interface? What keyword is used to define one?

Answered: 1 week ago