Xác định yêu cầu, các lớp, thuộc tính, phương thức: -_ Xây dựng lớp danh sách liên kết đơn - _ Xây dựng lớp đa thức - _ Xây dụng hàm main - Ham toan tl nhập, xuất, cộng, trừ, nhân 2 đa
Ham x6a mot nut khdi danh sach 1lién két void deleteNode (Node<T>* p) {
if (!p) { return; if (p == head) { head = p->getNext ();
/⁄/ trẻ đến ptu trudc ptu p while (current && current-—>getNext() != p) { current = current->getNext(); if (current) { current-—>setNext (p->getNext ()); delete p;
/⁄/ Toán tử nhân hai đa thức Dathuc operator* (Dathuc other) {
The algorithm multiplies two polynomials represented as linked lists It iterates through both lists, multiplying the coefficients and adding the exponents of the terms The resulting coefficients and exponents are then added to the product linked list.
// Cộng các đa thức có cùng số bậc product.combineTerms (); return product; int main() { Dathuc pl, p2, sum, diff, product; cout pl; cout > p2; cout SetTuoi (temp->GetTuoi(});
// Cuéi cting, no tién hanh dé quy vao con phai dé xdoa node có gtri
// nhỏ nhất bên phải đi vì đã gán vào vị trí của node muốn xóa rồi
// cap nhật con phải của node hiện tai bang cây con phải Sau khi xóa node->SetRight (Delete (node->GetRight(), temp->GetMSV())); return node;
SinhVien* Update(SinhVien* node, int MSV, string HoTen, int Tuoi) {
Delete(node, MSV); return Insert (node, MSV, HoTen, Tuoi);
SinhVien* FindMin(SinhVien* node) { while (node->GetLeft() != nullptr) { node = node->GetLeft(); return node;
SinhVien* Search(SinhVien* node, int MSV) { if (node == nullptr || node->GetMSV() == MSV) { return node;
} else if (MSV < node->GetMSV(}) { return Search(node->GetLeft(), MSV);
} else { return Search(node->GetRight(), MSV); void InOrder(SinhVien* node) { if (mode != nullptr) {
InOrder (node->GetLeft())}; cout