Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Javascript Articles
Page 268 of 534
Doubly linked lists in Javascript
In this article, we are going to discuss a Doubly Linked List Class data structure in JavaScript. This is a linear data structure. Doubly linked lists are almost the same as a singly linked list in all operations, we just need to keep track of one extra link per node. In singly linked lists, we just had next links, in doubly linked lists, we have 2 links, next and prev. Structure of Doubly Linked List Doubly linked lists are represented as: ...
Read MoreHash Table Data Structure in Javascript
Hash Table is a data structure which stores data in an associative manner. In a hash table, data is stored in an array format, where each data value has its own unique index value. Access to data becomes very fast if we know the index of the desired data. Thus, it becomes a data structure in which insertion and search operations are very fast irrespective of the size of the data. Hash Table uses an array as a storage medium and uses the hash technique to generate an index where an element is to be inserted or is to ...
Read MoreBinary Tree in Javascript
Binary Tree is a special data structure used for data storage purposes. A binary tree has a special condition that each node can have a maximum of two children. A binary tree has the benefits of both an ordered array and a linked list as search is as quick as in a sorted array and insertion or deletion operation are as fast as in the linked list. Here is an illustration of a binary tree with some terms that we've discussed below: A Root ...
Read MoreBinary Search Tree in Javascript
A Binary Search Tree (BST) is a specialized data structure where each node follows a specific ordering rule. A node's left child must have a value less than its parent's value, and the node's right child must have a value greater than its parent's value. 8 3 10 1 6 14 ...
Read MoreRemoving a node in a Javascript Tree
In JavaScript, removing a node from a tree is a fundamental operation that requires handling different scenarios based on the node's structure. This article covers the three main cases for node deletion in Binary Search Trees (BST). Tree Structure and Traversal Overview A tree is a nonlinear data structure consisting of nodes connected by edges. Tree traversal retrieves and processes data from each node in a specific order: In-order traversal − Follows the path (Left → Root → Right) Pre-order traversal − Follows the path (Root → Left → Right) Post-order traversal − Follows the path ...
Read MoreAVL Rotations in Javascript
To balance itself, an AVL tree may perform the following four kinds of rotations: Left rotation Right rotation Left-Right rotation Right-Left rotation The first two rotations are single rotations and the next two rotations are double rotations. To have an unbalanced tree, we at least need a tree of height 2. With this simple tree, let's understand them one by one. Left Rotation If a tree becomes unbalanced when a node is inserted into the right subtree of ...
Read MoreDepth-first search traversal in Javascript
DFS visits the child vertices before visiting the sibling vertices; that is, it traverses the depth of any particular path before exploring its breadth. A stack (often the program's call stack via recursion) is generally used when implementing the algorithm. Following is how a DFS works − Visit the adjacent unvisited vertex. Mark it as visited. Display it. Push it in a stack. If no adjacent vertex is found, pop up a vertex from the stack. (It will pop up all the vertices from the stack, which do not ...
Read MoreTopological sorting using Javascript DFS
A topological sort or topological ordering of a directed graph is a linear ordering of its vertices such that for every directed edge UV from vertex u to vertex v, u comes before v in the ordering. This only makes sense in directed acyclic graphs (DAGs). There are many places where topological sort makes a lot of sense. For example, let's say you're following a recipe, in this, there are some steps that are prerequisites for going to the next steps. Similarly, during college when selecting courses, there are prerequisites for more advanced courses which themselves may be prerequisites ...
Read MoreHow to clone an object in JavaScript?
An object is said to be an entity which has properties and types in it. Example, consider a Person as an object and it has properties like height, weight, age and salary. In the similar way JavaScript also have objects and their defined properties. An object in JavaScript is a complicated data type where it can store various data types in it. Let's consider this example below: const employee = { ...
Read MoreGarbage collection(GC) in JavaScript?
Memory management in JavaScript is much easier than in low-level languages like C or C++. Unlike low-level languages, JavaScript automatically detects which objects will be needed in later cases and which will be garbage that is occupying memory without any reason. In this article, we shall discuss how garbage collection (GC) works in JavaScript. There are a few important parts that we are going to discuss in detail: Reachability from root Interlinked Objects (interconnections between different objects) Unreachable Collections (Broken link) Reachability The first concept of ...
Read More