# Problem

```
def binary_search(arr, num):
low = 0
high = len(arr) - 1
while low <= high:
mid = (low + high) // 2
if arr[mid] == num:
return True
elif arr[mid] < num:
low = mid + 1
```

# Solution

Input Size | Steps |
---|---|

4 | 2 |

8 | 3 |

16 | 4 |

### How does the running time increase w.r.t the input?

The running time's rate of increase is $log_2N$. The number of steps reflects how many times the input size can be divided by 2.

### What is the time complexity?

$O(logN)$

##### This workbook was created by Jad and Rayan Slim. Feel free to explore some of their courses:

##### The Complete Java Development Bootcamp

##### The Complete Spring Boot Development Bootcamp – Become a Java Web Developer

Feedback Summary

0.0

0 students

5

0%

4

0%

3

0%

2

0%

1

0%

Written Reviews

There are no written reviews yet.