Questions

Q:

Write a c program for merge sort.

Answer

#include
#define MAX 50

void mergeSort(int arr[],int low,int mid,int high);
void partition(int arr[],int low,int high);

int main(){
  
    int merge[MAX],i,n;

    printf("Enter the total number of elements: ");
    scanf("%d",&n);

    printf("Enter the elements which to be sort: ");
    for(i=0;i<n;i++){
         scanf("%d",&merge[i]);
    }

    partition(merge,0,n-1);

    printf("After merge sorting elements are: ");
    for(i=0;i<n;i++){
         printf("%d ",merge[i]);
    }

   return 0;
}

void partition(int arr[],int low,int high){

    int mid;

    if(low<high){
         mid=(low+high)/2;
         partition(arr,low,mid);
         partition(arr,mid+1,high);
         mergeSort(arr,low,mid,high);
    }
}

void mergeSort(int arr[],int low,int mid,int high){

    int i,m,k,l,temp[MAX];

    l=low;
    i=low;
    m=mid+1;

    while((l<=mid)&&(m<=high)){

         if(arr[l]<=arr[m]){
             temp[i]=arr[l];
             l++;
         }
         else{
             temp[i]=arr[m];
             m++;
         }
         i++;
    }

    if(l>mid){
         for(k=m;k<=high;k++){
             temp[i]=arr[k];
             i++;
         }
    }
    else{
         for(k=l;k<=mid;k++){
             temp[i]=arr[k];
             i++;
         }
    }
  
    for(k=low;k<=high;k++){
         arr[k]=temp[k];
    }
}


Sample output:

Enter the total number of elements: 5
Enter the elements which to be sort: 2 5 0 9 1
After merge sorting elements are: 0 1 2 5 9

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 2431
Q:

Give the truth table for a Half Adder. Give a gate level Implementation of the same.

Answer

TRUTH TABLE FOR HALF ADDER


A    B  SUM  CARRY


0    0    0         0


0    1    1         0


1    0    1         0


1    1    0         1


INPLEMENTATION:


For SUM, The two inputs A and B are given to XOR gate.


For Carry, The two inputs A and B are given to AND gate.

Report Error

View answer Workspace Report Error Discuss

Subject: Hardware

0 2430
Q:

Steven Leslie was convicted of what after causing a fatal collision?

A) first-degree murder B) second-degree murder
C) premeditated D) None of the above
 
Answer & Explanation Answer: B) second-degree murder

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: World History
Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Analyst , Bank Clerk , Bank PO

0 2430
Q:

The basic structural unit of the body is the

A) Organs B) Cell
C) Nerve D) Brain
 
Answer & Explanation Answer: B) Cell

Explanation:

Cells are the the basic structural unit of the body.

Report Error

View Answer Report Error Discuss

Filed Under: General Science
Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Analyst , Bank Clerk , Bank PO

5 2430
Q:

Which group in an ecosystem performs photosynthesis?

A) Xylotrophs B) Autotrophs
C) Monotrophs D) Heterotrophs
 
Answer & Explanation Answer: B) Autotrophs

Explanation:

In an ecosystem, Autotrophs performs photosynthesis. Autrophs are those prepare their own food.

Report Error

View Answer Report Error Discuss

Filed Under: General Science
Exam Prep: AIEEE , Bank Exams
Job Role: Analyst , Bank Clerk , Bank PO

1 2428
Q:

In the following question, a sentence has been given in Direct/Indirect speech. Out of the four alternatives suggested, select the one, which best express the same sentence in Indirect/Direct speech.

Anil says, "I am glad to be here this morning"

A) Anil says he is glad to be there that morning. B) Anil says that he is glad to be there that morning.
C) Anil was saying that he was glad to be there this morning. D) Anil says that he was glad to be here this morning.
 
Answer & Explanation Answer: B) Anil says that he is glad to be there that morning.

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: English
Exam Prep: Bank Exams , GRE , TOEFL

0 2428
Q:

Read the passage carefully and choose the best answer to each question out of the four alternatives and click the button corresponding to it.

In the world today we make health an end in itself. We have forgotten that health really means to enable a person to do his work and do it well. A lot of modern medicine, and this includes many patients as well as many physicians, pay very little attention to health but very much attention to those who imagine they are ill. Our great concern with health is shown by the medical columns in newspapers, the health articles in popular magazines and the popularity of television programmes and all those books on medicine. We talk about health all the time. Yet for the most part the only result is more people with imaginary illness. A healthy man should not be wasting time talking about health : he should be using health for work.


A healthy man should be concerned with

A) his work which good health makes possible B) looking after his health
C) his health which makes work possible D) talking about health
 
Answer & Explanation Answer: A) his work which good health makes possible

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: English
Exam Prep: Bank Exams

0 2428
Q:

In the following question, out of the four alternatives, select the alternative which best expresses the meaning of the idiom/phrase.

 

The tail is wagging the dog

 

 

A) A situation where a small good thing makes everyone happy B) The less important or subsidiary factor, person, or thing dominates a situation  
C) A person who is always happy to meet you D) Even smaller tasks become important if the whole project is to succeed
 
Answer & Explanation Answer: B) The less important or subsidiary factor, person, or thing dominates a situation  

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: English
Exam Prep: Bank Exams , CAT , GRE , TOEFL

11 2428