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 2391
Q:

Mercedes luggage is a symbol of

Answer

Mercedes's language in reference to the story "Call of the Wild" actually means civilization. She had brought numerous belongings along with her and they were much more than the dogs could pull. Her decision of not parting with any of the belongings would ultimately lead to her death. One can easily draw a clear difference between civilization and wildness.

Report Error

View answer Workspace Report Error Discuss

Subject: Books and Authors Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Analyst , Bank Clerk

5 2390
Q:

Four words are given, out of which only one word is spelt correctly. Choose the correctly spelt word and click the button corresponding to it.

A) Conniosseur B) Connoisseur
C)  Connossieur D) Connosseiur
 
Answer & Explanation Answer: B) Connoisseur

Explanation:
Report Error

View Answer Report Error Discuss

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

1 2390
Q:

A tone in music is a sound that

A) has high frequency B) has definite pitch
C) has low duration D) None of the above
 
Answer & Explanation Answer: B) has definite pitch

Explanation:

A tone in music is a sound that has definite pitch. Pitch is nothing but the relative highness or lowness of a sound.

Report Error

View Answer Report Error Discuss

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

1 2390
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.

We set out for the gallows. Two warders marched on either side of the prisoner, with their rifles at the slope; two others marched close against him, gripping him by his arm and shoulder, as though, at once pushing and supporting him. The rest of us, magistrates and the like, followed behind. Suddenly, when we had gone ten yards, the procession stopped short without any order or warning. A dreadful thing had happened ­ a dog, come goodness knows whence, had appeared in the yard. It came bounding among us with a loud volley of barks, and leapt round us wagging its whole body, wild with glee at finding so many human beings together. It was a large woolly dog, half Airedale, half Pariah. For a moment, it pranced round us, and then, before anyone could stop it, it had made a dash for the prisoner, and jumping up tried to lick his face. Everyone stood aghast, too taken aback even to grab at the dog.

What was the emotion displayed by the dog?

A) Fear B) Joy
C) Anger D) Alarm
 
Answer & Explanation Answer: B) Joy

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: English
Exam Prep: Bank Exams

0 2390
Q:

Improve the bracketed part of the sentence.
The exhausted travellers seemed relieved when the train finally (came into) the station.

A) pulled in B) pulled into
C) pulled onto D) no improvement
 
Answer & Explanation Answer: A) pulled in

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: English
Exam Prep: Bank Exams

0 2388
Q:

Choose the correctly spelt word:-

A) Sepulchral B) Sepalchrle
C) Sepalchral D) Sepulchrle
 
Answer & Explanation Answer: A) Sepulchral

Explanation:

Sepulchral is spelt correctly which means joyless

Report Error

View Answer Report Error Discuss

Filed Under: English
Exam Prep: Bank Exams

1 2388
Q:

What would be the output of the following program?

/* sample.c */

main ( int argc, char **argv )

{

     argc = argc - (argc -1);

     printf ("%s", argv[argc - 1]);

}

Answer

C: \SAMPLE.EXE

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 2388