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

Amazon Rainforest Forests are located in which continent?

A) South America B) Australia
C) North America D) Antarctica
 
Answer & Explanation Answer: A) South America

Explanation:

Amazon Rainforest Forests are located in South America.

Report Error

View Answer Report Error Discuss

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

7 2382
Q:

The mass of a mole of NaCl is the

A) 58.44 gm/mol B) 57.25 gm/mol
C) 56.31 gm/mol D) 59.14 gm/mol
 
Answer & Explanation Answer: A) 58.44 gm/mol

Explanation:

To get the mass of a mole of NaCl, we need to add the molar atomic weights of the individual elements i.e, Na and Cl

Atomic weights of Na = 22.99 gm/mol  Cl = 35.45 gm/mol

 

Now, mass of a mole of NaCl = 22.99 + 35.45 = 58.44 gm/mol.

Report Error

View Answer Report Error Discuss

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

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

Explain the difference between fixed and flexible budgets ?

Answer

1. A fixed budget is established for a specific level of activity whereas flexible budget is prepared for various levels of activity.


2. Fixed budget cannot be changed after the period commences, whereas a flexible budget can be changed after the period commence.


3. Fixed budget is more suitable for fixed expenses whereas flexible budget takes both fixed as well as variable expenses in account.


4. Fixed budget includes only fixed costs, whereas a flexible budget includes fixed costs, variable costs and semi variable costs.


5. Fixed budget is mainly used in planning stage whereas flexible budget is used in controlling stage.

Report Error

View answer Workspace Report Error Discuss

Subject: Finance Exam Prep: Bank Exams , CAT
Job Role: Bank Clerk , Bank PO

1 2381
Q:

On election day, voters for President are really voting for

A) Electors B) President
C) The speaker of the House D) Both B & C
 
Answer & Explanation Answer: A) Electors

Explanation:

On election day, voters for The President are really voting for the electors who can elect President.

Report Error

View Answer Report Error Discuss

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

3 2381
Q:

Which state police has launched e-learning portal 'Nipun' for training its personnel?

A) Delhi B) Uttar Pradesh
C) Telangana D) Maharashtra
 
Answer & Explanation Answer: A) Delhi

Explanation:

Delhi state police has launched e-learning portal 'Nipun' for training all its police officers to give up to date information through specialized courses designed by experts.

Report Error

View Answer Report Error Discuss

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

2 2381
Q:

What is XPath?

Answer

XPath is an expressions to select a xml node in an XML document.


It allows the navigation on the XML document to the straight to the element where we need to reach and access the attributes.


 

Report Error

View answer Workspace Report Error Discuss

1 2380