May 2017
Intermediate to advanced
340 pages
8h 16m
English
This process is similar to the first operation that we looked at. The main difference is that we need to find out the specific node and then insert a new node before it. When we find the target node, we can change the next node so that it points to the newly created node, and then we can change the node following the newly created node so that it points to the node that we searched for. This is shown in the following image:

Here is the code to implement the logic shown earlier:
public function insertBefore(string $data = NULL, string $query = NULL) { $newNode = new ListNode($data); if ($this->_firstNode) ...Read now
Unlock full access