Skip to content

Practice with binary search trees in Javascript

Notifications You must be signed in to change notification settings

AdaGold/tree-practice-js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Binary Search Tree Practice (JavaScript)

In this exercise you will implement, in JavaScript, several Tree methods.

  • add(value) - This method adds a key-value pair to the Binary Search Tree
  • find(value) - This method returns the matching value for the given key if it is in the tree and None if the key is not found in the tree.
  • Traversals: These methods return an array of objects consisting of all the key-value pairs in the tree in a specific order.
    • inorder - This method returns an array of all the elements in the tree, in order.
    • postorder - This method returns an array of all the elements in a postorder fashion (left, right , root).
    • preorder - This method returns an array of all the elements in a preorder fashion (root, left, right).
  • height - This method returns the height of the binary search tree.

Optionals

  • bfs - This method returns an array with the tree elements in a level-by-level order (see Breadth-First traversal)

Installation

This has been tested with node 12.10.0. To install, run

npm i

after cloning this project.

Testing

Run all tests with:

npm test

About

Practice with binary search trees in Javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 88.6%
  • Dockerfile 11.0%
  • Shell 0.4%