[SOLVED] CECS328-Lab 2

20.99 $

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

Description

Rate this product

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

and returns โŒˆโˆš๐‘โŒ‰.

Example 1: input: 28

Output: 6

ย 

Example 2: input: 16

Output: 4

ย 

(Note:

  • You are NOT allowed to use the built-in sqrt function in your code โ€ข Do NOT use any type of array in your code)

ย 

Question 2. Given a sorted array of n distinct numbers where the range of the numbers are between 0 to m and m > n (m is given by user). Find the smallest missing number.

Example 1: input: a = [0, 1, 3, 6, 8, 9], m = 10

Output: 2

ย 

Example 2: input: a = [2, 5, 7, 11], m = 15

Output: 0

ย 

Example 3: input: a = [0, 1, 2, 3, 4], m = 8

Output: 5

ย 

Example 4: input: a = [12], m = 13

Output: 0

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.