[Lab Evaluation] Implementation of ADT


Submit solution

Points: 10 (partial)
Time limit: 0.5s
Memory limit: 12M

Author:
Problem type
Allowed languages
Python

Python ADT

Implement basic operations on three different data structures: Stack, Queue, and Doubly Linked List.

Instructions:
Stack Operations:
  1. Read noofpush elements and push them onto the stack using the push method.
  2. Pop noofpop elements from the stack using the pop method.
  3. Print the popped items and the top item using the top method.
Queue Operations:
  1. Read noofenqueue elements and enqueue them using the enqueue method.
  2. Dequeue noofdequeue elements using the dequeue method.
  3. Print the dequeued items and the front item using the front method.
Doubly Linked List Operations:
  1. Read noofappend elements and append them to the doubly linked list using the append method.
  2. Display the doubly linked list using the display method.
Main Menu:

Implement a menu-driven system with the following options:

  • 1 for Stack Operations
  • 2 for Queue Operations
  • 3 for Doubly Linked List Operations
  • 4 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

There are no comments at the moment.