Answer:
Explanation:
( n cards are there initially )
we pick out the first card in random it takes n-1 comparisons to figure out
its Equivalence card - n-1 steps
Two cards have been eliminated ( this leaves us with 2 and n-2 cards)
we pick out the 2nd card in random it takes n-3 comparisons to figure out
its Equivalence card - n-3 steps
we continue to do this.. till all cards are exhausted ( leaves us with 2
and n-4 cards again)
the last comparison will
have
- n-(n-3)
the sum of all these steps - (n-1) + (n-3) + (n-5) + .........+
(n-(n-3))
if you draw this in the form of a tree.
n - n
2
n-2 - n
2
n-4 - n-2
2
n-6 - n-4
2
n-8 - n- 6
the height of the tree will be log n , sum @ each level is at most n
Answer:
No but my baby brother can play with u
Answer:
Explanation:
I have written the code in Java. It contains the class Insertion Sorter which has the InsertionSort function. This function uses the insertion sort algorithm to sort a comparable array and if it fails to do so for whatever reason it throws an Illegal ArgumentException. If it sorts the array correctly it returns the number of changes that needed to be made in order to correctly sort the array. Due to technical difficulties I have attached the code as a text document below and proof of output in the picture below as well.
I would say 3-D model!!!! not 100% sure but this sounds most correct!