class Deque:
    def __init__(self):
        self.items = []
    def isEmpty(self):
        return self.items == []

    def addFront(self,item):
        self.items.append(item)

    def addRear(self,item):
        self.items.insert(0,item)

    def removeFront(self):
        self.items.pop()

    def removeRear(self):
        self.items.pop(0)

in this implementation adding and removing items from the front is O(1) whereas adding and removing from the rear is O(n).

results matching ""

    No results matching ""