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

being a chemical engineer and with an aggregate of 80% why you opt for TCS and not your core industry?

1 Answers   TCS,


Explain what is wrong with this statement? Myname = ?robin?;

0 Answers  


What is the difference between volatile and const volatile?

0 Answers  


What is malloc and calloc?

0 Answers  


whether itis a structured language?

1 Answers   Microsoft,






What are comments and how do you insert it in a C program?

0 Answers  


When should structures be passed by values or by references?

0 Answers   Adobe,


What is key word in c language?

4 Answers   ABC,


What is a function simple definition?

0 Answers  


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

0 Answers   TISL,


Write a program to exchange two variaables without temp

9 Answers   Geometric Software,


what is the answer for it main() { int i; clrscr(); printf("%d",&i)+1; scanf("%d",i)-1; }

3 Answers  


Categories