12.07.2015 Views

Data Structures and Algorithms

Data Structures and Algorithms

Data Structures and Algorithms

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Contents1 Introduction 11.1 What this book is, <strong>and</strong> what it isn’t . . . . . . . . . . . . . . . . 11.2 Assumed knowledge . . . . . . . . . . . . . . . . . . . . . . . . . 11.2.1 Big Oh notation . . . . . . . . . . . . . . . . . . . . . . . 11.2.2 Imperative programming language . . . . . . . . . . . . . 31.2.3 Object oriented concepts . . . . . . . . . . . . . . . . . . 41.3 Pseudocode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.4 Tips for working through the examples . . . . . . . . . . . . . . . 61.5 Book outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.6 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.7 Where can I get the code? . . . . . . . . . . . . . . . . . . . . . . 71.8 Final messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7I <strong>Data</strong> <strong>Structures</strong> 82 Linked Lists 92.1 Singly Linked List . . . . . . . . . . . . . . . . . . . . . . . . . . 92.1.1 Insertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.1.2 Searching . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.1.3 Deletion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.1.4 Traversing the list . . . . . . . . . . . . . . . . . . . . . . 122.1.5 Traversing the list in reverse order . . . . . . . . . . . . . 132.2 Doubly Linked List . . . . . . . . . . . . . . . . . . . . . . . . . . 132.2.1 Insertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.2.2 Deletion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.2.3 Reverse Traversal . . . . . . . . . . . . . . . . . . . . . . . 162.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 Binary Search Tree 193.1 Insertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.2 Searching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.3 Deletion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.4 Finding the parent of a given node . . . . . . . . . . . . . . . . . 243.5 Attaining a reference to a node . . . . . . . . . . . . . . . . . . . 243.6 Finding the smallest <strong>and</strong> largest values in the binary search tree 253.7 Tree Traversals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.7.1 Preorder . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26I

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!