Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Only 14.5,14.9 Only 14.5,14.9 (C++) P14.5 Write a class Polynomial that stores a polynomial such as P(X) = 5x10 + 9x?-X-10 as a linked list
Only 14.5,14.9Only 14.5,14.9 (C++)
P14.5 Write a class Polynomial that stores a polynomial such as P(X) = 5x10 + 9x?-X-10 as a linked list of terms. A term contains the coefficient and the power of x. For example, you would store p(x) as (5,10).69.7).(-1,1),(-10,0) Supply member functions to add, multiply, and print polynomials. Supply a constructor that makes a polynomial from a single term. For example, the polynomial p can be constructed as Polynomial p(Term-10, 0)); p.add(Polynonial(Tern(-1, 1))); p.add(Polynonial (Tern(9, 7)}); p.add(Polynonial(Tern(5, 10))); Then compute p(x) x p(x). Polynonial q = p.nultiply(p); q.print(); - P14.6 Using a queue of vectors, implement a non-recursive variant of the merge sort algorithm as follows. Start by inserting vectors of length 1 for each element into the queue. Keep removing pairs of vectors from the queue, merging them into a single vector, and adding the result back into the queue. Stop when the queue has size 1. ... P14.7 In a paint program, a "flood fill" fills all empty pixels of a drawing with a given color, stopping when it reaches occupied pixels. In this exercise, you will implement a simple variation of this algorithm, flood-filling a 10 x 10 array of integers that are initially Prompt for the starting row and column. Push the Crow, colm) pair on a stock. You will need to provide a simple Pair class. Repeat the following operations until the stack is empty: Pop off the Crow, column) pair from the top of the stack. if it has not yet been filled, fill th corresponding array location with numbers 1, 2, 3, and so on (to show the order in which the square is filled) Push the coordinates of any unfilled neighbors in the north, east, south, or west direction on the stock. When you are done, print the entire array. ... P14.8 Repeat Exercise ... P14.7, but use a queue instead. ...P14.9 Modify the expression calculator of Section 14.6.3 to convert an expression into reverse Polish notation. Hint: Instead of evaluating the top and pushing the result, append the instructions to a string, 0. P14.5 Write a class Polynomial that stores a polynomial such as P(X) = 5x10 + 9x?-X-10 as a linked list of terms. A term contains the coefficient and the power of x. For example, you would store p(x) as (5,10).69.7).(-1,1),(-10,0) Supply member functions to add, multiply, and print polynomials. Supply a constructor that makes a polynomial from a single term. For example, the polynomial p can be constructed as Polynomial p(Term-10, 0)); p.add(Polynonial(Tern(-1, 1))); p.add(Polynonial (Tern(9, 7)}); p.add(Polynonial(Tern(5, 10))); Then compute p(x) x p(x). Polynonial q = p.nultiply(p); q.print(); - P14.6 Using a queue of vectors, implement a non-recursive variant of the merge sort algorithm as follows. Start by inserting vectors of length 1 for each element into the queue. Keep removing pairs of vectors from the queue, merging them into a single vector, and adding the result back into the queue. Stop when the queue has size 1. ... P14.7 In a paint program, a "flood fill" fills all empty pixels of a drawing with a given color, stopping when it reaches occupied pixels. In this exercise, you will implement a simple variation of this algorithm, flood-filling a 10 x 10 array of integers that are initially Prompt for the starting row and column. Push the Crow, colm) pair on a stock. You will need to provide a simple Pair class. Repeat the following operations until the stack is empty: Pop off the Crow, column) pair from the top of the stack. if it has not yet been filled, fill th corresponding array location with numbers 1, 2, 3, and so on (to show the order in which the square is filled) Push the coordinates of any unfilled neighbors in the north, east, south, or west direction on the stock. When you are done, print the entire array. ... P14.8 Repeat Exercise ... P14.7, but use a queue instead. ...P14.9 Modify the expression calculator of Section 14.6.3 to convert an expression into reverse Polish notation. Hint: Instead of evaluating the top and pushing the result, append the instructions to a string, 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started