I am trying to implement Dynamic graph using Treap data structue.
Here is node structure:
    class TreapNode
    {
        public:
                int key;
                int priority;
                TreapNode* left, *right;
                vector<int> neighbourNode;
                
                TreapNode(int key)
                {
                    this->priority = 0;
                    this->key = key;
                    this->left  = nullptr;
                    this->right = nullptr;
                }
                
                TreapNode()
                {}
                
                TreapNode* addNode(TreapNode*&,int);
                void updateNode(TreapNode*&,int,int);
     };          
     
When I want to add neighbouring node to particular node,
- I search the node , and then add neighbouring node to search node's 
vector<int> neighbourNodethroughupdateNode(), in the following way. 
searchAddress->neighbourNode.push_back(x);
But my professor says, store address of vector<int> neighbourNode in the node.
- Is it going to reduce my TreapNode size ?
 - How to store address and access it ? I tried this way in TreapNode class but it is giving 
neighbourNodeundefine error. 
int* neighbourNodeAddress = neighbourNode.data()
Can anyone help me ?
Aucun commentaire:
Enregistrer un commentaire