Question
Trace three searches by hand on the following datasets. Unsorted Data Set: 5, 2, 12, 7, 3, 9, 8, 6 Sorted Data Set: 3, 5,
Trace three searches by hand on the following datasets.
Unsorted Data Set: 5, 2, 12, 7, 3, 9, 8, 6
Sorted Data Set: 3, 5, 8, 9, 12, 14, 18, 19, 21, 23, 24, 26
To trace a linear/sequential search, list each array index that is visited.
For the linear/sequential search, use the "optimized" versions.
This means you will end the search when the target is found.
For sorted lists, you will also end the search once you know the target cannot be found.
To trace a binary search, list the value of first, last, and mid for each pass through the method.
Trace 1:
Trace the sorted data set using a linear/sequential search (optimized for sorted data).
Sorted Data Set: 3, 5, 8, 9, 12, 14, 18, 19, 21, 23, 24, 26
Search target: 15
To trace a linear search, list each array index that is visited.
Trace 2:
Trace the sorted data set using a binary search.
Sorted Data Set: 3, 5, 8, 9, 12, 14, 18, 19, 21, 23, 24, 26
Search target: 23
To trace a binary search, list the value of first, last, and mid for each pass through the method.
Trace 3:
Trace the sorted data set using a binary search.
Sorted Data Set: 3, 5, 8, 9, 12, 14, 18, 19, 21, 23, 24, 26
Search target: 15
To trace a binary search, list the value of first, last, and mid for each pass through the method.
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