Skip to content

Commit

Permalink
Update README.markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosaking authored Aug 27, 2017
1 parent 4c796cc commit 1df06b2
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions Shell Sort/README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,10 @@ Here is an implementation of Shell Sort in Swift:
var arr = [64, 20, 50, 33, 72, 10, 23, -1, 4, 5]
public func shellSort(_ list: inout [Int]) {
var sublistCount = list.count / 2
while sublistCount > 0 {
for index in 0..<list.count {
guard index + sublistCount < list.count else { break }
if list[index] > list[index + sublistCount] {
swap(&list[index], &list[index + sublistCount])
}
guard sublistCount == 1 && index > 0 else { continue }
if list[index - 1] > list[index] {
swap(&list[index - 1], &list[index])
}
for pos in 0..<sublistCount {
insertionSort(&list, start: pos, gap: sublistCount)
}
sublistCount = sublistCount / 2
}
Expand Down

0 comments on commit 1df06b2

Please sign in to comment.