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 the maximum no. of arguments that can be given in a command line in C.?
What does void main () mean?
1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321
Can you please explain the difference between syntax vs logical error?
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none
What is the use of function overloading in C?
How is a macro different from a function?
What is a nested formula?
When should volatile modifier be used?
Explain what does it mean when a pointer is used in an if statement?
Differentiate Source Codes from Object Codes
What is the explanation for modular programming?
Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings
Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.
Can we use visual studio for c?