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

All Insurance is based on a principle called

A) investment premiums B) division of risk
C) cash value coverage. D) premium earnings
 
Answer & Explanation Answer: B) division of risk

Explanation:

Any type of insurance, be it home, auto, life, health, etc. are based on a principle of division of risk.

 

Division of Risk :: This is based on how much risk the insurer estimates the insured's coverage to be. The riskier the opportunity (bad health, area the home is in) the higher the premium costs.

Report Error

View Answer Report Error Discuss

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

0 2381
Q:

The right to vote in India is in an article of

A) 370 B) 368
C) 356 D) 326
 
Answer & Explanation Answer: D) 326

Explanation:

In India, the right to vote is provided by the Constitution and the Representation of People's Act, 1951, subject to certain disqualifications. Article 326 of the Constitution guarantees the right to vote to every citizen above the age of 18.

Report Error

View Answer Report Error Discuss

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

1 2380
Q:

A computer port is used to

A) Donwload files B) Communicate with other computer peripherals
C) Communicate with hard disks D) All of the above
 
Answer & Explanation Answer: B) Communicate with other computer peripherals

Explanation:
Report Error

View Answer Report Error Discuss

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

1 2380
Q:

As per the decision of the GST Council, e-Way Bill system has been rolled out from

A) 1st March 2018 B) 1st April 2018
C) 1st May 2018 D) 1st January 2018
 
Answer & Explanation Answer: B) 1st April 2018

Explanation:

As per the decision of the GST Council, e-Way Bill system has been rolled out from 1st of April this year (2018).

Report Error

View Answer Report Error Discuss

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

3 2379
Q:

Which was the only Indus site with an artificial brick dockyard?

A) Lothal B) Dholka
C) Both A & B D) None of the above
 
Answer & Explanation Answer: A) Lothal

Explanation:
Report Error

View Answer Report Error Discuss

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

3 2379
Q:

Which of the following Indian cities is known as City of Roses?

A) Hyderabad B) Kolkata
C) Mumbai D) Chandigarh
 
Answer & Explanation Answer: D) Chandigarh

Explanation:

Among the Indian cities Chandigarh is known as City of Roses.

Report Error

View Answer Report Error Discuss

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

3 2378
Q:

Which of the following statement(s) is/are CORRECT?

A) Oxides of non-metals are basic B) Oxides of non-metals are acidic
C) Oxides of metals are acidic D) All options are correct
 
Answer & Explanation Answer: B) Oxides of non-metals are acidic

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Chemistry
Exam Prep: Bank Exams

1 2378