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 are the types of pointers?

590


What are the applications of c language?

613


If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?

768


Why c is called free form language?

557


Explain the ternary tree?

590






What is the difference between malloc() and calloc()?

607


what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above

659


What is a stream in c programming?

578


What are the preprocessor categories?

626


Distinguish between actual and formal arguments.

578


Can you please compare array with pointer?

605


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.

3493


What are the disadvantages of c language?

606


Write a program to check whether a number is prime or not using c?

565


What does %p mean c?

613