inserting an element at the head of singly linked list an important property of linked list is that it does not have predetermined fixed sizeit uses space proportionally to its current number of elements when using singly linked listwe can easily insert an element at the head of the listas shown in figure and described with pseudo-code in code fragment the main idea is that we create new nodeset its element to the new elementset its next link to refer to the current headand then set the list' head to point to the new node head msp atl bos (anewest head lax msp atl bos (bnewest lax head msp atl bos (cfigure insertion of an element at the head of singly linked list(abefore the insertion(bafter creation of new node(cafter reassignment of the head reference algorithm add first(le)newest node( {create new node instance storing reference to element enewest next head {set new node' next to reference the old head nodel head newest {set variable head to reference the new nodel size size {increment the node countcode fragment inserting new element at the beginning of singly linked list note that we set the next pointer of the new node before we reassign variable head to it if the list were initially empty ( head is none)then natural consequence is that the new node has its next reference set to none