Hi, I am trying to implement a priority queue (minheap) using pointers and a struct for my nodes for an assignment and I was wondering about something. My class supports a function deleteMin() which basically gets the root address which I have stored and deletes the data and key and replaces them with those of the last node on the tree and then rearranges the tree from top to bottom with comparisons. My question is this: As far the last node is concerned from which I took the data I change the pointer of its father to him to NULL so basically that node is disconnected from the tree. However that memory is not freed, right? It's still associated with the program? If it is I was wondering how I can free it so that memory address can be used in the future. I was thinking to use the command delete [pointer to ex-last node] but this will just erase the pointer, right?
I apologise for being so confusing
example of code
Code:/*lst is a ponter to struct node and currently points to the last most right node of the tree*/ setLstNode(lst->father->l_ch); //Function assigns the new last node to be the right child //of the father of the ex-last node lst->father->r_ch=NULL; //assigning NULL to right child of father delete lst; //This probably doesnt do a thing right?