Question
Python :Modify the Sorted Names program that you wrote for exercise #2 so it allows you to search the array for a specific name. My
Python :Modify the Sorted Names program that you wrote for exercise #2 so it allows you to search the array for a specific name.
My sorted names program is:
inp = [] num = int(input(" Enter the number of elements from stdin ")) print " Enter the string values from stdin: " for i in range(int(num)): n = input(num) inp.append(n) print " Entered string values are " print(inp) inp.sort() print " Ascending (alphabetical) order: ", inp
Additional Problem Requirements: Include a binarySearch function that takes input parameters of the array of names, the size of the array, and the name to search. The binarySearch function should return an integer representing the array position of the found search name or -1 if the search name was not found Create a main module as your program start module. This module should create local variables to initialize the array of names, prompt the user for a name to search, and call the binarySearch function with the appropriate arguments. Use the search function return value to display different descriptive messages indicating whether the search was successful or not. o Only an array of 10 names is used o The array of names has already been populated with values o The array of names has already been arranged in increasing alphabetical order
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