[algogeeks] Re: Need an algorithm to find the missing numbers.

2006-08-28 Thread Thomas Taranowski
Good point. I had assumed that the array is sorted. Although not mentioned in the original email, seeing the 1,2,3...n progression led me to assume so. If the array is not sorted, I would definately sort first. Perhaps there is a method where I can scan for missing numbers while sorting, or lo

[algogeeks] Re: Need an algorithm to find the missing numbers.

2006-08-26 Thread Thomas Taranowski
I can't see a way to do this in less than O(n) time, unless I can take advantage of the way the data is stored. If the numbers were stored in a simple C-style array, and the numbers were sparsely missing, something like this could be done: //This value is to be adjusted based on the character o