Ejemplo n.º 1
0
class Stack:
    #Creating empty linked list to store stack
    __llist = None

    def __init__(self):
        self.__llist = Linkedlist()

    def Push(self, data):

        self.__llist.add(data)
        return

    def Pop(self):

        return self.__llist.delete(self.__llist.size())

    def Peek(self):

        return self.__llist.delete(self.__llist.size(), False)

    def print(self):

        self.__llist.print_linked_list()
Ejemplo n.º 2
0
class Queue:
    #Creating empty linked list to store stack
    __llist = None

    def __init__(self):

        self.__llist = Linkedlist()

    def Add(self, data):

        self.__llist.add(data)
        return

    def Remove(self):

        return self.__llist.delete(1)

    def Peek(self):

        return self.__llist.delete(1, False)

    def print(self):

        self.__llist.print_linked_list()