Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PYTHON QUESTIONS There are 10 questions on this homework You should consider writing your programs using file magic sometimes so that the programs you write
PYTHON
QUESTIONS There are 10 questions on this homework You should consider writing your programs using file magic sometimes so that the programs you write in this notebook are automatically stored in an external file, instead of being executed. Then all you have to do is to import the necessary functions and classes to run your test code. For example, consider the code below. %%file assignment.py class Assignment: def _init_( self, name, ident): self.name = name self.ident = ident def _str_( self ): return f"{self.name}: {self.ident:03d}" Writing assignment.py from assignment import Assignment a = Assignment( "Homework", 1) print( a ) Homework: 001 As you see, the first code cell above used %%file assignment.py to store the content of that cell in an external file called assignment.py - Then in the next cell we used an import statement to import what we need to use in our test code. You can always copy and paste code into cells and not use the file magic facility as well. As you know, you have always been asked to never wait for a homework to push you to test all code in the book. In other words, you are expected to enter the code in the book into a file or a notebook and test it to ensure that it works as expected. The first set of questions in this homework simply ask you to do this. Some ask you to provide additional work. Question 1 Test the implementation of the binarySearch() function in Listing 5.4 (page 130) in your book. Demonstrate with several examples that the function behaves as expected. ]: Question 2 Test the implementation of the bubblesort() function in Listing 5.5 (page 134) in your book. Demonstrate with several examples that the function behaves as expected. ]: ]: Question 3 Test the implementation of the selectionsort() function in Listing 5.6 (page 137) in your book. Demonstrate with several examples that the function behaves as expected. Question 4 Test the implementation of the insertionsort() function in Listing 5.7 (page 140) in your book. Demonstrate with several examples that the function behaves as expected. Question 5 Test the implementation of the mergesortedLists() function in Listing 5.9 (page 146) in your book. Demonstrate with several examples that the function behaves as expected : Question 6 Test the implementation of the Bag class in Listing 6.5 (page 166) in your book. Your demonstration must include the iterator for the Bag class! Demonstrate with several examples that the function behaves as expected. . : Question 7 Package the implementation provided in Listing 6.8 on page 171 in your book) for removing a node from a linked list using a tail reference into a function def remove_node( target_value, head, tail ): where target_value specifies the value stored in the node that needs to be removed. The head and tail are references to the first and last nodes in the linked list First, you must build a linked list either using a linked list implementation or manually. Demonstrate with several examples that the function behaves as expected. Duplicating the scenario provided in the book is one possible way to demonstrate that the code works. However, you should think of providing additional examples. Question 8 Package the implementation provided in Listing 6.10 (on page 171 in your book) for inserting a value into a sorted linked list into a function def insert_node( value, head ): where value specifies the value to be stored with the new node and head is the reference to the first node in the linked list. First, you must build a linked list either using a linked list implementation or manually. Demonstrate with several examples that the function behaves as expected. Duplicating the scenario provided in the book is one possible way to demonstrate that the code works. However, you should think of providing additional examplesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started