Algorithms

Find the middle of a given linked list

The Tortoise and Hare Algorithm is a popular algorithm used to find the median of a linked list. It derives its name from the fable of the tortoise and the hare, where the tortoise wins due to its steady pace. This algorithm prov…

Two-Pointer Algorithm in JavaScript

The two-pointer technique is a powerful approach to solving certain problems with optimal time and space complexity. One common application is finding pairs in a sorted array that sum up to a given target. In this example, we’ll…

How to Generate Prime Number Using JavaScript

Prime number is a natural number that has exactly two distinct natural number divisors: 1 and itself. The first 30 prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47 and 53. Prime numbers are very importa…

How To Implement LRU Cache In JavaScript In 28 Lines Or Less

LRU stands for Least Recently Used. It is a cache algorithm that is used to determine which elements should be discarded from memory when the cache is full. The most basic LRU algorithm would simply check the last time a given…

How to implement PhoneBook using tries data structure in typescript

Trie is a node-based data structure. It is used to implement word lookups. It is better than the use of HashTable because it can store efficiently sorted data and don’t have to use a sorting algorithm while retrieving data. We’…

Write a function to delete a Linked List in C#

In computer science, a linked list is a linear collection of data elements whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collecti…

Design a stack that supports getMin() in O(1) time

In this blog post, we’ll explore the MinStack data structure in JavaScript, covering its design, implementation, and how it works under the hood. We’ll also include visualizations to help you better understand how this data str…

QuickSort implementation in TypeScript using recursion

This post will discuss how to implement the QuickSort algorithm in typescript/javascript. Quicksort is the fastest algorithm. Quicksort works on the divide and conquer strategy. All languages in the world provide sorting func…

Load More
That is All