were given an array of numbers "A" of size n, any given number in the array can be one of the following: 0,1,2.
using insertion sort, what is the worst case scenario, and what is the best case scenario.
i translated this question since it was given to me in another language (not a native English speaker)
anyway what they mean by worst case is in which case would the algorithim perform the most comparisons.
the best case is for example if all numbers in the array are the same, thats easy.
but for the worst case i got to the conclusion that an array that its first third is all 2's, second third is all 1's and last third is all 0's would make it so the algorithem will perform as many comparrisons as possible given the constraints.
i got to my answer by trial and error, and not only am i not sure that im even right, just giving the answer is not enough i need to explain it formally, (university)
i havent the slightest idea of where to even start. pls help :(
the insertion sort algo were using is based on the book Introduction to Algorithms Second Edition from MIT
(sorry if my English is not good)