
Searches – Directed Lab Work
1. When an object does not occur in an array, a sequential search for it must examine the entire
array. If the array is sorted, you can improve the search by using the approach described in
Exercise 2. A jump search is an attempt to reduce the number of comparisons even further.
Instead of examining the n objects in the array a sequentially, you look at the elements a[j],
a[2j], a[3j], and so on, for some positive j < n. If the target t is less than one of these objects,
you need to search only the portion of the array between the current object and the previous
object. For example, if t is less than a[3j] but is greater than a[2j], you search the elements
a[2j + 1], a[2j + 2], . . ., a[3j - 1] by using the method in Exercise 2 on the textbook’s page
544. The implementation should take care of the case when t > a[k × j], but (k + 1) × j > n.
Devise an
Then, using
⌈√n⌉
as the value of j, implement the jump search. Add more test cases in the main method.
Modify and save the file as JumpSearchYourlastname.java.
2. An interpolation search assumes that the data in an array is sorted and uniformly distributed.
Whereas a binary search always looks at the middle item in an array, an interpolation search
looks where the sought-for item is more likely to occur. For example, if you searched your
telephone book for Victoria Appleseed, you probably would look near its beginning rather
than its middle. And if you discovered many Appleseeds, you would look near the last
Appleseed. Instead of looking at the element a[mid] of an array a, as the binary search would,
an interpolation search examines a[index], where
p = (desiredElement - a[first]) / (a[last] - a[first])
index = first + [(last – first) × p]
Implement an interpolation search of an array. For particular arrays, compare the outcomes
of an interpolation search and of a binary search. Consider arrays that have uniformly
distributed entries and arrays that do not. Modify and save the file as
SearchComparerYourlastname.java.

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps

- The contents of the array below represent a BST (Binary Search Tree). What would be the contents of the array after 30 is deleted. Briefly explain how 30 would be deleted. Use an X to represent any empty spots in the array. 30 2050 10 25 40 60arrow_forwarduse the RUSTarrow_forwardGiven an array, find the next greater element for each element in the array, ifavailable. If not available, print the element itself. The next greater element y for anelement x in the array is the first element that is greater than x and occurs on its rightside. The next greater element of the right most element in an array is the elementitself.Example: Given A = [ 6 8 4 3 9] the next greater element listB = [8 9 9 9 9].arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





