Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

are logN and (lognN) same

O(1) (in the worst case): Given the page that a business's name is on and the business name, find the phone number.

O(1) (in the average case): Given the page that a person's name is on and their name, find the phone number.

O(log n): Given a person's name, find the phone number by picking a random point about halfway through the part of the book you haven't searched yet, then checking to see whether the person's name is at that point. Then repeat the process about halfway through the part of the book where the person's name lies. (This is a binary search for a person's name.)

O(n): Find all people whose phone numbers contain the digit "5".

O(n): Given a phone number, find the person or business with that number.

O(n log n): There was a mix-up at the printer's office, and our phone book had all its pages inserted in a random order. Fix the ordering so that it's correct by looking at the first name on each page and then putting that page in the appropriate spot in a new, empty phone book.
Comment

PREVIOUS NEXT
Code Example
Python :: sort list in python 
Python :: python get file ending 
Python :: global var in python 
Python :: numpy insert 
Python :: how to add badges to github repo 
Python :: numpy.sort 
Python :: python math packege power e 
Python :: python list append() 
Python :: web scraping with selenium 
Python :: python re.split() 
Python :: gui button in tkinter color 
Python :: python print in the same line 
Python :: get array from h5py dataset 
Python :: selenium wait until 
Python :: telegram telethon get new user details 
Python :: truncatechars django 
Python :: iterate through dict with condition 
Python :: map numpy array 
Python :: python import statement 
Python :: string representation of date time 
Python :: add all elements of list to set python 
Python :: Routes In Django 
Python :: strip function in python 
Python :: how to find ascii value by python 
Python :: python list extend 
Python :: Python NumPy expand_dims Function Syntax 
Python :: django filter values with e and operator 
Python :: python read array line by line 
Python :: python all 
Python :: import from parent module package python 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =