Skip to content

Commit 809cb97

Browse files
committed
Typos corrected
1 parent 041c005 commit 809cb97

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Count Occurrences/README.markdown

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ In code this looks as follows:
2525
func countOccurrences<T: Comparable>(of key: T, in array: [T]) -> Int {
2626
var leftBoundary: Int {
2727
var low = 0
28-
var high = a.count
28+
var high = array.count
2929
while low < high {
3030
let midIndex = low + (high - low)/2
31-
if a[midIndex] < key {
31+
if array[midIndex] < key {
3232
low = midIndex + 1
3333
} else {
3434
high = midIndex
@@ -39,10 +39,10 @@ func countOccurrences<T: Comparable>(of key: T, in array: [T]) -> Int {
3939

4040
var rightBoundary: Int {
4141
var low = 0
42-
var high = a.count
42+
var high = array.count
4343
while low < high {
4444
let midIndex = low + (high - low)/2
45-
if a[midIndex] > key {
45+
if array[midIndex] > key {
4646
high = midIndex
4747
} else {
4848
low = midIndex + 1
@@ -62,7 +62,7 @@ To test this algorithm, copy the code to a playground and then do:
6262
```swift
6363
let a = [ 0, 1, 1, 3, 3, 3, 3, 6, 8, 10, 11, 11 ]
6464

65-
countOccurrencesOfKey(3, inArray: a) // returns 4
65+
countOccurrences(of: 3, in: a) // returns 4
6666
```
6767

6868
> **Remember:** If you use your own array, make sure it is sorted first!

0 commit comments

Comments
 (0)