[SOLVED] CECS328 Programming assignment 2

30.00 $

Programming resource
Digital learning resource
Category:
โœ“ Practical programming resource
โœ“ Suitable for guided study and reference
โœ“ Tutor guidance available when needed

Description

5/5 - (1 vote)

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)

 

 

 

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.