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

I make things short but I am pretty long myself. What am I?

Answer

I am ABBREVIATION that make things short but I am pretty long myself.


 


Example ::


HIV - Human Immuno Virus


WHO - World Health Organization

Report Error

View answer Workspace Report Error Discuss

2 2322
Q:

 Which of the following is required for the DB2 optimizer to consider a hash join strategy?

A) Optimization level 1 or above B) Equijion predicates
C) Registry variable DB_ANTIJOIN=YES D) SORTHEAP large enough to contain the tables being joined
 
Answer & Explanation Answer: B) Equijion predicates

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: IBM Certification

1 2322
Q:

Cranial bones develop

A) within fibrous membranes B) within osseous membranes
C) from cartilage models D) from a tendon
 
Answer & Explanation Answer: A) within fibrous membranes

Explanation:
Report Error

View Answer Report Error Discuss

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

1 2322
Q:

Goosebumps are caused by contractions of the

A) Muscles B) Nerves
C) Bones D) All of the above
 
Answer & Explanation Answer: A) Muscles

Explanation:

Goosebumps are caused by the contraction of the tiny muscles attached to hair follicles. These muscles are arrectores pilorum muscles.

 

Goosebumps_are_caused_by_contractions_of_the1560862968.png image

Report Error

View Answer Report Error Discuss

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

6 2322
Q:

In the following question, out of the four alternatives, select the alternative which best expresses the meaning of the idiom/phrase.

Run out of steam

A) Lose impetus or enthusiasm.   B) To keep going even after losing all energy.
C) Have no more funds to proceed any further D) Build interest as you go along
 
Answer & Explanation Answer: A) Lose impetus or enthusiasm.  

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: English
Exam Prep: CAT , GRE , TOEFL
Job Role: Bank Clerk , Bank PO

0 2322
Q:

Limbs of frog, lizard, bird and human are example of ______ organs.

A) Homogenous B) Heterogeneous
C) Analogous D) Homologous
 
Answer & Explanation Answer: D) Homologous

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Biology

4 2321
Q:

Which part of the female reproductive system prepares itself every month to receive and nurture the growing child?

A) Ovary B) Uterus
C) Vagina D) Cervix
 
Answer & Explanation Answer: B) Uterus

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Biology
Exam Prep: Bank Exams
Job Role: Bank Clerk

6 2320