Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write a F# program to implement jump search #5259

Open
Tracked by #5253
harshraj8843 opened this issue Jan 14, 2024 · 4 comments
Open
Tracked by #5253

Write a F# program to implement jump search #5259

harshraj8843 opened this issue Jan 14, 2024 · 4 comments
Assignees
Labels
F# f-sharp related good first issue Good for newcomers program triage Waiting for review

Comments

@harshraj8843
Copy link
Contributor

Description

Write a F# program to implement jump search

Like Binary Search, Jump Search is a searching algorithm for sorted arrays. The basic idea is to check fewer elements (than linear search) by jumping ahead by fixed steps or skipping some elements in place of searching all elements.

For example, suppose we have an array arr[] of size n and block (to be jumped) size m. Then we search at the indexes arr[0], arr[m], arr[2m]…..arr[km] and so on. Once we find the interval (arr[km] < x < arr[(k+1)m]), we perform a linear search operation from the index km to find the element x.

Pseudocode

procedure jump_search
   A ← sorted array
   n ← size of array
   x ← value to be searched

   Set block size = √n

   while A[min(block size, n)-1] < x do
      prev = block size
      block size = block size + √n
      if prev >= n
         return not found
         
   end while
   
   while A[prev] < x do
      prev = prev + 1
      
      if prev == min(block size, n)
         return not found
         
   end while
   
   if A[prev] == x
      return prev
      
   return not found
end procedure

Example

list = [1,2,3,4,5]
value = 4

Output : 3
How to contribute
  • Comment !assign to assign this issue to yourself
  • Fork this repository
  • Create a new branch
  • Save the solution in program/program/implement-jump-search/ImplementJumpSearch.fs
  • Commit the changes
  • Create a pull request
@harshraj8843 harshraj8843 added F# f-sharp related good first issue Good for newcomers program labels Jan 14, 2024
@codinasion-bot
Copy link

👋🏻 Hey @harshraj8843

💖 Thanks for opening this issue 💖

A team member should be by to give feedback soon.

@codinasion-bot codinasion-bot bot added the triage Waiting for review label Jan 14, 2024
@Riyazul555
Copy link
Contributor

!assign

@Lasterminator
Copy link
Contributor

!assign

@codinasion-bot
Copy link

Hey @Lasterminator, this issue is already assigned to @Riyazul555! cc/ @codinasion/codinasion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F# f-sharp related good first issue Good for newcomers program triage Waiting for review
Projects
None yet
Development

No branches or pull requests

3 participants