Question: could someone help me with this pls Project 2 (Deques and Randomized Queues) Problem 4. (Sampling Integers) Implement a program called Sample.java that accepts lo

 could someone help me with this pls Project 2 (Deques andRandomized Queues) Problem 4. (Sampling Integers) Implement a program called Sample.java thataccepts lo (int), hi (int), k (int), and mode (String) as command-line

could someone help me with this pls

Project 2 (Deques and Randomized Queues) Problem 4. (Sampling Integers) Implement a program called Sample.java that accepts lo (int), hi (int), k (int), and mode (String) as command-line arguments, uses a random queue to sample k integers from the interval [lo, hi], and writes the samples to standard output. The sampling must be done with replacement if mode is "+", and without replacement if mode is "-". You may assume that khi lo + 1. Corner Cases The program should throw an IllegalArgumentException("Illegal mode") if mode is different from "+" or "-". Performance Requirements The program should run in time T(k,n) ~ kn in the worst case (sampling without replacement), where k is the sample size and n is the length of the sampling interval. >- */workspace/project2 $ java Sample 1 5 5 + 3 java Sample 1 55 - 5 Problem 4. (Sampling Integers) Hints: Accept lo (int), hi (int), k (int), and mode (String) as command-line arguments Create a random queue q containing integers from the interval [lo, hi] If mode is "+" (sampling with replacement), sample and write k integers from q to standard output If mode is "-" (sampling without replacement), dequeue and write k integers from q to standard output import stdlib.Stdout; public class Sample { // Entry point. public static void main(String[] args) { int lo = Integer.parseInt(args[0]); int hi = Integer.parseInt(args[1]); int k = Integer.parseInt(args[2]); RandomizedQueue q = new RandomizedQueue(); String mode = args[3]; if (mode.equal("+")) { kp } } } Sample > main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!