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

Parallel implementation of the raytracer, You are supposed to do the follow...

You are supposed to do the following: Write a parallel implementation of the raytracer using pthreads. Measure and compare the execution times for (i) the sequential ver

Algorithm to sort a given list by quick sort method, Q. Write down an algor...

Q. Write down an algorithm to sort a given list by making use of Quick sort method. Describe the behaviour of Quick sort when input given to us is already sorted.

Multiple queue, How to create multiple queue on single array?

How to create multiple queue on single array?

Algorithm to insert a node in between any two nodes, Q. Write down an algor...

Q. Write down an algorithm to insert a node in between any two nodes in a linked list         Ans. Insertion of a the node after the given element of the listis as follows

Explain b- tree, B- Tree  A B-tree of order m is an m-way true in which...

B- Tree  A B-tree of order m is an m-way true in which  1)  All leaves are on the similar level 2)  All internal nodes except the root have at most m-1(non-empty) childre

Insert an element after an element pointed by some pointer, Consider a link...

Consider a linked list of n elements. What is the time taken to insert an element after an element pointed by some pointer? O (1)

Variable length codes, Variable length codes (Niveau I) Code the following ...

Variable length codes (Niveau I) Code the following sequence of integers (2, 4, 2, 8, 3, 1, 4, 5, 13, 2) with • unary codes • ? codes • d codes • Rice codes (for a suitable l) and

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

Create a binary tree , Create a class "box" that will contain a random inte...

Create a class "box" that will contain a random integer value v such that O

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