def maintain_cards(self):
     """This method maintains the deck of cards in a queue
     """
     self.sort_cards()
     cards_in_hand = queue_linked_list.Queue()
     for i in range(0, len(self.deck_of_cards)):
         cards_in_hand.en_queue(i)
def print_card(player_cards):
    """This method displays the distributed cards"""
    players = queue_linked_list.Queue()
    for i in range(4):
        print("\nCards of player {} is :".format(i + 1))
        player = Player(player_cards[i])
        players.en_queue(player)
        players.print_list()
 def print_deck(self):
     """This method prints the deck of cards maintained in the queue
     :return: displays the sorted deck
     """
     hand = queue_linked_list.Queue()
     for q in self.deck_of_cards:
         hand.en_queue(q)
     hand.print_list()
def levelOrderTraversal(rootNode):
    if not rootNode:  # if we reach the end of a branch, stop
        return
    else:
        customQueue = queue.Queue()
        customQueue.enqueue(rootNode)
        while not (customQueue.isEmpty()):
            root = customQueue.dequeue()
            print(root.value.data)
            if (root.value.left is not None):
                customQueue.enqueue(root.value.left)
            if (root.value.right is not None):
                customQueue.enqueue(root.value.right)
Exemple #5
0
def levelOrderTraversal(rootNode):
    if not rootNode:
        return
    else:
        customQueue = queue.Queue()
        customQueue.enqueue(rootNode)
        while not(customQueue.isEmpty()):
            root = customQueue.dequeue()
            print(root.value.data)
            if root.value.left is not None:
                customQueue.enqueue(root.value.left)
            if root.value.right is not None:
                customQueue.enqueue(root.value.right)