Skip to content

Commit 1df06b2

Browse files
authored
Update README.markdown
1 parent 4c796cc commit 1df06b2

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

Diff for: Shell Sort/README.markdown

+2-16
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,10 @@ Here is an implementation of Shell Sort in Swift:
117117
var arr = [64, 20, 50, 33, 72, 10, 23, -1, 4, 5]
118118
119119
public func shellSort(_ list: inout [Int]) {
120-
121120
var sublistCount = list.count / 2
122-
123121
while sublistCount > 0 {
124-
125-
for index in 0..<list.count {
126-
127-
guard index + sublistCount < list.count else { break }
128-
129-
if list[index] > list[index + sublistCount] {
130-
swap(&list[index], &list[index + sublistCount])
131-
}
132-
133-
guard sublistCount == 1 && index > 0 else { continue }
134-
135-
if list[index - 1] > list[index] {
136-
swap(&list[index - 1], &list[index])
137-
}
122+
for pos in 0..<sublistCount {
123+
insertionSort(&list, start: pos, gap: sublistCount)
138124
}
139125
sublistCount = sublistCount / 2
140126
}

0 commit comments

Comments
 (0)