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
What are the types of pointers?
What are the applications of c language?
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?
Why c is called free form language?
Explain the ternary tree?
What is the difference between malloc() and calloc()?
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
What is a stream in c programming?
What are the preprocessor categories?
Distinguish between actual and formal arguments.
Can you please compare array with pointer?
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.
What are the disadvantages of c language?
Write a program to check whether a number is prime or not using c?
What does %p mean c?