File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ # Implement Queue using List(Functions)
2+ q = []
3+ def Enqueue ():
4+ if len (q )== size : # check wether the stack is full or not
5+ print ("Queue is Full!!!!" )
6+ else :
7+ element = input ("Enter the element:" )
8+ q .append (element )
9+ print (element ,"is added to the Queue!" )
10+ def dequeue ():
11+ if not q :# or if len(stack)==0
12+ print ("Queue is Empty!!!" )
13+ else :
14+ e = q .pop (0 )
15+ print ("element removed!!:" ,e )
16+ def display ():
17+ print (q )
18+ size = int (input ("Enter the size of Queue:" ))
19+ while True :
20+ print ("Select the Operation:1.Add 2.Delete 3. Display 4. Quit" )
21+ choice = int (input ())
22+ if choice == 1 :
23+ Enqueue ()
24+ elif choice == 2 :
25+ dequeue ()
26+ elif choice == 3 :
27+ display ()
28+ elif choice == 4 :
29+ break
30+ else :
31+ print ("Invalid Option!!!" )
You can’t perform that action at this time.
0 commit comments