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...

second highest number in a given set of numbers

Answer Posted / om

There are two good method to solve this problem; first one
takes 2n-3 comparison and second one takes n+lg(n)-2
comparison only.

1) Run bubble sort loop only for 2 times ..the first time it
will do n-1 comparison and put the largest element at the
end of the array.... then by running second time it will do
n-2 comparison and put the second largest element at the
second last position in the array... so n-1 + n-2 =2n-3
comparison. cool naa... I didn't sort the whole array and
found the second largest element.

2)http://www.seeingwithc.org/topic3html.html
check this site...

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is structure packing in c?

1142


Process by which one bit pattern in to another by bit wise operation is?

1233


difference between Low, Middle, High Level languages in c ?

2144


how can f be used for both float and double arguments in printf? Are not they different types?

1132


How do you write a program which produces its own source code as output?

1177


Can we change the value of static variable in c?

1080


What type is sizeof?

1090


What is storage class?

1127


How are portions of a program disabled in demo versions?

1346


What is ## preprocessor operator in c?

1138


how to construct a simulator keeping the logical boolean gates in c

2309


What does emoji p mean?

1211


What is typedef example?

1265


Why does everyone say not to use scanf? What should I use instead?

1477


void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }

1792