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

Java, Ask consider the file name cars.text each line in the file contains i...

Ask consider the file name cars.text each line in the file contains information about a car ( year,company,manufacture,model name,type) 1-read the file 2-add each car which is repr

Discrete time simulation of a queue, In this project you will write a progr...

In this project you will write a program to produce a discrete time simulation of a queue as shown in Fig. 1. Time is slotted on the input and the output. Each input packet follows

Graph, adjacency multilist

adjacency multilist

Compare and contrast various sorting techniques, Q. Compare and contrast va...

Q. Compare and contrast various sorting techniques or methods with respect to the memory space and the computing time.

Non-recursive algorithm, Q .  Write down the non-recursive algorithm to tra...

Q .  Write down the non-recursive algorithm to traverse a tree in preorder. Ans: T he Non- Recursive algorithm for preorder traversal is written below: Initially i

Write functions for both addition and subtraction, You will write functions...

You will write functions for both addition and subtraction of two numbers encoded in your data structure. These functions should not be hard to write. Remember how you add and subt

Explain the concept of colouring, Colouring The use of colours in CAD/C...

Colouring The use of colours in CAD/CAM has two main objectives : facilitate creating geometry and display images. Colours can be used in geometric construction. In this case,

Define linked list ?, Linked lists are among the most common and easiest da...

Linked lists are among the most common and easiest data structures. They may be used to implement various other common abstract data types, including queues, stacks, symbolic expre

Two sparce matrices multipilcation algorithm, Write an algorithm for multi...

Write an algorithm for multiplication of two sparse matrices using Linked Lists.

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