repl.it
Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
q = []
front = 0
rear = -1
size = 0
maxSize = 5

def isFull(qsize,qmaxsize):
  return (qsize == qmaxsize)

def isEmpty(qsize):
  return (qsize == 0)

def enQueue(item):
  global front
  global rear
  global size
  global maxSize
  if isFull(size,maxSize) == True:
    print("queue full")
  elif rear == -1:
    q[0] = item
    rear = (rear + 1) % maxSize
    size += 1
  else:
    q[rear + 1] = item
    rear = (rear + 1) % maxSize
    size += 1

def deQueue():
  global front
  global size
  if size == 0:
    print("Queue empty")
  else:
    item = q[front]
    front = (front + 1) % maxSize
    size -= 1
    return(item)
Fetching token
?