You are viewing a single comment's thread. Return to all comments →
function insertNodeAtPosition($llist, $data, $position) { if($position == 0) { $node = new SinglyLinkedListNode($data); $node->next = $llist; return $node; } $llist->next = insertNodeAtPosition($llist->next, $data, $position - 1); return $llist; }
Seems like cookies are disabled on this browser, please enable them to open this website
Insert a node at a specific position in a linked list
You are viewing a single comment's thread. Return to all comments →