• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
July 04, 2022 |810 Views
Sparse search
  Share   Like
Description
Discussion

Given a sorted array of strings which is interspersed with empty strings, write a method to find the location of a given string.
Examples: 
 

Input : arr[] = {"for", "geeks", "", "", "", "", "ide", 
                     "practice", "", "", "", "quiz"}
         x = "geeks"
Output : 1

If there were no empty strings then we could’ve simply performed binary search. We can still use Binary Search with a little modification. If our mid is empty we just have to move mid to closest Non-Empty string.


Sparse search : https://www.geeksforgeeks.org/sparse-search/

Read More