Run Code  | API  | Code Wall  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

binary_search_30-Seconds-of-C++

Language: Layout:
+ ] Compiler args + ] Show input
Compilation time: 0.82 sec, absolute running time: 0.07 sec, cpu time: 0.01 sec, memory peak: 3 Mb, absolute service time: 0,9 sec 
edit mode |  history
The array is : 1 5 8 9 6 7 3 4 2 0 

Let's say we want to search for 2 in the array
So, we first sort the array

The array after sorting is : 0 1 2 3 4 5 6 7 8 9 

Now, we do the binary search
Element found in the array

Now, say we want to search for 10
Element not found in the array

    
                
λ
.NET NoSQL database for rapid development