0% found this document useful (0 votes)
10 views1 page

Ha1 Sorting, Searching

The document outlines a home assignment for the Data Structure & Algorithm Laboratory at United International University. It consists of two main tasks: modifying a Binary Search operation to delete or insert values in a sorted array, and adding a menu option to find the square root of a number using binary search. Students are instructed to ensure their code handles edge cases and to submit a single code file without additional files.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Ha1 Sorting, Searching

The document outlines a home assignment for the Data Structure & Algorithm Laboratory at United International University. It consists of two main tasks: modifying a Binary Search operation to delete or insert values in a sorted array, and adding a menu option to find the square root of a number using binary search. Students are instructed to ensure their code handles edge cases and to submit a single code file without additional files.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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.

You might also like