What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-11-08 06:59:08
javascript binary search
const arr = [1, 3, 5, 7, 8, 9]; const binarySearch = (arr, x , start=0, end=arr.length) => { // If the item does not exist, return -1 if(end < start) return -1; // Calculate middle index of the array let mid = Math.floor((start + end) / 2... Add solution -
C++ 2021-10-29 06:04:08
how to shorten code using using c++ in class with typename
template<typename T> using Node = typename BinarySearchTree<T>::Node; template <class T> Node<T> const* BinarySearchTree<T>::find(const T& value) const { // some code here return nullptr; } Add solution -
Javascript 2021-09-25 23:54:03
binaryserachindex javascript
function binarySearchIndex (array, target, low = 0, high = array.length - 1) { if (low > high) { return -1 } const midPoint = Math.floor((low + high) / 2) if (target < array[midPoint]) { return binarySearchIndex(array, target, low, ... Add solution -
Other 2021-09-08 05:10:02
how to check if a binary tree is a binary search tree
class BTNode { constructor(value) { this.value = value; this.left = null; this.right = null; } } /** * * @param {BTNode} tree * @returns {Boolean} */ const isBinarySearchTree = (tree) => { if (tree) { if ( tree.left &am... Add solution