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
Can we declare variables anywhere in c?
praagnovation
What is stack in c?
How can I dynamically allocate arrays?
how is the examination pattern?
What is structure of c program?
Can the sizeof operator be used to tell the size of an array passed to a function?
#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??
Tell me when would you use a pointer to a function?
What does a pointer variable always consist of?
How does selection sort work in c?
In C, What is the #line used for?
What are local static variables?
What does 4d mean in c?
What are compound statements?