Skip to content

dip4k/DS-and-Algorithm-prep-in-TS

Repository files navigation

Data Structures & Algorithms practice in TypeScript

Introduction

This is practice repo for Udemy course Master the Coding Interview: Data Structures + Algorithms purely written in Typescript.

Dev Setup


pre-requisite : node/deno installed

  • using vs code (with prettier, eslint and typescript support installed)
  • using eslint for code standard and prettier for formatting
  • using (node + ts-node) or deno to run program files

how to run


  • clone this repo
  • install npm packages by running --> npm install
  • when using deno, execute program file by running --> deno run fileLocation/filename.ts
  • when using node+ts-node --> ts-node fileLocation/filename.ts

Will add test cases for testing program files

Main Topics


How to measure code/program quality?

Time complexity

  • how much time needed to execute program as we increase input (input can be anything, and our code will perform operations on input)
  • We express time complexity of code in terms of Big-O notation.
  • O(1) - Big-O of one : constant time --> will take same time to execute irespective of input
  • O(n) - Big-O of N : Linear time --> execution time will increase linearly as we increase input
  • O(n^2)- Big-O of N-square : Quadratic time --> execution time will increase quadratically(to the square of input) as we increase input

space complexity

  • how much memory need for executing the program

Data structures


Array


programs

  • intro to array
  • own custom array
  • reverse given string
  • merge two sorted array into one (bonus : merge unsorted array in ascending or descending order)

Array operations and their time complexity

  • insertion --> O(n)
  • deletion --> O(n)
  • search --> O(1)
  • traversal --> o(1)

Hash Table


programs

  • custom hash table
  • first recurring character
  • custom generic hash table

Time complexity

  • search --> avg : O(1), worst : O(n)
  • insertion --> avg : O(1), worst : O(n)
  • deletion --> avg : O(1), worst : O(n)

Space complexity

  • O(n)

Linked-List


Programs

  • singly-linked-list implementation in typescript
  • doubly-linked-list implementation in typescript

Opeartions

  • prepend --> O(1)
  • append ---> O(1)
  • lookup --> O(n)
  • insert --> O(n)
  • delete --> O(n)

Interview Questions


Array/string additional questions

Resources

About

DS and Algorithm preparation using Typescript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors