Linked List To Queue Adapter
easy
1. You are required to complete the code of our LLToQueueAdapter class. 2. As data members, you've a linkedlist available in the class. 3. Here is the list of functions that you are supposed to complete 3.1. add -> Should accept new data in FIFO manner 3.2. remove -> Should remove and return data in FIFO manner. If not available, print "Queue underflow" and return -1. 3.3. peek -> Should return data in FIFO manner. If not available, print "Queue underflow" and return -1. 3.4. size -> Should return the number of elements available in the queue 4. Input and Output is managed for you. Note -> The intention is to use linked list functions to achieve the purpose of a queue. All the functions should work in constant time.
Constraints
None
Format
Input
Input is managed for you
Output
Output is managed for you
Example
Sample Input
add 10
add 20
add 30
add 40
add 50
add 60
peek
remove
peek
remove
peek
remove
peek
remove
peek
remove
peek
remove
quit
Sample Output
10
10
20
20
30
30
40
40
50
50
60
60
Question Video