Skip to content

jagadeeshshetty/javascript

Repository files navigation

Javascript Datatstructures and Algorithms

Author: @Jagadeesh C


All about Javascript datastructures.

Setup

npm install --save-dev mocha chai nyc

  1. Arrarys
  2. Tbd
  3. Tbd

Run

All with Code coverage report npm run test:coverage:report

Single Test macOS: ./node_modules/.bin/_mocha test/algorithms/sorting/ Windows: npm run test:single .\test\algorithms\sorting\bubble_sort.test.js


T O D O S

Arrays

  • Count odd and even elements
  • Sum of the elements in the array
  • Largest element in the array
  • Largest and smallest element in the array
  • Reverse the array
  • Search an element in the array
  • Sum of 2d array

Linked Lists

  • Print the Linked List in Reverse Order
  • Get Nth node from the last
  • Detect the loop in the linked list
  • Reverse the linked list
  • Get Nth Node of the Linked List
  • Find the Middle Node of the Linked List [Using Loop]
  • Find the Middle Node of the Linked List [Using Slow & Fast Pointers]

Stacks

  • Implement two stacks in an array[Method 1]
  • Implement two stacks in an array[Method 2]
  • Reverse a string using Stack
  • Check if the given expression is balanced or not
  • Introduction to Infix Prefix Postfix expressions
  • Evaluate the postfix expression using Stack

Binary Search Trees

  • Find Minimum Value in BST
  • Find Sizeof() BST
  • Find Maximum Depth or Height of BST
  • Mirror of the Tree
  • Same Tree
  • Double Tree
  • Check if a binary tree is BST or not

Hashing

  • Check if an array is a subset of another array

check-for-disjoint-arrays

check-for-subarray-with-sum-zero

Strings

String length

Count vowels in a string

Compare two strings problem

String copy

Concatenate two strings

Lower and upper problem

Reverse the string - Method 1

Reverse the string - Method 2

Palindrome of the string

Bitwise

Find equal or not using bitwise

Find odd or even using bitwise

Swap two numbers using bitwise

Count set bits in an integer

Clear the rightmost set bit of a number

Brian Kernighan’s Algorithm (Count set bits)

Enable nth bit of a number

Check nth bit is set or unset

Disable nth bit of a number

Toggle nth bit of a number

Check if a number is a power of 2

Check if the number has alternate bit pattern

Find the odd occuring numbers using bitwise

Two Single Numbers

Find the Missing Number

Recursion

Introduction recursion & basic rules

How recursion works [Factorial of a Number]

Stack overflow in recursion

Changing iterative function to recursive function

Recursion vs Iteration

Types of recursion

Tail recursion

Head recursion

Nested recursion

Binary or Tree recursion

Indirect recursion

Why Tail Recursion is Efficient? - Part1

Why Tail Recursion is Efficient? - Part2

Sum of natural numbers

Decimal to binary conversion

Modulo operation

Find string length

Reverse a string

Check if a string is a Palindrome

Count vowels in a string

Sum of numbers in a singly linked list

Sliding Windows

Introduction

Maximum Sum Subarray of Size K

Smallest Subarray with a given sum

Two Pointers

Introduction

Pair with Target Sum

Remove all occurrences of an element from Array

Move all zeros to the end

Remove duplicates from sorted array

Remove duplicates(at most twice) from sorted array

Fast & Slow Pointers

Introduction

Middle of the Linked List

Linked List Loop

Length of Linked List Loop

Start of Linked List Loop

Happy Number

Cyclic Sorts

Introduction

Cyclic Sort

Find the Duplicate Number

Find the Missing Number

BFS

Introduction

Binary Tree Level Order Traversal

Level Order Successor

Minimum Depth of a Binary Tree

DFS

Introduction

Binary Tree Path Sum

Print Paths in a Tree

All Paths for a Sum

Bitwise XOR

Introduction

Single Number

Two Single Numbers

Linked List Reversal

Introduction

Reverse the Linked List

Reverse the Sublist

Reverse Every K Nodes of a Linked List

Top K Elements

Introduction

Top K Numbers using Max Heap

Top K Numbers using Min Heap

Kth Smallest Number

K Closest Points to the Origin

Connect N Ropes with Minimum Cost

Dynamic Programming

Introduction to Dynamic Programming

Implementation of Nth Fibonacci: Bottom-Up approach

Implementation of Nth Fibonacci: To-Down Approach with Memoization

Memoization: Avoid Recomputation Issue in Top-Down Approach

Characteristics of Dynamic Programming

Knapsack Problem Introduction

0-1 Knapsack

Longest Common Subsequence

Longest Common Substring

Minimum number of jumps to reach end

Convert one string to another using minimum number of operations

Count number of ways to reach n'th stair

Cutting a rod to maximise profit

Binary Search

  • What is Binary Search?
  • Implementation of Binary Search
  • Time and Space Complexity Analysis
  • Find in Mountain Array
  • Search in Rotated Sorted Array
  • Sqrt(x) using Binary Search
  • Peak Index in a Mountain Array
  • Binary Search using Divide and Conquer Strategy
  • Search Insert Position of K in a Sorted Array
  • Find First and Last Position of Element in Sorted Array
  • Find the Number of Occurrences of an Element in a Sorted Array
  • Find Minimum in Rotated Sorted Array
  • Search in Row Wise Column Wise Sorted Matrix

Numbers

Find positive or negative number

Absolute value of a number

Odd or Even Problem

Swap two numbers

Sum of Natural Numbers

Sum of Natural Numbers Method 2

Factor of a Number

Split numbers into digits

Sum of digits

Reverse a number

Palindrome number

Armstrong number

Fibonacci series

Prime number

Perfect number

References

About

Covers DS and Algorithms in Javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published