Binary Search - C#

A Binary Search is a searching algorithm used to search a collection or array.

What is a Binary Search?

A Binary Search is a searching algorithm used to search a collection or array. It is often more efficient than a full scan of the collection.

The collection must be sorted to perform a binary search.

A binary search returns the index of the position where the item was found. (Or it returns the negative inverse of the position where the item should be inserted if it is not found).

int index = Array.BinarySearch(names, "Francis");

Level: Freelancer · More C# terms at this level

Updated