Home Page class 12 @ Python

CBSE Class 12 : Data Structures

Introduction to Data Structures

CBSE Class 12 : Searching

Creation And Traversal
What is Searching?
Linear/Sequential Search
Binary Search
Insertion Of Element
Deletion Of Element

CBSE Class 12 : Sorting

What is sorting?
Bubble Sort
Selection Sort
Insertion Sort

CBSE Class 12 : Stacks

Stacks
Applications of Stacks
Implementation of Stacks

CBSE Class 12 : Queues

Queues
Applications Of Queues
Implementation of Queues

Class 12 Data Structures | Queues 9

Queues
=======
1.
Write a program to perform insert and delete operations on a Queue containing Members details as given in the following definition of item node:
member no integer
member name string
age integer

2.
Write a program to perform insert and delete operations on a Queue containing product details as given in the following definition of product node:

product no integer
product name string
product price float
product qty integer
3.
Write a program to perform insert and delete operations on a Queue containing mobile details as given in the following definition of mobile node:

mobile no integer
customer name string
mobile company string
mobile bal integer

#queue implementation using functions
#program to create a queue of product(pno,pname,qty,rate).
"""
Add product
delete product
display details
"""
product=[]
def Add_product():
        pno=input("Enter product no.  ")
        pname=input("Enter name of the product ")
        qty=int(input("Enter the quantity "))
        rate=float(input("enter the price "))
        p=(pno,pname,qty,rate)
        product.append(p)
def del_product():
        if(product==[]):
                print("Underflow / product queue in empty")
        else:
                pno,pname,qty,rate=product.pop(0)
                print("poped element is ")
                print("product no. : ",pno,": product name: ",pname,": Quatity: ",qty,": Rate: ",rate)
def traverse():
        if not (product==[]):
                n=len(product)
                for i in range(0,n):
                        print(product[i])
        else:
                print("Empty , No details to display")
while True:
        print("1. Add details of product")
        print("2. delete details of product")
        print("3. Display details of product")
        print("4. Exit")
        ch=int(input("Enter your choice "))
        if(ch==1):
                Add_product()
        elif(ch==2):
                del_product()
        elif(ch==3):
                traverse()
        elif(ch==4):
                print("End")
                break
        else:
                print("Invalid choice")