class List ( int value; List next; ); void printList( List source; ) { print( "{ " ); while ( source != null ) { print( source.value ); source = source.next; if ( source != null ) print( ", " ); }; println( " }" ); }; void createNode( int level; var List dest; int value; List next; ) { dest = new List{ value, next }; }; void deleteNode( int level; List source; var List dest; int value; ) { if ( source == null || value < source.value ) { dest = source; } else if ( value == source.value ) { dest = source.next; // Show state at this point } else { createNode( level + 1, dest, source.value, null ); deleteNode( level + 1, source.next, dest.next, value ); // Inside the above invocation } }; List source, a2, a4, a6, a8, a10, dest; a10 = new List{ 10, null }; a8 = new List{ 8, a10 }; a6 = new List{ 6, a8 }; a4 = new List{ 4, a6 }; a2 = new List{ 2, a4 }; source = a2; deleteNode( 0, source, dest, 6 ); // Inside this invocation printList( source ); printList( dest );