Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

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

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

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

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

More C Interview Questions

write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.

how do u find out the number of 1's in the binary representation of a decimal number without converting it into binary(i mean without dividing by 2 and finding out the remainder)? three lines of c code s there it seems...can anyone help

what is op? for(c=0;c=1000;c++) printf("%c",c);

Are c and c++ the same?

What is binary tree in c?

There is a 100-story building and you are given two eggs. The eggs (and the building) have an interesting property that if you throw the egg from a floor number less than X, it will not break. And it will always brake if the floor number is equal or greater than X. Assuming that you can reuse the eggs which didn't broke; you got to find X in a minimal number of throws. Give an algorithm to find X in minimal number of throws.

What is the difference between scanf and fscanf?

What should malloc() do? Return a null pointer or a pointer to 0 bytes?

could u able to tell about suresoft technical session

long int size a) 4 bytes b) 2 bytes c) compiler dependent d) 8 bytes

How to print %d in output

Categories