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 India Kisan Sabha was founded in

A) 1936 B) 1946
C) 1956 D) 1966
 
Answer & Explanation Answer: A) 1936

Explanation:

All India Kisan Sabha was founded in Lucknow in 1936. Swami Sahajanand Saraswati was elected as its first President.

Report Error

View Answer Report Error Discuss

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

2 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:

Who was the Prime Minister of India during adopting of Article 370 for Jammu & Kashmir?

A) Narendra Modi B) Jawaharlal Nehru
C) Indira Gandhi D) Gulzarilal Nanda
 
Answer & Explanation Answer: B) Jawaharlal Nehru

Explanation:

Article 370 of the Indian constitution used to give special provision to the region of Jammu and Kashmir. It allows the state to have its own constitution, a separate flag and independence over all matters except foreign affairs, defence and communications. It was adopted in 1947 by then Prime Minister Jawaharlal Nehru.

Report Error

View Answer Report Error Discuss

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

18 2380
Q:

The International Human Rights Convention adopted by the United Nations in 1990 relates to

A) Children B) Dasabled
C) Stateless Persons D) Migrant workers
 
Answer & Explanation Answer: A) Children

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: World Organisations

2 2380
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