Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 class BSTNode : public BinNode { private: Key k; // The node's key E it; // The node's value BSTNode* lc; // Pointer to left child BSTNode* rc; // Pointer to right child

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* b) { lc = (BSTNode*)b; } inline BSTNode* right() const { return rc; } void setRight(BinNode* b) { rc = (BSTNode*)b; }

// 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions

Question

What is Larmors formula? Explain with a suitable example.

Answered: 1 week ago

Question

Understanding Groups

Answered: 1 week ago