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
Explain the ternary tree?
Explain the difference between null pointer and void pointer.
What does struct node * mean?
Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix
What are external variables in c?
What is the meaning of typedef struct in c?
What is the sizeof () operator?
What do you mean by dynamic memory allocation in c? What functions are used?
int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;
Describe the header file and its usage in c programming?
How can I rethow can I return a sequence of random numbers which dont repeat at all?
Is null a keyword in c?
Explain how can type-insensitive macros be created?
The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration
What is the use of the function in c?