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
Web Development Articles
Page 327 of 801
Removing 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 create tabs with CSS and JavaScript?
In this article, we are going to discuss how to create tabs with CSS and JavaScript. Tabs are containers whose main purpose is to show and navigate through the diverse content of the website. Tabs are commonly used to manage the space and make the website more user-friendly without reloading too many times. The content in these tabs are usually closely related but mutually exclusive. There are several types of tabs which can be created and used in various cases: Horizontal tabs Horizontal with Secondary Tabs Frameless ...
Read MoreHow to create a responsive slideshow with CSS and JavaScript?
In this article, we will create a responsive slideshow using JavaScript and CSS. A responsive slideshow is an interactive design element that displays a series of images with navigation controls, adapting to different screen sizes. A responsive slideshow allows users to browse through multiple images using arrow buttons or dot indicators. It's commonly used to showcase content while conserving space on web pages. HTML Structure First, create the HTML structure with a container for slides, navigation arrows, and dot indicators: 1 / 3 ...
Read MoreHow to create a form with multiple steps in JavaScript?
Creating multi-step forms improves user experience by breaking complex forms into manageable sections. This approach reduces form abandonment and makes data collection more organized. Complete Multi-Step Form Example Here's a complete implementation of a multi-step registration form with validation and progress indicators: * { box-sizing: border-box; } body { background-color: #f1f1f1; } #regForm { margin: 100px auto; ...
Read MoreImplementing Linear Search in JavaScript
Linear search is a simple algorithm that sequentially checks each element in an array until the target element is found or the end of the array is reached. It has a time complexity of O(n) in the worst case. How Linear Search Works Linear Search Process Array: [1, 19, 5, 11, 22, 55] Target: 22 1 i=0 19 i=1 ...
Read MoreHow to add and remove names on button click with JavaScript?
JavaScript allows you to dynamically add and remove names from a list using DOM manipulation methods. This functionality is commonly used in todo lists, user management interfaces, and interactive forms. HTML Structure First, we need a basic HTML structure with an input field, buttons, and a container for the names list: Add and Remove Names body { ...
Read MoreCreate increment decrement plus minus buttons programmatically for HTML input type number in JavaScript
In JavaScript, you can create increment and decrement buttons for HTML input type number using the stepUp() and stepDown() methods. This approach provides better user experience by allowing precise control over numeric inputs. On clicking Increment (+), the number in the input field increases by the step value On clicking Decrement (-), the number in the input field decreases by the step value The buttons respect the min/max constraints of the input field Basic Implementation Here's how to create increment/decrement buttons programmatically: ...
Read More