Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python Write a function generate_binary_numbers that takes a number N as a parameter and returns a queue of binary number strings from 1 to N

image text in transcribedimage text in transcribed

python

Write a function generate_binary_numbers that takes a number N as a parameter and returns a queue of binary number strings from 1 to N without using any built-in or library functions like bin(). In fact, your solution should not use any built-in or library functions other than those in the Stack and Queue classes provided. The front of the queue begins @ '1'. If N is too small, return an empty queue.

fix generate_binary.py to pass generate_binary_test.py

6 00 generate_binary_test.py 1 # TEST FILE FOR GENERATE BINARY NUMBERS 2 # DO NOT MODIFY 3 4 from Queue import Queue 5 from generate_binary import generate_binary_numbers 6 7 def test_binary_0(): assert generate_binary_numbers (0) == Queue ([]) 9 10 def test_binary_1(): 11 assert generate_binary_numbers(1) == Queue (['1']) 12 13 def test_binary_2(): assert generate_binary_numbers (2) == Queue (['1', 1 '10']) 15 16 def test_binary_3(): 17 assert generate_binary_numbers (3) == Queue ('l', '10', '11'] ) 18 19 E def test_binary_4(): 20 assert generate_binary_numbers (4) == Queue ( ['1', '10', '11', '100'] ) 21 22 E def test_binary_5(): 23 assert generate_binary_numbers (5) == Queue( ['1', '10', '11', '100', '101'] ) 14 generate_binary.py # ASSIGNMENT: Technical HW: Stacks & Queues 5 6 7 def 00 9 Edef main(): 10 generate_binary_numbers (2) 11 generate_binary_numbers (3) 12 generate_binary_numbers (6) 13 14 15 # Don't run main on import 16 if __name_ == "__main__": 17 main() ( 18 19

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

Psychological, financial, and career counseling.

Answered: 1 week ago