Skip to content

Commit

Permalink
Create ShellSortExample.swift
Browse files Browse the repository at this point in the history
Inner while loop was slightly incorrect - for example try array [64, 20, 50, 33, 72, 10, 23, -1, 4,-2,-3] with previous version.
  • Loading branch information
Darr758 authored Jun 10, 2017
1 parent 17bf20d commit 1bc6990
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Shell Sort/ShellSortExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public func shellSort(_ list : inout [Int]) {

guard sublistCount == 1 && index > 0 else { continue }

while list[index - 1] > list[index] && index - 1 > 0 {
while index > 0 && list[index - 1] > list[index] {
swap(&list[index - 1], &list[index])
index -= 1
}
Expand Down

0 comments on commit 1bc6990

Please sign in to comment.