Welcome to EssayHotline!

We take care of your tight deadline essay for you! Place your order today and enjoy convenience.

The binary search method is faster than searching all items but has an additional constraint. What is required of a list to use binary search?

Python

ICS 140 Computational Thinking with Programming

Class Exercise 11

Lecture Section

  1. What is the name of the search algorithm that loops over every item in the list to check if it contains the sought item?
  2. The binary search method is faster than searching all items but has an additional constraint. What is required of a list to use binary search?
  3. What does big O notation represent?
  4. Describe the Selection Sort algorithm.
  5. Describe the Insertion Sort algorithm.
  6. Describe the Bubble Sort algorithm.
  7. Describe the Merge Sort algorithm.
  8. For the sort algorithms above, which one will generally be the most efficient as lists grown larger?
  9. In addition to the increase in processing required as list grow, name another resource constraint to watch for.
  10. Coding sorting algorithms requires a way to swap values between 2 places in a list. Choose one of the methods that can be used and write the python code for swapping values below.

 

Coding Search Algorithms

Write python function that implements the sequential and binary search algorithms. Use the provided search_algorithms.py file provided to complete this exercise. In the search_algorithms.py file, you will find some functions already built that will help test out the performance of the algorithms. I have also copied the pseudocode from the assigned reading to help simplify the coding process. Write functions with the names and inputs of the routines in the commented pseudocode.

Note: Some lines of the pseudocode are not relevant to python. For example, there is no end if statement like there is in other programming languages. Lines like this can be deleted or commented out.

The output should like something like this:

Smaller lists will be very close in speed. If we test out a larger number, we should see the binary search pull away with dramatically.

Once you have coded the functions, paste the code for the 2 functions in their designated area below and take a few screenshots of your program running with different sizes of lists similar to the screenshots above.

 

© 2024 EssayHotline.com. All Rights Reserved. | Disclaimer: for assistance purposes only. These custom papers should be used with proper reference.