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
How to write a code for reverse of string without using string functions?
FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above
Describe the header file and its usage in c programming?
What does %p mean c?
What is main () in c?
How can I invoke another program or command and trap its output?
Compare interpreters and compilers.
What is getch c?
What is C language ?
What is the use of pragma in embedded c?
List the different types of c tokens?
What is a stream water?
What are the advantages and disadvantages of c language?
Which driver is a pure java driver
Are the variables argc and argv are local to main?