Skip to content

Instantly share code, notes, and snippets.

@Shurlow
Last active December 17, 2018 18:01
Show Gist options
  • Save Shurlow/f2a2cffe9d1497cf5c2bae1e9a958485 to your computer and use it in GitHub Desktop.
Save Shurlow/f2a2cffe9d1497cf5c2bae1e9a958485 to your computer and use it in GitHub Desktop.
Binary Search Trees Lesson Notes

Binary Search Trees

Objectives

  • Define what a binary search tree is
  • Explain why binary search trees are useful
  • Write pseudo code to traverse a binary search tree
  • Explain the difference between depth first search methods (pre-order, in-order, post-order)
  • Describe the Big O of binary search tree methods
  • Implement binary search tree methods

Guiding Questions

  • What is a binary search tree? What are it's restrictions? When might they useful?

    Your answer...

  • Diagram the following set of numbers as a binary search tree:

    • 1, 3, 4
    • 3, 1, 4
    • 5, 3, 8, 4, 0, 6, 7

    Your answer...

  • How do you traverse a binary search tree? What is depth first search? How do Pre-order, In-order and Post-order differ?

    Your answer...

  • What is the Big-O of Binary Search Trees methods (best and worst case):

    • Insert
    • Remove
    • Lookup
    • Traverse

    Your answer...

  • Practice working with trees

    https://github.com/gSchool/trees-assessment

Resources

Implementation

Start by forking and cloning the checkpoint repo: https://github.com/gSchool/binary-search-trees Implement the following methods on the BinarySearchTree class:

  • insert()
  • DFSPreOrder()
  • DFSPostOrder()
  • findDFS()
  • size()
  • breadthFirstSearch()
  • findBFS()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment