Skip to content

alexngari/binary-search-lab

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Binary Search

Firstly you are to create three functions, as prototypes to the Array class to return the following:

toTwenty() returns [1, 2, 3 . . . 20]

toForty() returns [2, 4, 6 . . . 40]

toOneThousand() returns [10, 20, 30 . . . 1000]

Once you are done, create another prototyped function called search, it will take just one argument which is the number you are to find. The search functon should return an object, which contains

.count, the number of times you function iterated to find the index of the number in question .index, the index of the number in question .length, the length of the original array The .search function should implement the binary search algorithm, each time you iterate, you should increase the count, to test how efficient your implementation is.

How to Run this Lab

Fork this Repository, then Clone forked repository Open the file named binarySerch.py and start coding

Notes

Prior understanding of python classes, and data types will be required to complete this exercise.

Remember that passing code is just the first step. The goal is to work towards a solution that is as readable and expressive as you can make it.

Please make your solution as general as possible. Good code doesn't just pass the test suite, it works with any input that fits the specification.

Have fun!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%