1. Let x be the missing and y be the repeated element
3. Calculate the sum of all the elements and sum of squares of all the
elements of array.

S=Sum of all the elements of array
S1= Sum of squares of all the elements of array

Sum of first n natural numbers=a= ( n * (n+1) )/2
Sum of squares of first n natural no=b= n * (n+1) * (2n+1) / 6

a=S+x-y
b=S1+x^2- y^2

(b-S1)/(a-S)=x+y;
Now we have 2 equations and 2 variables & hence both x and y can be found.

On Sun, Sep 11, 2011 at 3:58 PM, parag khanna <[email protected]>wrote:

> Q.) Take an array of 100 elements and fill it with the no 1 to 100 such
> that one no. should skip and one no. should repeated. Find the no. which is
> repeated and which is skipped.
>
>
>
>
>
>
> --
> Parag Khanna
> B.tech Final Year
> NIT,Kurukshetra
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Regards
Ravi Maggon
B.E. CSE, Final Year
Thapar University

www.algorithmguru.com

"*Failure is the opportunity to begin again more intelligently"*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to