yeasir007

Thursday, November 09, 2017

Implement Queue without STL in C++ and Java Language

Implement Queue without STL in C++ and Java Language
Queue: A queue is a container of objects that are inserted and removed according to first-in-first-out(FIFO) principle.

[Problem]
Enqueue the given N (2 <=N <=100) numbers in order into a queue, then dequeue each and print on the screen.

[Input]
The first input line contains the number of test cases,T.
The next line contains the number of data input.
Then,integer data will be listed.

[Output]
For each given test case,print each queue.

Input                                                       OUTPUT
2 //Test case                                            #1 1 2 3 4 5
5 //Data size                                           #2 5 4 3 2 1
1 2 3 4 5
5
5 4 3 2 1

Stack Implementation without STL in C++ and Java language & Runtime Stack Re-Initialization

Stack Implementation without STL in C++ and Java language & Runtime Stack Re-Initialization
Stack: A stack is a container of objects that are inserted(push) and removed (pop) according to the last-in-first-out(LIFO) principle.

[Problem]
Insert(Push) the given N (2 <=N <=100) numbers in order into a stack, then pop each and print on the screen.

[Input]
The first input line contains the number of test cases,T.
The next line contains the number of data input.
Then,integer data will be listed.

[Output]
For each given test case,print each stack.

Input                                                       OUTPUT
2 //Test case                                            #1 5 4 3 2 1
5 //Data size                                           #2 1 2 3 4 5
1 2 3 4 5
5
5 4 3 2 1