second highest number in a given set of numbers

Answers were Sorted based on User's Feedback



second highest number in a given set of numbers..

Answer / kartik

Read the set of numbers in to an array ,sort it using bubble
sort(ascending order logic),the last but one number wil be
second highest number.....

Is This Answer Correct ?    9 Yes 4 No

second highest number in a given set of numbers..

Answer / suriya

put all nos. in an array and sort it using selection sort in
ascending order the last no. will be the second highest no.

Is This Answer Correct ?    6 Yes 2 No

second highest number in a given set of numbers..

Answer / 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

More C Interview Questions

What does the function toupper() do?

0 Answers  


What is s or c?

0 Answers  


in one file global variable int i; is declared as static. In another file it is extern int i=100; Is this valid ?

2 Answers   NetApp,


how do you programme Carrier Sense Multiple Access

0 Answers  


What is the difference between struct and union in C?

1 Answers  






What compilation do?

7 Answers   Geometric Software, Infosys,


if a person is buying coconuts of Rs10,and then sell that coconuts of Rs9,with the loss of one rupee.After that the person became a millaniore.how?

9 Answers   Wipro,


main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }

0 Answers   Wilco,


hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell

0 Answers   Reliance,


What is the scope of an external variable in c?

0 Answers  


Is c compiled or interpreted?

0 Answers  


What is the purpose of 'register' keyword in c language?

0 Answers  


Categories