we will explain how Binary Search in javascript work and what is the bigO of what and how to calculates the result need in js. Understanding data structures, algorithms, and basic programming concepts are essential for one to become a better...

we will explain how Binary Search in javascript work and what is the bigO of what and how to calculates the result need in js. Understanding data structures, algorithms, and basic programming concepts are essential for one to become a better developer.

as we know, we are used multi ALgrathmic to search items in the array or an object, but what is distance one algorithmic about others is the complexity and bigO. What is Binary Search? Binary search is algorithmic used to find them to find elements or items found in array sorting before we start. what is meaning it is sorting example [2,5,6,9,13,15,28,30], as we see this array is sorting let discussion the code

```
var start = 0;
var end = arr.length - 1;
var middle = Math.floor((start + end) / 2);
while(arr[middle] !== elem && start <= end) {
if(elem < arr[middle]) end = middle - 1;
else start = middle + 1;
middle = Math.floor((start + end) / 2);
}
return arr[middle] === elem ? middle : -1;
}
```

binarySearch([2,5,6,9,13,15,28,30], 103) how it work at first we spilt arry into 2 sub array and detarment the center element found in array middle by this code var middle = Math.floor((start + end) / 2); then we need check element if equales the elemnt parctical if true we found the elemnt . at first we will contiououse untaill the while(arr[middle] !== elem && start <= end) //this for elemnt not found from the first time and start <=end to reach the last elenment in the array.

the image explains the simple example of how it works the best case O(1) but the worst case it is the O(logN)

Divide and conquer algorithm. A binary search is a searching algorithm for finding an item from a sorted list of items. It works by repeatedly dividing in half the portion of the list that could contain the item until you’ve narrowed down the possible locations to just one. As compared to linear, binary search is much faster with Time Complexity of O(logN) whereas the linear search algorithm works in O(N) time complexity. The implementation of binary search can be done iteratively or recursively.

Prerequisite: Binary Search Tree In JavaScript. Deletion in Binary Search Tree with JavaScript. Deletion in binary search tree can be tricky, since we’re not working with just leafs but having to restructure all of a node’s children. Node to be deleted is leaf. To delete a leaf node, simply remove it from the tree. Since it was a leaf node we deleted it from the tree without making any other changes.

I think Google’s Cloud Firestore is a great example of leveraging a basic concept in computer science to create a powerful software

Searching Algorithms in Java. A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

Javascript String search() is an inbuilt function that executes the search for a match between a regular expression and this String object.