课程: C# Algorithms
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Binary search arrays in C#
- [Instructor] Searching data is a common task in software development. In order to optimize our search algorithm, we'll need to make assumptions about the data. For example, if you know the array will be sorted, you can start at the middle and then work your way towards the beginning or the end of the array, depending on where the items should be located. If this happens to be the case, one algorithm we can use is binary search. Binary search is a divide and conquer algorithm where in each step it halves the number of elements it has to search through. For example, if we had an array of sorted numbers, the algorithm would start at the middle. Then depending on whether the item we're searching for is greater than or less than the item we're looking at, it would continue its search in that portion of the array. Let's say we were looking for the number 45. The algorithm would start its search at index three, or item 19. Since 19 is less than 45, it would continue its search in the…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。