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

Why c language is called c?

1064


How can I find out how much free space is available on disk?

1106


What is selection sort in c?

1177


Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1137


Tell me what is the purpose of 'register' keyword in c language?

1040


Disadvantages of C language.

1165


How can I open a file so that other programs can update it at the same time?

1242


State the difference between x3 and x[3].

1168


What is the use of putchar function?

1110


What does return 1 means in c?

1119


Explain what are reserved words?

1160


What is hashing in c language?

1427


code for find determinent of amatrix

2018


What is a pointer variable in c language?

1156


How can I write a function that takes a format string and a variable number of arguments?

1104