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 structure packing in c?
Process by which one bit pattern in to another by bit wise operation is?
difference between Low, Middle, High Level languages in c ?
how can f be used for both float and double arguments in printf? Are not they different types?
How do you write a program which produces its own source code as output?
Can we change the value of static variable in c?
What type is sizeof?
What is storage class?
How are portions of a program disabled in demo versions?
What is ## preprocessor operator in c?
how to construct a simulator keeping the logical boolean gates in c
What does emoji p mean?
What is typedef example?
Why does everyone say not to use scanf? What should I use instead?
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }