logo

CuriousTab

CuriousTab

Discussion


Home Technical Questions Programming See What Others Are Saying!
  • Question
  • Write a c program for merge sort.


  • Correct 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;imid){ 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 


  • More questions

    • 1. In the relational model, relationships between relations or tables are created by using:

    • Options
    • A. composite keys.
    • B. determinants.
    • C. candidate keys.
    • D. foreign keys.
    • Discuss
    • 2. What does microprocessor speed depend on?
    • Discuss
    • 3. What does RSI stand for?
    • Discuss
    • 4. Which Stack is used in 8086?
    • Discuss
    • 5. What is object repository?
    • Discuss
    • 6. Which is the Stack used in 8085?
    • Discuss
    • 7. What does GUI stand for?
    • Discuss
    • 8. What is the main reason the OSI Model was created?
    • Discuss
    • 9. Ethernet uses which topology

    • Options
    • A. Star
    • B. Bus
    • C. Twisted pair
    • D. Both B & C
    • Discuss
    • 10. What are various scheduling queues?
    • Discuss


    Comments

    There are no comments.

Enter a new Comment