From 44e8fcb086de5ae7f0032199294c6eda47243bf0 Mon Sep 17 00:00:00 2001 From: Martin Mares <mj@ucw.cz> Date: Wed, 6 Mar 2019 18:10:44 +0100 Subject: [PATCH] Splay operation: We will need virtual methods for assignment 03 The experiments in assignment 03 needs to override some methods from the Splay tree implemention. --- 02-splay_operation/cpp/splay_operation.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/02-splay_operation/cpp/splay_operation.h b/02-splay_operation/cpp/splay_operation.h index a4f03e8..5d7bd11 100644 --- a/02-splay_operation/cpp/splay_operation.h +++ b/02-splay_operation/cpp/splay_operation.h @@ -30,7 +30,7 @@ class Tree { // Rotate the given `node` up. Perform a single rotation of the edge // between the node and its parent, choosing left or right rotation // appropriately. - void rotate(Node* node) { + virtual void rotate(Node* node) { if (node->parent) { if (node->parent->left == node) { if (node->right) node->right->parent = node->parent; @@ -133,7 +133,7 @@ class Tree { // Splay the given node. // If a single rotation needs to be performed, perform it as the last rotation // (i.e., to move the splayed node to the root of the tree). - void splay(Node* node) { + virtual void splay(Node* node) { // TODO: Implement } -- GitLab