Client. Write a client program Permutation.java that takes an integer k as a command-line argument; reads a sequence of strings from standard input using stdIn.readString(0; and prints exactly k of them, uniformly at random. Print each item from the sequence at most once. m/Desktop/queues> more distinct.txt m/Desktop/queues> more duplicates.txt ABCDEFGHI AА В ВВ вв вв сс сс m/Desktop/queues> java-algs4 Permutation 3 < distinct.txt /Desktop/queues> java-algs4 Permutation 8 < duplicates.txt BB G AA BB /Desktop/queues> java-algs4 Permutation 3 < distinct.txt BB BB BB Your program must implement the following API: public class Permutation { public static void main(String[] args) Command-line argument. You may assume that 0 sksn, where n is the number of string on standard input. Note that you are not given n. Performance requirements. Your implementation must achieve the following worst-case performance requirements: • The running time of Permutation must be must be linear in the size of the input. • You may use only a constant amount of memory plus either one Deque or RandomizedQueue object of maximum size at most n. • For an extra challenge (and a small amount of extra credit), use only a constant amount of memory plus either one Deque or RandomizedQueue object of maximum size at most k.
Client. Write a client program Permutation.java that takes an integer k as a command-line argument; reads a sequence of strings from standard input using stdIn.readString(0; and prints exactly k of them, uniformly at random. Print each item from the sequence at most once. m/Desktop/queues> more distinct.txt m/Desktop/queues> more duplicates.txt ABCDEFGHI AА В ВВ вв вв сс сс m/Desktop/queues> java-algs4 Permutation 3 < distinct.txt /Desktop/queues> java-algs4 Permutation 8 < duplicates.txt BB G AA BB /Desktop/queues> java-algs4 Permutation 3 < distinct.txt BB BB BB Your program must implement the following API: public class Permutation { public static void main(String[] args) Command-line argument. You may assume that 0 sksn, where n is the number of string on standard input. Note that you are not given n. Performance requirements. Your implementation must achieve the following worst-case performance requirements: • The running time of Permutation must be must be linear in the size of the input. • You may use only a constant amount of memory plus either one Deque or RandomizedQueue object of maximum size at most n. • For an extra challenge (and a small amount of extra credit), use only a constant amount of memory plus either one Deque or RandomizedQueue object of maximum size at most k.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
![Client. Write a client program Permutation.java that takes an integer k as a command-line argument; reads a sequence of strings from standard input using stdIn.readString(); and prints exactly
k of them, uniformly at random. Print each item from the sequence at most once.
•1
~/Desktop/queues> more distinct.txt
A B C DEF G HI
~/Desktop/queues> more duplicates.txt
А В В ВВ В В С СС
~/Desktop/queues> java-algs4 Permutation 3 < distinct.txt
~/Desktop/queues> java-algs4 Permutation 8 < duplicates.txt
BB
G
АА
А
В
CC
~/Desktop/queues> java-algs4 Permutation 3 < distinct.txt
В
E
BB
F
CC
G
BB
Your program must implement the following API:
public class Permutation {
public static void main (String[] args)
}
Command-line argument. You may assume that 0 < k < n, where n is the number of string on standard input. Note that you are not given n.
Performance requirements. Your implementation must achieve the following worst-case performance requirements:
• The running time of Permutation must be must be linear in the size of the input.
• You may use only a constant amount of memory plus either one Deque or RandomizedQueue object of maximum size at most n.
• For an extra challenge (and a small amount of extra credit), use only a constant amount of memory plus either one Deque or RandomizedQueue object of maximum size at most k.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F88167701-6d3f-46b8-9f75-5ab21a2347bf%2F608f60fa-7ff5-42ee-a08c-438e076e1e06%2Fzfin7i_processed.png&w=3840&q=75)
Transcribed Image Text:Client. Write a client program Permutation.java that takes an integer k as a command-line argument; reads a sequence of strings from standard input using stdIn.readString(); and prints exactly
k of them, uniformly at random. Print each item from the sequence at most once.
•1
~/Desktop/queues> more distinct.txt
A B C DEF G HI
~/Desktop/queues> more duplicates.txt
А В В ВВ В В С СС
~/Desktop/queues> java-algs4 Permutation 3 < distinct.txt
~/Desktop/queues> java-algs4 Permutation 8 < duplicates.txt
BB
G
АА
А
В
CC
~/Desktop/queues> java-algs4 Permutation 3 < distinct.txt
В
E
BB
F
CC
G
BB
Your program must implement the following API:
public class Permutation {
public static void main (String[] args)
}
Command-line argument. You may assume that 0 < k < n, where n is the number of string on standard input. Note that you are not given n.
Performance requirements. Your implementation must achieve the following worst-case performance requirements:
• The running time of Permutation must be must be linear in the size of the input.
• You may use only a constant amount of memory plus either one Deque or RandomizedQueue object of maximum size at most n.
• For an extra challenge (and a small amount of extra credit), use only a constant amount of memory plus either one Deque or RandomizedQueue object of maximum size at most k.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps

Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question
Is there a way to do the bonus for Permutation? (Maximum size of at most K and not N)
Solution
Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY