Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

binary search between two indexes

 int BinarySearch(int[] arr, int low, int high, int key)
 {
     while (low <= high)
     {
         int mid = low + (high - low) / 2;
         int midVal = arr[mid];

        if (midVal < key) low = mid + 1;
        else if (midVal > key) high = mid - 1;
        else if (midVal == key) return mid;
    }
    return -1;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: csv to dataset c# 
Csharp :: C# USING SHARED CLASS 
Csharp :: == vs equals c# 
Csharp :: entity framework get all 
Csharp :: c# how to use or operator on integers in while loop 
Csharp :: skrivetækning 
Csharp :: C# MemoryStream - Timeouts are not supported on this stream 
Csharp :: Unity mousetoterrainposition 
Csharp :: c# how to return 2 strings 
Csharp :: get c directory contains system windows c# 
Csharp :: unity diference protected and virtual 
Csharp :: UPA Error 
Csharp :: c# silent execute exe 
Csharp :: console.out 
Csharp :: visual studio pre build event not working 
Csharp :: block wapalyzer from detecting codeigniter 
Csharp :: c# ef dynamic ApplyConfiguration 
Csharp :: c# dictionary key set 
Csharp :: how to unfocus a richtextbox windows forms 
Csharp :: index was out of the bound array in c# 
Csharp :: difference between c# and .net 
Csharp :: httprequestmessage with authorization .net 5 
Csharp :: unity camera movement script 
Csharp :: Jeng InitDb 
Csharp :: get centerpoint of points transforms 
Csharp :: c# class where T : enum C# 7.03 
Csharp :: unity int inputfield value 
Csharp :: asp.net Read raw Body 
Csharp :: dotnet core vue in subdirectory 
Csharp :: C# replace all . except last one 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =