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

In the given question, a part of the sentence is printed in bold. Below the sentence, three alternatives to the bold part are given which may help improve the sentence. Choose the option that reflects the correct use of the phrase in the context of the sentence. In case the given sentence is correct, your answer is (E) i.e. No correction required.

Although I don’t have any special bond with the rank and folder of the Labour Union, I know some top engineers.

(i) in the rank and folders of the Labour Union

(ii) with the rank and portfolio of the Labour Union

(iii) with the rank and file of the Labour Union

A) Only (i) B) Only (ii)
C) Only (iii) D) (i) and (ii)
 
Answer & Explanation Answer: C) Only (iii)

Explanation:
The correct phrase is ‘rank and file’ which means ‘the ordinary members of an organization’.
Report Error

View Answer Report Error Discuss

Filed Under: English

0 2390
Q:

The part of the Himalayas between Tista and Dihang rivers is known as _________ Himalayas.

A) Nepal B) Kashmir
C) Assam D) Jammu
 
Answer & Explanation Answer: C) Assam

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Indian Geography
Exam Prep: Bank Exams

1 2389
Q:

Plant cell walls consist mainly of

A) Chitin B) peptidoglycan
C) cellulose D) chlorophyll
 
Answer & Explanation Answer: C) cellulose

Explanation:

Plant cell walls are mostly made up of the molecule cellulose. Cellulose is a polysaccharide, a complex sugar made of long chains of glucose.

 

The cell wall must be made of thick and strong material as it provides the structural shape of the plant and protection from insects and microorganisms.

Report Error

View Answer Report Error Discuss

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

1 2389
Q:

One of the following was not associated with the Gadar party

A) Lala Hardayal B) Baba Gurdit Singh
C) Mohammad Barkatullah D) Sohan Singh Bhakna
 
Answer & Explanation Answer: B) Baba Gurdit Singh

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: General Awareness
Exam Prep: Bank Exams

1 2389
Q:

The Nobel Literature Prize 2018 has been awarded to

A) Bob Dylan B) Shashi Tharoor
C) George Saunders D) No one
 
Answer & Explanation Answer: D) No one

Explanation:

This is for the first time that no Literature Prize will be given in 70 years because of a #MeToo scandal.

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

Which equation represents a neutralization reaction?

A) 2Al(OH)3(s) ---> Al2O3(s) + 3H2O(l) B) H2SO4(aq) + 2NaOH(aq) ---> Na2SO4(aq) + 2H2O(l)
C) 2H2(g) + O2(g) ---> 2H2O(l) D) H2CO3(aq) ---> CO2(g) + H2O(l)
 
Answer & Explanation Answer: B) H2SO4(aq) + 2NaOH(aq) ---> Na2SO4(aq) + 2H2O(l)

Explanation:

Here in the option B) H2SO4 - Sulfuric acid is reacting with sodium hydroxide (NaOH), a base to produce a salt (Sodium Sulfate), and water (H2O). This is characteristic of of acid-base neutralization reactions.

Report Error

View Answer Report Error Discuss

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

1 2388
Q:

Which nutrient provides maximum energy?

A) Fats B) Carbohydrates
C) Proteins D) None of the above
 
Answer & Explanation Answer: A) Fats

Explanation:

The nutrient which provides the maximum energy is Fat. It provides the energy of 9 calories/gram.

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 2387