Jump Search

Jump Search is another searching algorithm that can be used on sorted collections (arrays or lists). The idea is to reduce the number of comparisons by jumping ahead by fixed steps or skipping some elements in place of searching all elements.

Illustration of Jump Search:

Let’s consider the following array: (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610).

The length of the array is 16. The Jump search will find the value of 55 with the following steps assuming that the block size to be jumped is 4.

  • Jump from index 0 to index 4;
  • Jump from index 4 to index 8;
  • Jump from index 8 to index 12;
  • Since the element at index 12 is greater than 55, we will jump back a step to come to index 8.
  • Perform a linear search from index 8 to get the element 55.

Time Complexity of Jump Search:

  • Time Complexity: O(√n), where “n” is the number of elements in the collection. This makes it more efficient than Linear Search but generally less efficient than Binary Search for large datasets.
  • Auxiliary Space: O(1), as it uses a constant amount of additional space for variables.

Performance Comparison based on Complexity:

linear search < jump search < binary search

Introduction to Searching – Data Structure and Algorithm Tutorial

Searching is the fundamental process of locating a specific element or item within a collection of data. This collection of data can take various forms, such as arrays, lists, trees, or other structured representations.

Introduction to Searching – Data Structure and Algorithm Tutorial

The primary objective of searching is to determine whether the desired element exists within the data, and if so, to identify its precise location or retrieve it. It plays an important role in various computational tasks and real-world applications, including information retrieval, data analysis, decision-making processes, and more.

Similar Reads

Importance of Searching in DSA

Efficiency: Efficient searching algorithms improve program performance. Data Retrieval: Quickly find and retrieve specific data from large datasets. Database Systems: Enables fast querying of databases. Problem Solving: Used in a wide range of problem-solving tasks....

Characteristics of Searching

Understanding the characteristics of searching in data structures and algorithms is crucial for designing efficient algorithms and making informed decisions about which searching technique to employ. Here, we explore key aspects and characteristics associated with searching:...

Searching Algorithms:

Searching Algorithms are designed to check for an element or retrieve an element from any data structure where it is stored....

1. Linear Search:

Linear Search, also known as Sequential Search, is one of the simplest and most straightforward searching algorithms. It works by sequentially examining each element in a collection of data(array or list) until a match is found or the entire collection has been traversed....

2. Binary Search:

Binary Search is defined as a searching algorithm used in a sorted array by repeatedly dividing the search interval in half. The idea of binary search is to use the information that the array is sorted and reduce the time complexity to O(log N)....

3. Ternary Search:

Ternary Search is a searching algorithm that divides the search space into three parts instead of two, as in Binary Search. It is very useful in the case of unimodal functions....

4. Jump Search:

Jump Search is another searching algorithm that can be used on sorted collections (arrays or lists). The idea is to reduce the number of comparisons by jumping ahead by fixed steps or skipping some elements in place of searching all elements....

5. Interpolation Search

Interpolation Search is an efficient searching algorithm for sorted collections of data, such as arrays or lists. It is an improvement over Binary Search, particularly when the data is uniformly distributed....

6. Fibonacci Search

Fibonacci Search is an efficient searching algorithm used for finding a target value in a sorted collection, such as an array or list. It is similar in principle to Binary Search but uses Fibonacci numbers to determine the positions to be compared....

7. Exponential Search

Exponential Search is a searching algorithm designed to find a target value in a sorted collection, such as an array or list. It combines elements of Binary Search and Linear Search to efficiently locate the target, especially when its position is near the beginning of the collection....

Easy Problems on Searching:

Count 1’s in a sorted binary array Ceiling in a sorted array k largest(or smallest) elements in an array Kth smallest element in a row-wise and column-wise sorted 2D array Given an array of of size n and a number k, find all elements that appear more than n/k times....

Medium problems on Searching:

Find a peak element Search an element in a sorted and rotated array Find the minimum element in a sorted and rotated array Find the closest pair from two sorted arrays Allocate Minimum Number of Pages from N books to M students Assign stalls to K cows to maximize the minimum distance between them...

Hard problems on Searching:

Median of two sorted arrays Median of two sorted arrays of different sizes Search in an almost sorted array Find position of an element in a sorted array of infinite numbers Given a sorted and rotated array, find if there is a pair with a given sum Longest Increasing Subsequence Size (N log N)...