Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project Automatic Big-O analysis of nested Java for loops Description In this project, students will write a program to analyze nested Java for loops and

Project Automatic Big-O analysis of nested Java "for" loops Description In this project, students will write a program to analyze nested Java "for" loops and output the Big-O notation/estimate for each source file in the target folder. Particularly, the intended program will

(1) take the absolute path of the target folder as its only input parameter

(2) iterate through each source file, e.g., sourceFile01.txt, in the target folder

(3) output the Big-O notation/estimate for that source file, e.g., in file BigO_sourceFile01.txt

Each source file contains the nested "for" loops in an appropriate Java syntax, and is limited to (1) at most 2 "for" loops and for loops only (so no "while" or "do-while" loops) (2) simple operations + (plus), - (minus), * (multiplication) and / (division). Note that shorthanded operations "++", "--", "+=", "-=", "*=", and "/=" are also allowed. For the sake of simplicity, you can assume that the input code is under Java language and is free of syntax errors, as well as no methods/functions involved.

A source file, e.g., "sourceFile01.txt" is a text file where the first three lines describe different set of variables. Line #1 describes the estimate variables which should be used in the BigO estimate outcome. Line #2 describes the control variables in each loop. Line #3 describes variables that appeared in the loop/nested loop body. The corresponding output file, e.g., "BigO_sourceFile01.txt" contains the Big-O estimate of the code given in file "sourceFile01.txt". If you cannot give the estimate, explain in that file the reasons.

Examples

"input01.txt"

n /* The estimate variable */

i /* The control variable in the for loop */

sum /* Variable(s) appeared in the loop body */

for(i=0; i

{

sum = sum+2;

}

"BigO_input01.txt"

O(n)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions