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

Out of the four alternatives, choose the one which can be substituted for the given words/sentences and click the button corresponding to it.

A place of shelter for ships

A) Harbour B) Helipad
C) Port D) Barrack
 
Answer & Explanation Answer: A) Harbour

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: English
Exam Prep: Bank Exams

0 2395
Q:

The given sentences, when properly sequenced, form a coherent paragraph. Each sentence is labelled with a letter. Choose the most logical order of the sentences from among the five given choices to construct a coherent paragraph keeping 1 as the first statement.

1) In Hindu mythology, when Shiva opens his third eye, it is considered a terrible warning for the cosmos.

A) In somewhat similar fashion, in 2017, women across the world seemed to declare war — on harassment, abuse, rape, inequality and every form of injustice.

B) Anger, however, is only one facet of the fight for empowerment. Concomitantly, the year saw women stack up achievements on an unprecedented scale.

C) It means he is angry enough to incinerate anything that comes in his way.

D) Across the world, there was a furious outpouring of rage against men in power, men on the street, men at home, and in families.

A) ABCD B) CBDA
C) DBAC D) DACB
 
Answer & Explanation Answer:

Explanation:

The correct sequence is CADB.

Report Error

View Answer Report Error Discuss

Filed Under: English

0 2394
Q:

In the given question, a statement divided into different segments is given. The first segment is fixed, rearrange the other segments to form a coherent statement.

Introduction of the finance bill was delayed/ budget allocation for the cottage (P)/ debating over the renewal of the last year's (Q)/ by a week as the lawmakers were busy (R)/ industry which got wasted (S)

A) PQRS B) SPQR
C) RQPS D) QRPS
 
Answer & Explanation Answer: C) RQPS

Explanation:

This question can be best solved by the elimination technique. 'was delayed budget allocation', 'was delayed industry which' and 'was delayed debating over' do not make sense; hence P, Q and S can't follow the first segment. This eliminates options 1, 2 and 4. Option 5 places S after R which makes the resultant segment as 'lawmakers were busy industry' which is illogical; hence option 5 can also be eliminated. Hence, the correct sequence is RQPS.

Report Error

View Answer Report Error Discuss

Filed Under: English

0 2394
Q:

A tenant farmer in the south usually needed to

A) land B) tools
C) animals D) Both B & C
 
Answer & Explanation Answer: D) Both B & C

Explanation:

A tenant farmer is one who resides on land owned by a landlord. These farmers would have to share the yield with the landowner in a process known as sharecropping. In the South, these farmers need to have their own tools and animals.

Report Error

View Answer Report Error Discuss

Filed Under: Indian Geography
Exam Prep: AIEEE , Bank Exams
Job Role: Analyst , Bank Clerk , Bank PO

3 2394
Q:

Menstruation is triggered by a drop in the levels of

A) progesterone B) relaxin
C) FSH D) LH
 
Answer & Explanation Answer: A) progesterone

Explanation:

The principal hormone secreted by the corpus luteum is progesterone. Menstruation is triggered by a drop in the levels of progesterone.

Report Error

View Answer Report Error Discuss

Filed Under: Biology
Exam Prep: AIEEE
Job Role: Analyst

4 2394
Q:

The book Taste of India is written by

A) Ramachandra Guha B) Khushwanth Singh
C) Chetan Bhagat D) Madhur Jaffrey
 
Answer & Explanation Answer: D) Madhur Jaffrey

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Books and Authors
Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Analyst , Bank Clerk , Bank PO

2 2394
Q:

Which of these is not a union territory of India?

A) Goa B) Puducherry
C) Delhi D) Andaman & Nicobar
 
Answer & Explanation Answer: A) Goa

Explanation:

A Union territory is a type of administrative division in India. Unlike the other states which have their own state governments, union territories are ruled by the central government. There are 7 union territories in India. They are ::



    • National Capital Territory of Delhi – Delhi.

 

    • Chandigarh – Chandigarh.

 

    • Daman and Diu – Daman.

 

    • Dadra and Nagar Haveli – Silvassa.

 

    • Pondicherry – Puducherry.

 

    • Andaman and Nicobar Islands – Port Blair.

 

    • Lakshadweep – Kavaratti.

 

Report Error

View Answer Report Error Discuss

Filed Under: Indian Geography
Exam Prep: CAT , Bank Exams , AIEEE
Job Role: Bank PO , Bank Clerk , Analyst

2 2393