In binary search tree we have the node strucure as
class Node
{
public:
int key;
Node *left;
Node *right;
};
So while creating a node we do
Node* createNode(int key)
{
Node *node=new Node();
node->key=key;
node->left=NULL;
node->right=NULL;
return node;
}
Now i want key ad 2d matrix instead of integer key. Something like this
class Node
{
public:
char matrix[3][3];
Node *left;
Node *right;
};
How to create node now?
Node* createNode(char key[3][3])
{
Node *node=new Node();
node->matrix=key; //This line
return node;
}
In C++ it is equally simple:
In C that would be
Note that the C way works in C++ as well, but you should prefer containers to plain pointers whenever you can.