Generate a random ordered list of integers

Assignment Help Python Programming
Reference no: EM132107409

Programming Exercise .

In Python, the use the binary search functions given(recursive and iterative). Generate a random ordered list of integers and do a benchmark analysis. What are your results ? Explain the results.

Recursive:

def binarySearch(alist, item):
if len(alist) == 0:
return False
else:
midpoint = len(alist)//2
if alist[midpoint]==item:
return True
else:
if item<alist[midpoint]:
return binarySearch(alist[:midpoint],item)
else:
return binarySearch(alist[midpoint+1:],item)

iterative:

def binarySearch(alist, item):
first = 0
last = len(alist)-1
found = False

while first<=last and not found:
midpoint = (first + last)//2
if alist[midpoint] == item:
found = True
else:
if item < alist[midpoint]:
last = midpoint-1
else:
first = midpoint+1

return found

Reference no: EM132107409

Questions Cloud

How is the required payment amount calculated : Generally, when someone takes out a mortgage or other non-revolving loan, each payment is the same except for the final payment.
Downfall to health care when using social media platforms : What do you see as a downfall to health care when using social media platforms?
How does walmart measure quality : How does Walmart measure quality? How does Walmart measure customer satisfaction? What do you think the business can do in order to improve their CRM strategy?
Write a c program that converts base 10 numbers : Using algorithm given in the class write a C program (or in any programming language) that takes any number in any bas.
Generate a random ordered list of integers : In Python, the use the binary search functions given(recursive and iterative). Generate a random ordered list of integers and do a benchmark analysis.
Compare and contrast the brand you like or use : Compare and contrast the brand you like or use to a different brand in the same product class.
Persuade customers to buy the wrong products : Do marketers persuade customers to buy the "wrong" products? Why or why not? Explain your logic.
How to create an output label and associate : How to create an output label and associate it with a StringVar object. Name your Python program name_address_GUI.py
Bulbs to burn out before they are replaced : After how many hours should all of the bulbs to be replaced if no more than 4% of the bulbs to burn out before they are replaced.

Reviews

Write a Review

Python Programming Questions & Answers

  Function should return a dictionary

Write a function numOccur(s), where s is a string; the function should return a dictionary whose keys are the 26 ascii letters abcdefghijklmnopqrstuvwxyz

  Write the pseudo code and then code it in python

Write the pseudo code and then code it in Python. Write a function that has number of tosses as an input parameter. As usual, screen copy your code and results.

  Practical laboratory exercises to automate business process

ITECH1100 Understanding the Digital Revolution - Story Resurrection - you will use skills acquired through practical laboratory exercises

  Q1there has been tremendous development in the arid west of

q1there has been tremendous development in the arid west of the united states over the past few decades creating

  Create a python program for managing media check-out

Create a python program for managing media check-out/check-in with members - Store a list of checked out items for a member and create a method to display it

  Calculate the problem and stop after the condition

Write a program that will calculate the problem and stop after the condition has been met.

  Creating an application that simulates a banking interface

ITECH1400 - Foundations of Programming Assignment - FedUni Banking. Creating an application that uses a GUI that simulates a simple banking interface

  Investigate mortality levels of infants and babies

ICT702 - Which countries have a high rate of child deaths and which countries have low rates? Are there connections between child mortality rates

  Modify your code to ask the user for the id of a restaurant

Copy check1.py to check2.py and continue to work on check2.py. Modify your code to ask the user for the id of a restaurant between 1 and 155 (humans don't need to know about list ids starting at 0).

  Creates and returns a tuple containing details of employee

CE151 - creates and returns a tuple containing details of the employee specified by the string. The string should be assumed to have the format

  How does the given change your programming capabilities

CS 192- Considering the lessons on menu logic and the use of arrays and loops, how does this change your programming capabilities? What kind of programs can you now create utilizing these powerful programming tools?

  Simulate a simple banking interface

ITECH1400 – Foundations of Programming - Assignment – FedUni Banking - The ability to view the balance of the bank account and to deposit and withdraw virtual

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd