NeoAlgo icon indicating copy to clipboard operation
NeoAlgo copied to clipboard

binary search without using length function (built-in) in java under GSSOC'22

Open Akshitajain1906 opened this issue 2 years ago • 2 comments

🚀 Feature

This code is to find a particular element in an sorted array when we do not know the length of the array and are not allowed to use length function. This can be treated as a base code for binary search in an infinite array where we are unaware of the length. binary search without using arrayname.length using java under GSSOC'22

Have you read the Contributing Guidelines on Pull Requests?

yes

Motivation

Just started learning DSA and eager to implement it here.

Pitch

for questions related to searching in an array of infinite length, this approach will be really helpful. CODE (java)- public static int binarySearch(int[] arr, int target){ int start=0; int end=1; while(arr[end]>target) { while(start<=end){ int mid = start + (end - start) / 2; if (arr[mid] == target) return mid; else if (arr[mid] < target) start = mid + 1; else end = mid - 1; } //exp++; int temp = end+1; end = end + (end-start+1)*2; start=temp; } return -1; }

infinite array

Akshitajain1906 avatar Apr 28 '22 11:04 Akshitajain1906

please assign me this issue @HarshCasper /assign

Akshitajain1906 avatar Jun 27 '22 19:06 Akshitajain1906

/assign

Akshitajain1906 avatar Jun 27 '22 19:06 Akshitajain1906

Please reopen this issue once you add more information and updates here. If this is not the case and you need some help, feel free to seek help from our Telegram or ping one of the reviewers. Thank you for your contributions!

github-actions[bot] avatar Aug 27 '22 01:08 github-actions[bot]

/assign

Akshitajain1906 avatar Aug 29 '22 11:08 Akshitajain1906

/assign

Akshitajain1906 avatar Aug 29 '22 11:08 Akshitajain1906