Skip to content

Commit 11a5e7c

Browse files
committed
Fix typo "Idempotent"
1 parent 7d759ee commit 11a5e7c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Sparse Table/Sparse Table.playground/Contents.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ public class SparseTable<T> {
1414
private var defaultT: T
1515
private var table: [[T]]
1616
private var function: (T, T) -> T
17-
17+
1818
public init(array: [T], function: @escaping (T, T) -> T, defaultT: T) {
1919
let N = array.count
2020
let W = Int(ceil(log2(Double(N))))
2121
table = [[T]](repeating: [T](repeating: defaultT, count: N), count: W)
2222
self.function = function
2323
self.defaultT = defaultT
24-
24+
2525
for w in 0..<W {
2626
for l in 0..<N {
2727
if w == 0 {
@@ -35,7 +35,7 @@ public class SparseTable<T> {
3535
}
3636
}
3737
}
38-
38+
3939
public func query(from l: Int, until r: Int) -> T {
4040
let width = r - l
4141
let N = table[0].count
@@ -97,14 +97,14 @@ print("-------------------------------------------------------------------------
9797
print("---------------------------- EXAMPLE 4 -------------------------------------")
9898
// An array of positive integers and we're repeatedly finding
9999
// the gcd (greatest common divisor) over various ranges. The gcd operator is
100-
// associative and idempontent so we can use it with sparse tables
100+
// associative and idempotent so we can use it with sparse tables
101101

102102
let posIntArray = [7, 2, 3, 4, 6, 5, 25, 75, 100]
103103
func gcd(_ m: Int, _ n: Int) -> Int {
104104
var a = 0
105105
var b = max(m, n)
106106
var r = min(m, n)
107-
107+
108108
while r != 0 {
109109
a = b
110110
b = r
@@ -127,7 +127,7 @@ print("------------------------------------------------------------------------\
127127
print("---------------------------- EXAMPLE 5 -------------------------------------")
128128
// An array of nonnegative integers where for each integer we consider its binary representation.
129129
// We're repeatedly finding the binary OR (|) over various ranges. The binary operator is
130-
// associative and idempontent so we can use it with sparse tables
130+
// associative and idempotent so we can use it with sparse tables
131131

132132
let binArray = [0b1001, 0b1100, 0b0000, 0b0001, 0b0010, 0b0100, 0b0000, 0b1111]
133133

0 commit comments

Comments
 (0)