Giter Club home page Giter Club logo

data_structure_review's Introduction

BinarySearch Tree

Binary search trees have impressive performance characteristics since all operations can be done in O(log(n)) time on average. However, this is not always the case if a tree is unbalanced (more nodes on one side than another). The worst case runtime for a BST can be O(n) if a tree is completely unbalanced (there are much more complex data structures like AVL and Red-Black Trees which balance themselves to prevent these kinds of issues).

Operation Average Runtime search O(log(n)) insert O(log(n)) delete O(log(n)) space complexity O(n)

Depth First Search

Preorder:

  1. Visit the root
  2. Traverse the left subtree
  3. Traverse the right subtree

InOrder:

  1. Traverse the left subtree
  2. Visit the root
  3. Traverse the right subtree

PostOrder

  1. Traverse the left subtree
  2. Traverse the right subtree
  3. Visit the root

Breadth First Search

  1. start at the root
  2. place the root node in a queue
  3. while there is anything in the queue
  4. remove the first element in the queue (dequeue)
  5. if what has been dequeued has a left node
  6. enqueue the left node
  7. if what has been dequeued has a right node
  8. enqueue the right node

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.