Answer to Question #261251 in C++ for zain

Question #261251

1.      Create a class polynomial to create a linked list that uses class node from task 1 with the following functionalities

a.      Insertion. This function takes as an input the size of polynomial. E.g if the size is 6, the polynomial equation is of degree 6. Then you are required to create the appropriate list.

6x6+ 12x3+5

b.      Deletion. This function deletes the list of the degree of number passed as a parameter. E.g if the number is 7, it is invalid. If it is 2, it deletes the first 2 degrees and the remaining list is 12x3+5

c.      Overload the function of deletion. This function deletes the entire list.

d.      Traversal

e.      Print equation in the following format

6x6+0x5+0x4+ 12x3+0x2+0x1+5


1
Expert's answer
2021-11-04T16:26:03-0400
struct linked_list {
  int coefficient;
  int power;
  char sign
  struct linked_list *next;
};

void print(struct linked_list *list) {
  if (list) {
    std::cout << list-sign << list->coefficient << "x^" << list->power;
    print(list->next);
  } else {
    std::cout << std::endl;
  }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS