Answered step by step
Verified Expert Solution
Question
1 Approved Answer
needs to be completed in python. please show screenshots of your code and you running the code. Objectives: Review programming in a high-level language Implement
needs to be completed in python. please show screenshots of your code and you running the code.
Objectives: Review programming in a high-level language Implement linear search and binary search algorithms Evaluate the performance of linear and binary search Assignment: 1. Implement a method that will search a given array using the linear search algorithm 2. Implement a method that will search a given array using a recursive binary search algorithm 3. Write a driver program to test the methods implemented in questions 1-2. Note that you have to sort the input array before using the binary search algorithm, you can use any sorting method available 4. Test the program for array sizes N -16, 32, 64, 128, 256, 512, 1024, 2048, ....... 2. Initialize the array with random numbers between the ranges 1 through N and use the same array for testing linear search and binary search. Remember to sort the array before using binary search. Use a text file with 1,000 random numbers in the range I through 2 as the search keys. Compare the execution time for linear search and binary search. Include the time taken for sorting with the binary search time you have to sort only once for each array size). Use a table or plot to summarize the results and document your observations and explanations in the report. input_100_-675989818.txt 4 50 34 40 22 54 94 394 38 895 0 36 54 54 81 30 24 98 12 25 430 52 52 30 22 33 70 90 57 09 53 13 64 74 18 37 36 73 76 15 1 93 69 77 81 29 78 14 45 67 1 0 41 60 63 74 1675 75 36 49 68 S 67 29 15 84 47 77 40 80 24 61 25 7 85 83 81 47 10 39 22 72 87 64 92 27 50 69 12 54 23 85 38 75 73 94 Objectives: Review programming in a high-level language Implement linear search and binary search algorithms Evaluate the performance of linear and binary search Assignment: 1. Implement a method that will search a given array using the linear search algorithm 2. Implement a method that will search a given array using a recursive binary search algorithm 3. Write a driver program to test the methods implemented in questions 1-2. Note that you have to sort the input array before using the binary search algorithm, you can use any sorting method available 4. Test the program for array sizes N -16, 32, 64, 128, 256, 512, 1024, 2048, ....... 2. Initialize the array with random numbers between the ranges 1 through N and use the same array for testing linear search and binary search. Remember to sort the array before using binary search. Use a text file with 1,000 random numbers in the range I through 2 as the search keys. Compare the execution time for linear search and binary search. Include the time taken for sorting with the binary search time you have to sort only once for each array size). Use a table or plot to summarize the results and document your observations and explanations in the report. input_100_-675989818.txt 4 50 34 40 22 54 94 394 38 895 0 36 54 54 81 30 24 98 12 25 430 52 52 30 22 33 70 90 57 09 53 13 64 74 18 37 36 73 76 15 1 93 69 77 81 29 78 14 45 67 1 0 41 60 63 74 1675 75 36 49 68 S 67 29 15 84 47 77 40 80 24 61 25 7 85 83 81 47 10 39 22 72 87 64 92 27 50 69 12 54 23 85 38 75 73 94Step 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