United International University
Dept. of Computer Science & Engineering
Data Structure & Algorithm Laboratory I (CSE 2216)
Home Assignment 1
[Q1] Download the week 2 code and execute it to verify its functionality. Your task is to modify
the Binary Search operation as follows:
1. If the given key value is found in the array: Delete the value from its current position
and shift the remaining elements to fill the gap.
2. If the given key value is not found: Insert the value into its correct position in the
already sorted array, ensuring the array remains sorted after the insertion.
Ensure that your modifications maintain the integrity of the sorted array and handle edge cases
appropriately. Test your updated code with various inputs to confirm its correctness.
[Q2] Add another new menu option: "Find Square Root." On the same code.
• The program should prompt the user to enter a number.
• Implement the function float square_root(float val) to calculate the square root using
the binary search method, with a tolerance of 0.005.
• Ensure that your implementation correctly handles edge cases, such as:
→ When the input is 0
→ When the input is negative
→ When the input is a perfect cube
Submission Guideline:
Submit a single code file. There is no need to zip the folder or include additional files.