Coder Social home page Coder Social logo

ts-data-structures's Introduction

bun-start

To install dependencies:

bun install

To run:

bun run index.ts

This project was created using bun init in bun v1.0.11. Bun is a fast all-in-one JavaScript runtime.

ts-data-structures's People

Contributors

mg901 avatar

Stargazers

Sergey Udachin avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

shembel

ts-data-structures's Issues

Binary Tree

Tree

Image

Basic Concepts

  • The height of a node is the length of the longest downward path to a leaf from that node. The height of the root is the height of the tree. Conventionally, an empty tree (tree with no nodes, if such are allowed) has height โˆ’1.
  • The depth of a node is the length of the path to its root.

Binary Tree Node

interface BinaryTreeNode<T> extends Node<T> {
  left? BinaryTreeNode<T> | null
  right?: BinaryTreeNode<T> | null
  setLeft(value: T): this
  setRight(value: T): this
  removeChild(node: BinaryTreeNode<T>): boolean
}

setLeft or setRight method

  1. Should disconnect the existing child node before setting a new one.
  2. Should set child.

binary search tree

Binary Search Tree

interface BinarySearchTree<T> {
  root: BinarySearchTreeNode<T> | null
  insert(value: T): void
  contains(value: T): boolean
  remove(value: T): boolean
  toString(): string
}

Binary Search Tree Node

interface BinarySearchTreeNode<T> extends BinaryTreeNode<T> {
  insert(value): void
  find(value: T): BinariSearchTreeNode<T> | null
  contains(value: T): boolean
  remove(value: T): boolean
  findMin(): BinarySearchTreeNode<T>
  findMax(): BinarySearchTreeNode<T>
}

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.