Question
I need to use bit or Boolean fields to indicate whether a node pointer is a thread or regular pointer for a double threaded binary
I need to use bit or Boolean fields to indicate whether a node pointer is a thread or regular pointer for a double threaded binary search tree in C++. Not sure how to go about this, so any help would be appreciated. Thanks! Code to be modified is below:
#include "book.h" #include "BinNode.h"
#ifndef BSTNODE_H #define BSTNODE_H
// Simple binary tree node implementation template
public: // Two constructors -- with and without initial values BSTNode() { lc = rc = NULL; } BSTNode(Key K, E e, BSTNode* l = NULL, BSTNode* r = NULL) { k = K; it = e; lc = l; rc = r; } ~BSTNode() {} // Destructor
// Functions to set and return the value and key E& element() { return it; } void setElement(const E& e) { it = e; } Key& key() { return k; } void setKey(const Key& K) { k = K; }
// Functions to set and return the children inline BSTNode* left() const { return lc; } void setLeft(BinNode
// Return true if it is a leaf, false otherwise bool isLeaf() { return (lc == NULL) && (rc == NULL); } }; #endif
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started