Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROGRAM REQUIREMENTS Write a program that calculates the performance statistics for n = 30 and n = 1000. For each item write an actual for

PROGRAM REQUIREMENTS

Write a program that calculates the performance statistics for n = 30 and n = 1000. For each item write an actual for loop that corresponds to the BigO requested and has the loop count the number of iterations. O(1) would not actually be a loop, but a single statement.

A function using an algorithm with a worst-case running time of O (1).

A function using an algorithm with a worst-case running time of O (n).

A function using an algorithm with a worst-case running time of O (n2).

A function using an algorithm with a worst-case running time of O (n3).

A function using an algorithm with a worst-case running time of O (log2 n).

A function using an algorithm with a worst-case running time of O (n log2 n).

A function using an algorithm with a worst-case running time of O (n2 log2 n).

Each function should calculate the performance statistics for its algorithm by having a counter embedded in the function to count the number of times the innermost instruction is executed. The output should report performance at n = 30 and n = 1000 for all seven functions. Put the output into a tabular format with the columns n=30 and n=1000 and the rows each of the BigO functions (similar to below).

n=30 n=1000

O(1) xxxx xxxx

O(n) xxxx xxxx

O(n2) xxxx xxxx

O(n3) xxxx xxxx

O (lg n) xxxx xxxx

O (n lg n) xxxx xxxx

O (n2 lg n) xxxx xxxx

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

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions