[SOLVED] CECS328 Programming assignment 2

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Lab_2-ydghwz.zip (161.2 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (2 votes)

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)

 

 

 

  • Lab_2-ydghwz.zip