Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Given an array of numbers, except for one number all the
others occur twice. Give an algorithm to find that number
which occurs only once in the array.

Answer Posted / guest

int arr[n]; //n' numbers

for (int i=0;i<n;i++)
for (int j=0;j<n;j++)
{ if ( (a[i]==a[j])&&i!=j ) break; //ITS NOT THE NUM
if ( (a[i]!=a[j])&&j==n-1) return i; //IT IS!!
return -1; //IF THERE IS NO SUCH NUMBER...

Is This Answer Correct ?    3 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how can I pad a string to a known length?

1189


Explain what is the benefit of using enum to declare a constant?

1077


How do you determine a file’s attributes?

1078


What is a header file?

1078


What is the use of function in c?

1190


What is meant by inheritance?

1086


Differentiate between a for loop and a while loop? What are it uses?

1171


What is a void * in c?

1072


How does normalization of huge pointer works?

1167


Describe newline escape sequence with a sample program?

1116


What does 4d mean in c?

1493


what are enumerations in C

1161


Explain what are bus errors, memory faults, and core dumps?

1273


What is the purpose of the preprocessor directive error?

1264


What are actual arguments?

1083