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

Insertion sort, Data array A has data series from 1,000,000 to 1 with step ...

Data array A has data series from 1,000,000 to 1 with step size 1, which is in perfect decreasing order. Data array B has data series from 1 to 1,000,000, which is in random order.

Differentiate between nonpersistent and 1-persistent, Differentiate between...

Differentiate between Nonpersistent and 1-persistent Nonpersistent: If the medium is idle, transmit; if the medium is busy, wait an amount of time drawn from a probability dist

Illustrate the operations of the symbol abstract data type, The operations ...

The operations of the Symbol ADT The operations of the Symbol ADT are the following. a==b-returns true if and only if symbols a and bare identical. a symbol bin Unico

Curve, write a c++ program to find out the area of a curve y=f(x) between x...

write a c++ program to find out the area of a curve y=f(x) between x=a and x=b

Graph, For the following graph find the adjacency matrix and adjacency list...

For the following graph find the adjacency matrix and adjacency list representation of the graph.

Explain about hidden-surface, Explain about Hidden-surface Hidden-line...

Explain about Hidden-surface Hidden-line removal refers to wire-frame diagrams without surface rendering and polygonal surfaces with straight edges. Hidden-surface removal ref

Data structure for representing numbers, Your first task will be to come up...

Your first task will be to come up with an appropriate data structure for representing numbers of arbitrary potential length in base 215. You will have to deal with large negative

Explain about the structured types - built-in types, Explain about the Stru...

Explain about the Structured types - Built-In Types Values of the carrier set are not atomic, consisting rather than several atomic values arranged in some way. Common illu

Polynomials, Polynomials like  5x 4    +  2x 3    +  7x 2     +  10x  -  8...

Polynomials like  5x 4    +  2x 3    +  7x 2     +  10x  -  8  can  be  represented by using arrays. Arithmetic operations such as addition & multiplication of polynomials are com

Design a binary tree, (a) Suppose that t is a binary tree of integers (that...

(a) Suppose that t is a binary tree of integers (that is, an object of type BinTree of Int.) in the state shown in Figure 3.   Give the vectors returned by each of the f

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