HyperAIHyperAI

Command Palette

Search for a command to run...

Bi-partition

Date

6 years ago

definition

The binary search method is an algorithm whose input is an ordered list of elements.

If the element being searched is contained in the list, binary search returns its position; otherwise it returns null.

Basic idea

  1. This method is suitable when the amount of data is large.
  2. When using binary search, the data must be sorted
  3. Assuming the data is sorted in ascending order, for a given value key, start comparing from the middle position mid of the sequence:
  4. If the value of arr[mid] at the current position is equal to key, the search is successful;
  5. If key is less than the current position value arr[mid], then search for arr[low,mid-1] in the first half of the sequence;
  6. If key is greater than the current position value arr[mid], continue searching for arr[mid+1,high] in the second half of the sequence until it is found.

Time Complexity:

Build AI with AI

From idea to launch — accelerate your AI development with free AI co-coding, out-of-the-box environment and best price of GPUs.

AI Co-coding
Ready-to-use GPUs
Best Pricing
Get Started

Hyper Newsletters

Subscribe to our latest updates
We will deliver the latest updates of the week to your inbox at nine o'clock every Monday morning
Powered by MailChimp
Bi-partition | Wiki | HyperAI