Contains the source code from the course work throughout my undergraduate Computer Engineering degree at Brigham Young University. There is a mixture of Go, Python, C, C++, Java, VHDL, Verilog, Matlab, Bash, Assembly, etc..
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PolynomialListInterface.h 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //YOU MAY NOT MODIFY THIS DOCUMENT
  2. #pragma once
  3. #include <string>
  4. using namespace std;
  5. class PolynomialListInterface
  6. {
  7. public:
  8. /*
  9. * You must create a Node class that will hold each polynomial segment and will be used to create the
  10. * links in your PolynomialList.
  11. * Your Node will likely have 3 private variables in addition to a Node * next you may have.
  12. * These 3 variables will be for the Coefficient, the Variable, and the Exponent respectively.
  13. * i.e. 2x^7
  14. * Coefficient = 2
  15. * Variable = x
  16. * Exponent = 7
  17. */
  18. PolynomialListInterface(void){}
  19. virtual ~PolynomialListInterface(void){}
  20. /*
  21. insert
  22. A node with the given term should be inserted at the appropriate spot in the list.
  23. A term can be accepted only with Coefficient value > 0, and exponent value non-negative.
  24. If the term is invalid, do not add it to the list.
  25. i.e. If the given term segment is 3x^5 and your list contains 2x^8, x^4, 11x^2
  26. the node should be added after 2x^8. Your updated list should look like 2x^8, 3x^5, x^4, 11x^2.
  27. */
  28. virtual void insert(string term) = 0;
  29. /*
  30. clear
  31. Remove all nodes from the list.
  32. */
  33. virtual void clear() = 0;
  34. /*
  35. at
  36. Returns the polynomial of the node at the given index. The list begins at
  37. index 0.
  38. If the given index is out of range of the list, return "invalid";
  39. */
  40. virtual string at(int index) = 0;
  41. /*
  42. size
  43. Returns the number of nodes in the list.
  44. */
  45. virtual int size() = 0;
  46. /*
  47. * This function should string together all of the nodes and print out the entire polynomial separated with '+' signs.
  48. * If an exponent of 0 exists however, you should print only the Coefficient.
  49. * i.e. list of Nodes = (2x^4)->(4x^2)->(3x^1)->(11x^0)
  50. * printList() = return "2 x ^ 4 + 4 x ^ 2 + 3 x ^ 1 + 11 x";
  51. */
  52. virtual string printList() = 0;
  53. };