Talk:Computer Science/Data Structures/Introduction content

Induction on a Summation Comment
Was on the main page:
 * [TODO: I added a proof for the closed form of the sum of the first n numbers, but I don't see how this helps insertion sort, so maybe this isn't the proof you were thinking of. - Nebu Pookins.]

Reply: That's exactly the proof needed, thanks! I'll read through it to look for any minor errors. It can help for the analysis of insertion sort, that being, an upper-bound on the number of compares for n elements. To find the first min, you need to do n-1 compares, to find the next min, you need to do n-2 compares, ... and so on, so the number of compares can be computed using this formula. I suppose while we're on the topic I should note that it might be nice if this series of books would always do more than just the regular "O(f(n))" analysis. For example, instead of just number of steps for sorting, it could be number of steps, number of swaps (if applicable), and number of compares. For hashtables, it will be expected lookup (O(1)), but also what the complexity of hashing a key is (O(k) where k is the key). MShonle 19:49, 11 August 2005 (UTC)