You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def produce_binary_numbers(n):
numbers_queue = Queue()
numbers_queue.enqueue("1")
for i in range(n):
front = numbers_queue.front()
print(" ", front)
numbers_queue.enqueue(front + "0")
numbers_queue.enqueue(front + "1")
numbers_queue.dequeue()
Proposed below:
def produce_binary_numbers(n):
numbers_queue = Queue()
numbers_queue.enqueue("1")
i = 0
while i < n//2 and not numbers_queue.is_empty():
i+=1
front = numbers_queue.dequeue()
print(front)
numbers_queue.enqueue(front + "0")
numbers_queue.enqueue(front + "1")
while not numbers_queue.is_empty() and i<n:
print(numbers_queue.dequeue())
i+=1
The text was updated successfully, but these errors were encountered:
https://github.com/codebasics/data-structures-algorithms-python/blob/master/data_structures/6_Queue/Exercise/binary_numbers.py
Issue:
Proposed below:
The text was updated successfully, but these errors were encountered: