Linked Lists and Binary Search Trees by Mihailo Despotovic, July 2005 and January 2011

The two classic interview data structures, from my C practice files: a singly linked list of names (2005) and a binary search tree of numbers (2011). Every function is animated step by step, with the pointers it uses. C leaves memory to the programmer, and that is where my bugs were: the programs print the right thing, but forget to free some memory, free the wrong thing, or crash on an empty list. Switch between my code and the fixed version to see the difference.

As I wrote it: the bugs are in memory handling, so the printed output looks right.

Linked list list.c, July 2005

Printed:

        
    

Binary search tree tree.c, January 2011

Printed:

        
    
The original C code