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

Which state declared dolphin as State aquatic animal?

A) Telangana B) Uttar Pradesh
C) Punjab D) Goa
 
Answer & Explanation Answer: C) Punjab

Explanation:

The Punjab state declared dolphin as State aquatic animal.

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

A passage is given with five questions following it. Read the passage carefully and select the best answer to each question out of the given four alternatives.

 

Teaching about compassion and empathy in schools can help deal with problems of climate change and environmental degradation,” says Barbara Maas, secretary,
Standing Committee for Environment and Conservation, International Buddhist Confederation (IBC). She was in New Delhi to participate in the IBC’s governing
council meeting, December 10-11, 2017. “We started an awareness campaign in the year 2005-2006 with H H The Dalai Lama when we learnt that tiger skins were
being traded in China and Tibet. At that time, I was not a Buddhist; I wrote to the Dalai Lama asking him to say that ‘this is harmful’ and he wrote back to say, “We
will stop this.” He used very strong words during the Kalachakra in 2006, when he said, ‘If he sees people wearing fur and skins, he doesn’t feel like living. ‘This sent
huge shock waves in the Himalayan community. Within six months, in Lhasa, people ripped the fur trim of their tubba, the traditional Tibetan dress.

 

The messenger was ideal and the audience was receptive,” says Maas who is a conservationist. She has studied the battered fox’s behavioral ecology in Serengeti, Africa. She heads the endangered species conservation at the Nature and Biodiversity Conservation Union (NABU) International Foundation for Nature, Berlin. “I met Samdhong Rinpoche, The Karmapa, HH the Dalai Lama and Geshe Lhakdor and I thought, if by being a Buddhist, you become like this, I am going for it, “says Maas, who led the IBC initiative for including the Buddhist perspective to the global discourse on climate change by presenting the statement, ‘The Time to Act is Now: a Buddhist Declaration on Climate Change,’ at COP21 in Paris.

 

“It was for the first time in the history of Buddhism that leaders of different sanghas came together to take a stand on anything! The statement lists a couple of important things: the first is that we amass things that we don’t need; there is overpopulation; we need to live with contentment and deal with each other and the environment with love and compassion,” elaborates Maas. She is an ardent advocate of a vegan diet because “consuming meat and milk globally contributes more to climate change than all "transport in the world.”

 

Turning vegetarian or vegan usually requires complete change of perspective before one gives up eating their favorite food. What are the Buddhist ways to bring about this kind of change at the individual level? “To change our behavior, Buddhism is an ideal vehicle; it made me a more contented person,” says Maas, who grew up in Germany, as a sausage chomping, meat-loving individual. She says, “If I can change, so can anybody”.

 

Why is Ms. Barbara an ardent follower of vegan diet?

 

A) She believes that “consuming meat and milk contributes more to climate change than all transport in the world”. B) She believes that “turning vegan gives your skin an unmatchable glow and helps you stay away from diseases”.
C) She believes that “all living beings should be treated with love and compassion”. D) She believes that “abstinence helps you win major battles of life”.
 
Answer & Explanation Answer: A) She believes that “consuming meat and milk contributes more to climate change than all transport in the world”.

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: English
Exam Prep: Bank Exams

0 2426
Q:

Read the passage carefully and choose the best answer to each question out of the four alternatives and click the button corresponding to it.

We set out for the gallows. Two warders marched on either side of the prisoner, with their rifles at the slope; two others marched close against him, gripping him by his arm and shoulder, as though, at once pushing and supporting him. The rest of us, magistrates and the like, followed behind. Suddenly, when we had gone ten yards, the procession stopped short without any order or warning. A dreadful thing had happened ­ a dog, come goodness knows whence, had appeared in the yard. It came bounding among us with a loud volley of barks, and leapt round us wagging its whole body, wild with glee at finding so many human beings together. It was a large woolly dog, half Airedale, half Pariah. For a moment, it pranced round us, and then, before anyone could stop it, it had made a dash for the prisoner, and jumping up tried to lick his face. Everyone stood aghast, too taken aback even to grab at the dog.

What was surprising about the actions of the dog?

A) It ran up and down the path B) It bit the guards
C) It barked at the magistrates D) It licked the prisoner's face
 
Answer & Explanation Answer: D) It licked the prisoner's face

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: English
Exam Prep: Bank Exams

0 2426
Q:

In what city would you find the Kowloon peninsula?

Answer

Hong Kong

Report Error

View answer Workspace Report Error Discuss

Subject: World Geography

0 2425
Q:

Which countries launched a common digital currency "Aber"?

A) UAE & Saudi Arabia B) Saudi Arabia & Iraq
C) Iraq & UAE D) Malaysia & UAE
 
Answer & Explanation Answer: A) UAE & Saudi Arabia

Explanation:

The United Arab Emirates (UAE) central bank (UAECB) and the Saudi Arabian Monetary Authority (SAMA) have announced that the interbank digital currency they are co-developing will be called 'Aber.'

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

At which stage in its life cycle does the silkworm yield the fiber of commercial use

A) Larva B) Egg
C) Pupa D) Imago
 
Answer & Explanation Answer: C) Pupa

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Biology
Exam Prep: Bank Exams

3 2425
Q:

The bar graph shows the number of employees working in the different departments of a company. Study the diagram and answer the following questions

Which department has the lowest number of employees?

A) C B) D
C) A D) B
 
Answer & Explanation Answer: B) D

Explanation:
Report Error

View Answer Report Error Discuss

1 2424