Re: [algogeeks] missing integers in an unsorted array

2010-01-31 Thread Anurag Bhatia
Sum of n numbers = n(n+1)/2 Traverse the array and add up all the numbers. Subtract that from the sum of n numbers. --Anurag On Mon, Feb 1, 2010 at 4:24 AM, Banoo wrote: > hi, > can you help me solve the following problem? > > You are given an unsorted list of n-1 distinct integers from the rang

Re: [algogeeks] missing integers in an unsorted array

2010-01-31 Thread Sathaiah Dontula
Use the formula for sum of first n natural numbers to get the missing number. Thanks & regards, Sathaiah Dontula On Mon, Feb 1, 2010 at 4:24 AM, Banoo wrote: > hi, > can you help me solve the following problem? > > You are given an unsorted list of n-1 distinct integers from the range > 1 to n.

Re: [algogeeks] missing integers in an unsorted array

2010-01-31 Thread Krishan Malik
sum of first N numbers is n(n+1)/2 . take the sum of given numbers and subtract it from n(n+1)/2. Thanks Sri On Mon, Feb 1, 2010 at 4:24 AM, Banoo wrote: > hi, > can you help me solve the following problem? > > You are given an unsorted list of n-1 distinct integers from the range > 1 to n. Wri

Re: [algogeeks] missing integers in an unsorted array

2010-01-31 Thread Mario Ynocente Castro
You could use a boolean array to mark which numbers you have on the list. 2010/1/31 Banoo > hi, > can you help me solve the following problem? > > You are given an unsorted list of n-1 distinct integers from the range > 1 to n. Write a linear-time algorithm to find the missing integer. > > > Tha

[algogeeks] missing integers in an unsorted array

2010-01-31 Thread Banoo
hi, can you help me solve the following problem? You are given an unsorted list of n-1 distinct integers from the range 1 to n. Write a linear-time algorithm to find the missing integer. Thanks -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" grou