Javascript Data Structures and other algorithms