Reputation: 433
Why are insertion sort algorithms also not considered brute force algorithms? Don't they systematically look through every value of the array as well? I undertand that selection sort has a worst best-case time complexity, but I'm still not fully understanding the differentiation between a brute-force algorithm and a decrease-and-conquer algorithm. Sorry if this is a stupid question. Thanks!
Upvotes: 0
Views: 1623
Reputation: 80197
Both insertion and selection sort might be called “decrease and conquer” because at every step of outer loop they treat smaller and smaller part of array.
Formally speaking, in these sorts loop invariant condition is that the subarray A[0 to i-1] is always sorted
.
I have not met “brute force” term in application to sorting algorithms, it looks like nonsense. Brute force algorithms usually check all possible variants and choose the best one. It is possible to generate all permutations of an array or list and choose sorted one - this kind of sortinh might be called "stupid sort" or something like.
Upvotes: 1