[Lab Evaluation] Implementation of ADT
Submit solution
Python
Points:
10 (partial)
Time limit:
0.5s
Memory limit:
12M
Author:
Problem type
Allowed languages
Python ADT
Implement basic operations on three different data structures: Stack, Queue, and Doubly Linked List.
Instructions:
Stack Operations:
- Read
noofpush
elements and push them onto the stack using thepush
method. - Pop
noofpop
elements from the stack using thepop
method. - Print the popped items and the top item using the
top
method.
Queue Operations:
- Read
noofenqueue
elements and enqueue them using theenqueue
method. - Dequeue
noofdequeue
elements using thedequeue
method. - Print the dequeued items and the front item using the
front
method.
Doubly Linked List Operations:
- Read
noofappend
elements and append them to the doubly linked list using theappend
method. - Display the doubly linked list using the
display
method.
Main Menu:
Implement a menu-driven system with the following options:
1
for Stack Operations2
for Queue Operations3
for Doubly Linked List Operations4
to Exit the program
Testcase
Input 1
1
3
24
44
18
2
4
Output 1
Stack Operations:
Item Pushed into Stack: 24
Item Pushed into Stack: 44
Item Pushed into Stack: 18
Popped item: 18
Popped item: 44
Top item: 24
Exiting the program.
Input 2
2
4
Ram
Anu
Ammu
Raj
2
4
Output 2
Queue Operations:
Item Enqueued into Queue: Ram
Item Enqueued into Queue: Anu
Item Enqueued into Queue: Ammu
Item Enqueued into Queue: Raj
Dequeued item: Ram
Dequeued item: Anu
Front item: Ammu
Exiting the program.
Input 3
3
5
3.14159
1.41421
1.44224
2.71828
0.69777
4
Output 3
Doubly Linked List Operations:
Item Appended into DLL: 3.14159
Item Appended into DLL: 1.41421
Item Appended into DLL: 1.44224
Item Appended into DLL: 2.71828
Item Appended into DLL: 0.69777
Doubly Linked List:
3.14159 <-> 1.41421 <-> 1.44224 <-> 2.71828 <-> 0.69777 <-> None
Exiting the program.
Input 4
1
3
24
44
18
3
4
Output 4
Stack Operations:
Item Pushed into Stack: 24
Item Pushed into Stack: 44
Item Pushed into Stack: 18
Popped item: 18
Popped item: 44
Popped item: 24
Stack is empty.
Exiting the program.
Input 5
2
3
Ram
Anu
Raj
4
4
Output 5
Queue Operations:
Item Enqueued into Queue: Ram
Item Enqueued into Queue: Anu
Item Enqueued into Queue: Raj
Dequeued item: Ram
Dequeued item: Anu
Dequeued item: Raj
Queue is empty.
Queue is empty.
Exiting the program.
Comments