Skip to main content

Polynomial Addition using Linked List

Given two polynomial numbers represented by a linked list. Write a function that add these lists means add the coefficients who have same variable powers.


Linked List : It is a data structure that stores each element as an object in a node of the list. every node contains three parts two integer part for coefficient(c), exponent(e) and one for next pointer.


A linked list that is used to store Polynomial looks like −

Polynomial : 4x7 + 12x2 + 45


This is how a linked list represented polynomial looks like.

Adding two polynomials that are represented by a linked list. We check values at the exponent value of the node. For the same values of exponent, we will add the coefficients.

Example,

 Input :  
 p1= 13x8 + 7x5 + 32x2 + 54  
 p2= 3x12 + 17x5 + 3x3 + 98  
   
 Output : 3x12 + 13x8 + 24x5 + 3x3 + 32x2 + 152  


Check out Code Here 👇

Code can get updated so also come back later to see if there is any changes. Also if there is any problem with code you can comment below. If you like it, do share with your friends.😊

Comments

Popular posts from this blog

Bouncing Ball

Group B   Practical 4 a   Problem Statement :   Write a C++ program to implement bouncing ball using sine wave form. Apply the concept of polymorphism. Check Out Code Here  ðŸ‘‡ Outputs :  Code can get updated so also come back later to see if there is any changes. Also if there is any problem with code you can comment below. If you like it, do share with your friends.😊

2D Object Transformations

  Group B   Practical 4 a   Problem Statement :    Write C++ program to draw 2-D object and perform following basic transformations a) Scaling b) Translation c) Rotation. Apply the concept of operator overloading. Check Out Code Here  ðŸ‘‡ Output : a) Scaling - b) Translation - c) Rotation - Code can get updated so also come back later to see if there is any changes. Also if there is any problem with code you can comment below. If you like it, do share with your friends.😊

OOP 4

  Object Oriented Programming Group B - Practical : 4 Problem Statement :  Write a C++ program that creates an output file, writes information to it, closes the file, open it again as an input file and read the information from the file. Check Out Code Here  ðŸ‘‡ Code can get updated so also come back later to see if there is any changes. Also if there is any problem with code you can comment below. If you like it, do share with your friends.😊