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 is a stream?
main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above
How to get string length of given string in c?
What is the advantage of using #define to declare a constant?
Explain how do you list files in a directory?
What is the sizeof () operator?
How can I read data from data files with particular formats?
When is a null pointer used?
What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
differentiate built-in functions and user – defined functions.
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What do the functions atoi(), itoa() and gcvt() do?
Can we assign string to char pointer?
What are the different properties of variable number of arguments?
What are variables and it what way is it different from constants?