Giter Site home page Giter Site logo

binary-search-lab's Introduction

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!

binary-search-lab's People

Contributors

kwahalf avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.