Programming assignment 2.

In this assignment, we will apply the idea of Binary Search algorithm to solve the below questions.

Note: The running time of your solutions should be O(logn).

Question 1. Implementing the square root function: Write a function that asks a user to enter an integer N

and returns ⌈√𝑁⌉.

(Note: You are NOT allowed to use the predefined sqrt function in the programming language you are

using)

Question 2. Ask the user to enter a random binary array having the first K numbers equal to 0 and the rest

equal to 1. Write a function to find the position of K that splits the 0s and 1s.

(Example: input: a = [ 0 0 0 1 1] ➔ output: K = 3)