logo

CuriousTab

CuriousTab

Discussion


Home Technical Questions Programming Comments

  • 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 


  • Programming problems


    Search Results


    • 1. Write a c program for insertion sort.
    • Discuss
    • 2. Write a c program for quick sort.
    • Discuss
    • 3. Write a c program for selection sort.
    • Discuss
    • 4. Write a c program to print multiplication table
    • Discuss
    • 5. Write a c program to check whether a number is strong or not.
    • Discuss
    • 6. Write a c program for binary search.
    • Discuss
    • 7. Write a program for matrix multiplication in c
    • Discuss
    • 8. Write a c program to copy a data of file to other file.
    • Discuss
    • 9. What will be output of following c code? void main() { struct india { char c; float d; }; struct world { int a[3]; char b; struct india orissa; }; struct world st ={{1,2,3},'P','q',1.4}; clrscr(); printf("%dt%ct%ct%f",st.a[1],st.b,st.orissa.c,st.orissa.d); getch(); }
    • Discuss
    • 10. What is the output of this C code? #include void m() { printf("hi"); } void main() { m(); }

    • Options
    • A. hi
    • B. Run time error
    • C. None
    • D. Varies
    • Discuss


    Comments

    There are no comments.

Enter a new Comment