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 you please compare array with pointer?
What is quick sort in c?
What is array of structure in c?
Why does everyone say not to use gets?
Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.
What is optimization in c?
Why is c not oop?
Write a program to print “hello world” without using semicolon?
What does p mean in physics?
What are the __date__ and __time__ preprocessor commands?
What are the advantages of c language?
Explain high-order bytes.
Write a program to check palindrome number in c programming?
What is static function in c?
Why doesnt long int work?