Posts

Showing posts from June, 2022

Merge Sort |Merge sort in C language|

Image
  Program to Merge two sorted array to a single sorted array code: #include <stdio.h>     void main()     {         int array1[50], array2[50], array3[100], m, n, i, j, k = 0;         printf("\n Enter size of array Array 1: ");         scanf("%d", &m);         printf("\n Enter sorted elements of array 1: \n");         for (i = 0; i < m; i++)          {             scanf("%d", &array1[i]);         }         printf("\n Enter size of array 2: ");         scanf("%d", &n);           printf("\n Enter sorted elements of array 2: \n");         for (i = 0; i < n; i++)          {           ...

|Polynomial Addition| |polynomial addition using linked list|

Image
   Polynomial Addition A = 4x 10 + 3x 6 + 1 B = 3x 10 – 2x 8 + 6x 6 + 8x 4 How Polynomial addition is done? In the above image we perform polynomial addition using linked list We use two pointers i and j for pointing A and B. In this liked list there will be 3 parts they are COEFFICIENT , EXPONENT, LINK (the pointer that points to the next node) First, We compare the Exponent of first element(i) in A and the Exponent of the first element(j) in B. Next, if the coefficient are same then we add and store them in C in form of ( COEFFICIENT , EXPONENT, LINK) ...