Warning: Use of undefined constant fixed - assumed 'fixed' (this will throw an Error in a future version of PHP) in /home/webtro13/domains/farenda.com/public_html/wp-content/themes/moments/header.php on line 65
class="header_container_flat">

How it works

The algorithm consists of two parts. First, we have to find the node we want to remove and remember its predecessor, so that we could connect it to the next node. In the second part, if the node was found, we have to handle two cases. If we remove a node from the first position, it means we are removing the head, therefore we have to promote the next node to be the new head. In every other case we just need to connect previous node with the node after the removed one.

Performance

It’s pretty clear that in the worst case – removal of element from the last position – we have to iterate through whole Linked List. Thus the algorithm runs in linear time – O(n).