Reference no: EM132662132
Question 1. Write a function that will read one line of input from the terminal. The input is supposed to consists of two parts separated by a colon ‘ : '. As its result, your program should produce a single character as follows.
N: No colon on the line
L: The left part (before the colon) is longer than the right
R. The right part (after the colon) is longer than the left
D: The left and right parts have the same length but are different
S: The left and right parts are exactly same
Use a Queue to keep track of the left part of the line while reading the right part.
Question 2. Give the specification for each of these functions and implement them. Write a complete program to test these functions. I. ListEntry(L, P, T) - The entry (element) at the given position P is returned in T, and the list L remains unchanged.
II. AppendList(L2, L1, L) - Appends the list L2 to the end of the list L1 and returns the appended list L.
III. CopyList(L1,L2) - Returns list L2, which is the copy of the given list L1
Question 3. Consider a linked list to store a polynomial, that is, every node of the linked list has coefficient, exponent and pointer to the next node in the list.
Write a complete program including a function to add two polynomials. The function should accept pointers to the two polynomials as arguments and return the pointer to the resultant polynomial.
Assume that the polynomials passed to the function are in decreasing order on the exponents.
Example: 7x 80 + 5x 50 + 3x 30 + 1 = 0
9x 90 + 6x 60 + 2x 30 + 3 = 0