Normally, I would just input head = new Node
in main, which would set everything up, but the stipulation is that I do not have permission to mess with global variables. This is an assignment where I only have access to main, and due to other backend features, I have to leave the global variables intact so I can't overwrite it with head = new Node
.
The point is just to add characters to a linked list. I just hardcoded inserting one just as an example, but I still can't avoid the error.
Is there a correct way to add them?
struct Node{
char key;
Node *next;
};
Node *head = NULL;
int main(){
char x = 'a';
cout<<x<<endl;
head->key=x;
}
assignment: Find all nodes in a BST that are between a given range of values. Then build a linked list of the values and the list should be in ascending order.
NOTE: the head of the linked list is declared globally in the back end and its initial value is NULL. Just add the nodes to the linked list using head. The printing of the linked list will also be done in the backend. Helper functions can be used.
void RangeSearch(TreeNode *node, char m, char n);