0% found this document useful (0 votes)
27 views2 pages

Python Exp4

The document provides examples of three data structures: a stack, a queue, and a linked list. It demonstrates how to manipulate these structures in Python, including appending and popping elements for the stack and queue, and defining a linked list with nodes. Each section includes code snippets and expected outputs for clarity.

Uploaded by

ankurkumar99421
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Python Exp4

The document provides examples of three data structures: a stack, a queue, and a linked list. It demonstrates how to manipulate these structures in Python, including appending and popping elements for the stack and queue, and defining a linked list with nodes. Each section includes code snippets and expected outputs for clarity.

Uploaded by

ankurkumar99421
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Stack :-
stack = []
[Link]('a')
[Link]('b')
[Link]('c')
print("Initial Stack: ")
print(stack)
[Link]()
[Link]()
print("Stack after popping elements: ")
print(stack)

Output :

2. Queue :-
queue = []
[Link]('a')
[Link]('b')
[Link]('c')
print("Initial Queue: ")
print(queue)
[Link]()
[Link]()
print("Queue after popping elements: ")
print(queue)

Output :
3. Linked List :-
class Node:
def __init__(self, dataval_Name):
[Link] = dataval_Name
[Link] = None

class LinkedList:
def __init__(self):
[Link] = None
def listprint(self):
printval = [Link]
while printval is not None:
print([Link])
printval = [Link]
e1 = Node("Mon")
e2 = Node("Tue")
e3 = Node("Wed")
[Link] = e2
[Link] = e3
list = LinkedList()
[Link] = e1
[Link]()

Output :

You might also like