Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Analyze algorithm efficiency with empirical tests Trace program execution with the debugger This exercise involves several algorithms for generating random permutations of the integers in
Analyze algorithm efficiency with empirical tests Trace program execution with the debugger
This exercise involves several algorithms for generating random permutations of the integers in N For example, when N and are legal permutations, but is not because the integer is duplicated and is missing.
The files Permutations.java and PermutationTester.java contain most of the code for the exercise. Create a new Java project in Eclipse and load these files into it
TheRandom classhasmethodsforgeneratingpseudorandomnumbersThemethodnextIntnreturnsa random integer in n
Tracing in debug mode
Open the PermutationTester class in an editor window. Doubleclick in the
left margin next to the statement palgorithma;
This should display a blue dot next to the statement, which marks a "break
point". When run in debug mode, the program will pause at this line. Click
the bug icon to start execution of the program. The program will stop at the breakpoint. Eclipse will also change to the "Debug perspective"
that shows panel with a list of all visible variables and their
values in the upper right corner.
What values are stored in array perm?
Click the Step Over icon to execute the method call.
What values are stored in array perm now? It is not correct according to
the problem specifications described above. What is wrong?
The error is in the statement inside the dowhile loop in the algorithm
method of the Permutations class. Fix the error check the Javadoc for the
nextInt method if necessary and run the tester in debug mode again to make
sure it is now correct.
Add two more statements to the main method to also run algorithm and
algorithm Run the program in debug mode again and execution will pause at
the breakpoint.
Advance one statement and write down the contents of array perm after
algorithm executes. Do the same for algorithm and algorithm
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started