algorithm - Algorithmic Analysis of Insertion Sort case -


enter image description here

i'm studying exam have tomorrow , can't seem understand problem. (this old assignment have answers to). don't quite understand parts b , parts c.

i understand b reverse sorted list, don't understand how find number of comparisons. answer if summation k 1 (n/2) of 2(2k-1) = (n^2)/2 - 1. why summing 1 n/2 , not n? difference make values twice? wouldn't still need iterate through them all?

i'm confused on c well. how go finding this? not sure how find average cases.

edit: ok. sort of understand b now. since it's worst case input know equal numbers going next each other. odd indexes comparisons while indexes i-1 since there's going in sorted portion.

still clueless c still :/.

please, elaboration , explanations forever grateful.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -