Git Product home page Git Product logo

dsa_ts's Introduction

DSA_TS

Examples of Data structures written in TS format

  • To Compile, run the following command in your command-line in the same directory
tsc --project tsconfig.json

Linked List

  • Time Complexity

  • Use Case: If you do a lot of insertions at the beginning of lists - linked lists are faster than arrays at this (niche)

Stack && Stack-Linked List

Queue && Queue-Linked List

Hash Table

  • Resolving Collisions with "Chaining"
  • Resolving Collisions with "Open Addressing"

Trees

Definition

  • Tree is a unidirectional, non-linear data structure with edges that connect vertices. There is a root node and there are no cycles

Terminology

  • Node / Vertex: A structure that contains a value

  • Edge: A connection between two nodes

  • Root Node: The top-most node in the tree

  • Sub Tree: A nested tree (i.e. sub tree root node is NOT main tree root node)

  • Path: A sequence of nodes and edges that connects

  • Distance: The number of edges between two nodes

  • Parent / Child: Two directly connected nodes, parent node is "above" child node

  • Ancestor / Descendant: Two nodes that are connected by multiple parent-child paths

  • Siblings: Two adjacent nodes with the same parent

  • Degree: The number of a child nodes of a given node

  • Level: The distance between a node and the root node

  • Depth: THe maximum level in a tree

  • Breadth: The number of leaves in a tree

  • Size: The total number of a nodes in a tree

  • Binary-Search-Tree: TWo children at most with values on the left that are less than the root node and values on the right that are greater than the root node

  • Balanced Tree: Sub-tree depth only differs by 1 at most aka AVL Tree.

  • AVL Tree: BST with self-balancing algorithm (named after the its inventor Georgy Adelson-Velsky and Evgenii Landis)

  • Balancing AVL Trees: Left Rotation, Right Rotation, Left-Right Rotation, Right-Left Rotation

  • Balance Factors: Difference between subtree depths (left - right)

  • Trie: Tree structure with nodes each with 26 children representing alphabets

Example

  • File System
    • Depth-First-Search: Dig into the tree first and explore sibling tress step by step
    • Breadth-First-Search: Evaluate all sibling values first before you dig into the tree in depth

Priority Queue

Min-Heap && Max-Heap

  • (Min) Heaps are Trees where the parent node values are smaller or equal than the child node values (for a "max heap", it's the other way around).

Graphs

Definition

  • A tree that breaks all the rules of a tree
  • The concepts of "levels", "nesting", "child / parent" don't exist
  • One node (vertex) may be connected (via Edges) to multiple other nodes
  • Bi-Directional connections are possible, loops are possible

Terminology

  • Directed Graphs: Edges between Nodes are unidirectional
  • Undirected Graphs: Edges between Nodes are bidirectional
  • Adjacency Matrix: Represents the adjacency matrix
  • Adjacency List: Each node contains a list of identifiers for the connected nodes
  • The Matrix and List are to represent the connections between nodes, therefore the nodes themselves can be in a separate list

Examples

  • Social Network: Contacts
  • Dependencies (Software, Citation, etc.)
  • Maps / Directions
  • Knowledge Graph
  • Disease Spread
  • Recommendation Engines

dsa_ts's People

Contributors

heemo521 avatar

Stargazers

 avatar

Watchers

 avatar

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.