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 8 of 534
JavaScript Program to Check if a Matrix is Symmetric
A symmetric matrix is a square matrix that equals its transpose, meaning element at position (i, j) equals element at position (j, i). In mathematical terms, A = AT, where A is the matrix and AT is its transpose. In this article, we'll explore JavaScript programs to check if a given matrix is symmetric using different approaches. Original Matrix A 1 ...
Read MoreJavaScript Program to Find Difference Between Sums of Two Diagonals
To find difference between sums of two diagonals, we will be discussing two different approaches. We will calculate the sum of the elements present in the left and right diagonal, then we will subtract both sum values to get the difference. In this article we are having a square matrix, our task is to write a JavaScript program to find difference between sums of two diagonals. ...
Read MoreJavaScript Program to Check horizontal and vertical symmetry in binary matrix
In this article, we will learn to create a program to check both horizontal and vertical symmetry in a binary matrix in JavaScript. A binary matrix is a 2-D array that consists of one and zero only as the elements in each cell. Horizontal symmetry of a binary matrix means if the first row is the same as the last row, the second row is the same as the second last row, and so on. What are Symmetry Matrices? Symmetry in matrices refers to how the values in the matrix mirror themselves along an axis. In the ...
Read MoreJavaScript Program to Cyclically Rotate an Array by One
To cyclically rotate an array by one means shifting the value present at each index to their left or right by one. In this article, we are having an array and our task is to write a JavaScript program to cyclically rotate an array by one. Users must be familiar with JavaScript loops and array operations. Original Array: 1 2 3 ...
Read MoreJavaScript Program for Inserting a Node in a Linked List
A linked list is a linear data structure where elements (nodes) are stored in sequence, with each node containing data and a reference to the next node. Unlike arrays, linked lists allow efficient insertion and deletion at any position without shifting elements. In this article, we'll explore how to insert nodes into a linked list using JavaScript, covering insertion at the beginning, specific positions, and the end of the list. Basic Node Structure First, let's define a simple Node class that represents each element in our linked list: class Node { ...
Read MoreJavaScript Program for Finding Length of a Linked List
To find the length of a linked list in JavaScript, we need to count how many nodes are present. A linked list is made up of nodes, where each node contains data and a reference to the next node. The length is determined by starting at the head and counting each node until the end of the list. If the list is empty, the length should be 0. Our task is to write a JavaScript program that calculates the length of a linked list. In other words, we need to find out how many nodes are in the list. ...
Read MoreC++ program to find the sum of elements between two given indices in array
Finding the sum of elements between two given indices in an array is a common operation in programming. In C++, there are multiple ways to calculate the sum of elements between two given indices in C++. In this article, we are going to discuss various approaches to calculating the sum of elements between two indices in an array using C++. How to Find the Sum of Elements Between Two Indices? In this problem, we are given an array and two indices, L and R, and we have to find the sum of elements from index L and R ...
Read MoreJavaScript Program for Equilibrium Index of an Array
To write a JavaScript program for equilibrium index of an array, we are going to discuss three different approaches with detailed explanation and example codes. The equilibrium index of an array is the position where the sum of the elements to its left and right equals one another. In this article we are having an array of integers, our task is to write a JavaScript program for equilibrium index of an array. Example Input: arr = [-7, 1, 5, 2, -4, 3, 0] Output: Equilibrium index: 3 At index 3, left sum = -7 ...
Read MoreJavaScript Program for Two Pointers Technique
In this article we are given a sorted array, our task is to find if there exists any pair of elements such that their sum is equal to a given number. Users must be familiar with array, loop and nested loops, and if/else statement. Two Pointers Technique Two pointers technique is a commonly used algorithmic approach to solve various problems that require linear time complexity. This technique is used to find a solution for problems that involve searching, sorting, or manipulating arrays, strings, or linked lists. In this article, we are going to solve the pair sum problem using ...
Read MoreJavaScript Program for the Third Largest Element in an Array of Distinct Elements
For the third largest element in an array of distinct elements, we will discuss three different approaches. We will improve efficiency with each approach and discuss their complexities. In this article we are having an array of distinct elements, our task is to find third largest element in an array of distinct elements in Javascript. Users must be familiar with array, loops and conditional statement. Problem Statement Given an array of distinct elements, we need to find the third largest element efficiently. Input: arr = [2, 5, 8, 1, 4, 10, 7] => Highest: 10, ...
Read More