A Queue can be used to implement a line in a store. If George, Judy, John, and Paula get in line and the cashier checks out two customers. Who is the person in line that would be checked out next? (This is a so-called "peek" operation on queues). Group of answer choices Return John, and remove him from the line. Return John Return John and Paula

Respuesta :

Answer:

Explanation:

The following code is written in Java. It creates a Queue/Linked List that holds the names of each of the individuals in the question. Then it returns John and removes him and finally returns Paula and removes her.

package sample;

import java.util.*;

class GFG {

   public static void main(String args[])

   {

       Queue<String> pq = new LinkedList<>();

       pq.add("John");

       pq.add("Paula");

       pq.add("George");

       pq.add("Judy");

       System.out.println(pq.peek());

       pq.remove("John");

       System.out.println(pq.peek());

       pq.remove("Paula");

   }

}