Download presentation
Presentation is loading. Please wait.
1
Abstract Data Types Polynomials CSCI 240
Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Abstract Data Types Polynomials Dale Roberts, Lecturer IUPUI
2
First-class ADT interface for polynomials
template <class Number> class POLY { private: // Implementation-dependent code public: POLY<Number>(Number, int); float eval(float) const; friend POLY operator+(POLY &, POLY &); friend POLY operator*(POLY &, POLY &); };
3
Linked-list implementation of polynomials
Structure of the polynomial node coef expon link
4
Examples a null b -3 10 null
5
Adding Polynomials 3 14 2 8 1 0 a 8 14 -3 10 10 6 b 11 14
2 8 1 0 a -3 10 b 11 14 a->expon == b->expon d 2 8 1 0 a -3 10 b 11 14 -3 10 a->expon < b->expon d
6
Adding Polynomials (Continued)
2 8 1 0 a -3 10 b 11 14 -3 10 2 8 d a->expon > b->expon
7
Circularly Linked Lists
circular list vs. chain ptr 2 8 1 0 avail ptr temp avail ...
8
Deleting a polynomial in constant time using a circular linked-list and an available list.
(2) ptr (1) temp NULL avail
9
Represent polynomial as circular list.
Head Node Represent polynomial as circular list. (1) zero a -1 Zero polynomial (2) others a -1 2 8 1 0
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.