circular deque double linked list is not working

class Node:
def init(self,data):
self.data=data
self.next=None
self.prev=None
class MyCircularDeque:

def __init__(self, k: int):
    """
    Initialize your data structure here. Set the size of the deque to be k.

    """
    self.head=None
    self.tail=None
    self.size=k
    self.length=0
    

def insertFront(self, value: int) -> bool:
    """
    Adds an item at the front of Deque. Return true if the operation is successful.
    """
    if(self.length <self.size):
        newNode=Node(value)
        if self.head == None:
            self.head=newNode
            self.tail=self.head
            self.length+=1
            return True
        else:
            newNode.next=self.head
            self.head.prev= newNode
            self.head=newNode
            self.length+=1
            return True
        
   
       
            
    else:
        return False

def insertLast(self, value: int) -> bool:
    """
    Adds an item at the rear of Deque. Return true if the operation is successful.
    """
    if(self.length<self.size):
        
        newNode=Node(value)
        if self.head == None:
            self.head=newNode
            self.tail=self.head
            self.length+=1
            return True
        else:
            self.tail.next= newNode
            newNode.prev=self.tail
            self.tail=newNode
            self.length+=1
            return True
    else:
        return False
            
        
    

def deleteFront(self) -> bool:
    """
    Deletes an item from the front of Deque. Return true if the operation is successful.
    
    """
    if self.length>0:
        
        self.head=self.head.next
        self.length-=1
        return True
    
    else:
        return False

def deleteLast(self) -> bool:
    """
    Deletes an item from the rear of Deque. Return true if the operation is successful.
    """
    
    if self.length>0:
        
        self.tail=self.tail.prev
        self.tail.next = None
        self.length-=1
        return True
    
    else:
        return False
    

def getFront(self) -> int:
    """
    Get the front item from the deque.
    """
    if(self.head!=None):
        return self.head.data
    else:
        return -1

def getRear(self) -> int:
    """
    Get the last item from the deque.
    """
    if(self.head != None):
        return self.tail.data
    else:
        return -1

def isEmpty(self) -> bool:
    """
    Checks whether the circular deque is empty or not.
    """
    if self.length==0:
        return True
    else:
        return False

def isFull(self) -> bool:
    """
    Checks whether the circular deque is full or not.
    """
    if self.length ==self.size:
        return True
    else:
        return False

Your MyCircularDeque object will be instantiated and called as such:

obj = MyCircularDeque(k)

param_1 = obj.insertFront(value)

param_2 = obj.insertLast(value)

param_3 = obj.deleteFront()

param_4 = obj.deleteLast()

param_5 = obj.getFront()

param_6 = obj.getRear()

param_7 = obj.isEmpty()

param_8 = obj.isFull()

Comments (1)