Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
3 views3 pages

ADTS

The document outlines a programming exercise related to queues and stacks, specifically detailing the implementation of a queue using an array in Python. It includes code snippets for enqueueing and dequeueing operations, along with user input handling. The document is associated with the Megz Tech Team and provides contact information.

Uploaded by

magdymark87
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)
3 views3 pages

ADTS

The document outlines a programming exercise related to queues and stacks, specifically detailing the implementation of a queue using an array in Python. It includes code snippets for enqueueing and dequeueing operations, along with user input handling. The document is associated with the Megz Tech Team and provides contact information.

Uploaded by

magdymark87
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
You are on page 1/ 3

Instagram: @megztechteam 1

CS A2
MEGZ
Ch. 23 Queues & Stacks
Question 3 Evidence
Student Name:

School:

Year:

Megz Tech Team +2 01122884770


Instagram: @megztechteam 2

Question 3
Part 3(a)
# declare QueueArray :Array[0 to 9]as string
# declare HeadPointer :integer
# declare TailPointer :integer
# decalre NumberItems :integer
QueueArray=[0 for i in range(10)]
HeadPointer=0
TailPointer=0
NumberItems=0
Part 3(b)
def Enqueue(DataToAdd):
global TailPointer
global NumberItems
if NumberItems==10 :
return False
QueueArray[TailPointer]=DataToAdd
if TailPointer>=9 :
TailPointer=0
else:
TailPointer=TailPointer+1
NumberItems=NumberItems+1
return True
Part 3(c)
def Dequeue():
global HeadPointer
if NumberItems>0:
Item=QueueArray[HeadPointer]
if HeadPointer==10:
HeadPointer=0
HeadPointer=HeadPointer+1

return Item
else:
return False
Part 3(d)(i)
for i in range(11):
item=input("plz enter a Char")
isEnqueue = Enqueue(item)
if isEnqueue:
print("value added successful")
else:
print("faild")

Dequeue()
print(Item)
Dequeue()
print(Item)
Part 3(d)(ii)

Megz Tech Team +2 01122884770


Instagram: @megztechteam 3

Megz Tech Team +2 01122884770

You might also like