Question
Unit 4 Assignment 5: Coding Project using C# Binary Search Scenario Use the same integer array named partNumbers that you used for task 3. Sort
Unit 4 Assignment 5: Coding Project using C#
Binary Search
Scenario
Use the same integer array named partNumbers that you used for task 3. Sort the array in ascending order.
1065, 1095, 1075, 1055, 1056, 1090, 1098, 1088, 1097, and 1078.
Java: use Array.sort()
C#: use Array.Sort()
PHP: use sort()
Write code that asks the user to enter two part numbers. For C#, use console input.
Implement a binary tree search function called binarySearch() to search the array for the part number entered. Use the following variable names: use a variable named x to represent the array passed to the function and an integer variable named key to represent the key being searched for.
Pass to this function the array partNumbers, the lower array index, the upper array index, and the variable key.
Define an integer variable in the binarySearch function called position. Use this variable for the value of the index of the middle position.
If the part number is found, display to the console the index that part number is in.
Depending on whether or not the part number exists, display to the console that the part number is or is not in stock.
To test your program and get the expected output, enter 1088 for the first value and 1067 for the second value.
Expected Output
The part number was found at index 5.
1088 is in stock.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started