Question: Code for Oracle.java package MissingNumber; import java.lang.Math; public class Oracle { long [ ] data; / / Creates a new oracle, ready to be told
Code for Oracle.java
package MissingNumber;
import java.lang.Math;
public class Oracle
long data;
Creates a new oracle, ready to be told all numbers
in any order from to except for one or two.
Must run in O time.
Oracle
Tells the oracle a number between and not yet told.
Must run in O time.
void tellint i
If every number between and except one have
been told, and no number has been told more than once,
sets MissInt equal to the one number not yet told.
Otherwise has undefined behavior.
Must run in O time.
void missingoneint MissInt
If every number between and except two have
been told, and no number has been told more than once,
sets MissInt and MissInt equal to the two numbers
not yet told where MissInt MissInt
Otherwise has undefined behavior.
Must run in O time.
void missingtwoint MissInt
Code for MAintest.java
package MissingNumber;
import java.util.;
import MissingNumber.Oracle;
public class MainTest
public static void mainString args
Setup
int MissInt;
MissInt new int; For missing numbers.
ArrayList V new ArrayList;
Test missingone
Oracle o new Oracle;
for int i ; i ; i
otelli;
MissInt;
omissingoneMissInt;
testMissInt;
Oracle o new Oracle;
for int i ; i ; i
otelli;
MissInt;
omissingoneMissInt;
testMissInt;
Oracle o new Oracle;
otell;
for int i ; i ; i
otelli;
MissInt;
omissingoneMissInt;
testMissInt;
Oracle o new Oracle;
Vclear;
for int i ; i ; i
Vaddi;
Collections.shuffleV;
for int i ; i ; i
otellVgeti;
omissingoneMissInt;
testMissInt Vget;
Oracle o new Oracle;
Vclear;
for int i ; i ; i
Vaddi;
Collections.shuffleV;
for int i ; i ; i
otellVgeti;
omissingoneMissInt;
testMissInt Vget;
System.out.printlnAssignment complete.";
public static void testBoolean a
if a System.out.printlnFound;
else
System.out.printlnFail;
return;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
