Demonstration of polynomial using linked list, Data Structure & Algorithms

Assignment Help:

Demonstration of Polynomial using Linked List

# include

# include

Struct link

{

Char sign; intcoef; int expo;

struct link *next;

};

Typedefstruct link poly; void insertion (poly *); void create_poly (poly *); void display (poly *);

/* Function create a ploynomial list */

voidcreate_poly (poly *start)

{

charch;

staticinti;

printf("\n Input choice n for break: ");

ch = getchar ();

if (ch != 'n')

{

print f("\n Input the sign: %d: ", i+1);

scanf("%c", &start->sign);

printf("\n Input the coefficient value: %d: ", i+1);

scanf("%d", &start->coef);

printf("\n Input the exponent value: %d: ", i+1);

scanf("%d", &start->expo);

}

else

flush(stdin);

i++;

start->next = (poly *) malloc(size of(poly));

create_poly(start->next);

start->next=NULL;

}

/* Display the polynomial */

void display(poly *start)

{

If(start->next != NULL)

{

Printf(" %c", start->sign);

printf(" %d", start->coef);

printf("X^%d", start->expo);

display(start->next);

}

}

/* counting the number of nodes */

Int count poly(poly *start)

{

Lists

If(start->next == NULL)

return 0;

else

}

Return(1+count_poly(start->next));

/* Function main */

void main()

{           poly *head = (poly *) malloc(sizeof(poly));

Create poly(head);

Printf("\n Total nodes = %d \n", count poly(head));

Display (head) ;}

Program: Representation of Polynomial using Linked list


Related Discussions:- Demonstration of polynomial using linked list

Just a quick couple questions, I was wanting to know where this web site wa...

I was wanting to know where this web site was created. My second question is,,, are the online tuters accredited teachers? If they are, are they only working for the website or ma

Representation of max-heap sequentially, Q. How do we represent a max-heap ...

Q. How do we represent a max-heap sequentially? Explain by taking a valid   example.         Ans: A max heap is also called as a descending heap, of size n is an almos

Explain the sum of subset problem, a. Explain the sum of subset problem. Ap...

a. Explain the sum of subset problem. Apply backtracking to solve the following instance of sum of subset problem: w= (3, 4, 5, 6} and d = 13. Briefly define the method using a sta

What is bubble sort, What is bubble sort? Bubble Sort: The basic ide...

What is bubble sort? Bubble Sort: The basic idea in bubble sort is to scan the array to be sorted sequentially various times. Every pass puts the largest element in its corr

Recursive function , Q. Write down the recursive function to count the numb...

Q. Write down the recursive function to count the number of the nodes in the binary tree.    A n s . R ecursive Function to count no. of Nodes in Binary Tree is writt

Nested for loop, nested for loop for (i = 0; i for (j = 0; j seq...

nested for loop for (i = 0; i for (j = 0; j sequence of statements } } Here, we observe that, the outer loop executes n times. Every time the outer loop execute

Sorting algorithm is best if the list is already sorted, Which sorting algo...

Which sorting algorithm is best if the list is already sorted? Why? Insertion sort as there is no movement of data if the list is already sorted and complexity is of the order

Calculate the k-th power and recursive algorithem, 1. The following is a r...

1. The following is a recursive algorithm to calculate the k -th power of 2. Input k a natural number Output kth power of 2 Algorithem: If k =0then return 1 Else return 2* po

Reverse order of elements on a slack, Q. Describe the representations of gr...

Q. Describe the representations of graph. Represent the graph which is given to us using any two methods Ans: The different ways by which we can represent graphs are:

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd