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
Articles by AYUSH MISHRA
112 articles
Count the number of nodes in a complete Binary tree using JavaScript
A binary tree is a non-linear data structure where each node can have at most two children i.e. left children and right children. In this article, we are going to discuss how to count nodes in a complete binary tree using JavaScript. What is a Complete Binary Tree? A complete binary tree is a binary tree in which all the nodes are completely filled except possibly the last level of the tree, and the last node has all its nodes on the left side as possible. Below are examples to demonstrate the above problem, clearly: Example 1 Input: ...
Read MorePython Program to Print Hollow Rectangle pattern
When we start programming then printing different star patterns helps us build our logic and problem-solving skills. One of the easiest and beginner patterns is the hollow rectangle pattern. In this article, we are going to learn how we can print the hollow rectangle pattern using different approaches in Python. Hollow Rectangle Pattern A Hollow rectangle pattern is a rectangle-shaped pattern printing of stars where the stars are present only on the boundaries of the rectangle. The rectangle is hollow, i.e., the stars are printed only on the boundaries of the rectangle, while the inner area remains empty. ***** ...
Read MorePython Program to count nodes in a binary tree
In this article, we are going to learn how we can count the total number of nodes in a binary tree in Python, using different approaches. A binary tree is a data structure in which each node can have at most two children. The two children node of a binary tree are called the left child and the right child. We have to calculate the total number of nodes present in the binary tree. Scenario 1 Input: Binary Tree = 1 2 3 4 5 Output: Total number of nodes: 5 Above-given binary tree has five nodes: 1, 2, ...
Read MoreFind the number that appears once, and the other numbers twice in Java
In this problem, we are given an array of integers. In the given array, each element occurs two times except one element, which occurs only once. We have to find the number that appears only once. In this article, we are going to learn how we can find the number that appears once, and all other numbers appear twice in Java. Scenario 1 All other numbers except 4 occur twice, so 4 is the only number that appears only once. Input: [ 1, 2, 3, 3, 2, 4, 1, 5, 5] Output: 4 Scenario 2 All other numbers except ...
Read MoreC++ Program to Rotate Array Left by One Position
Rotating an array means shifting the elements of an array in a specific direction while maintaining their relative order. For example, if the array {6, 12, 18, 24, 30} is rotating it left once will result in {12, 18, 24, 30, 6}. In this article, we are given an array and need to shift all elements one step to the left, with the first element moving to the last position. Example Here is an example of left rotation of elements in array by one place. Input: array = {5, 10, 15, 20, 25} Output: array = {10, 15, ...
Read MoreC++ Program to Find Sum of Leaf Node in Binary Tree
We can find the sum of leaf nodes in a binary tree using an iterative and a recursive approach. This problem has many real-life applications, such as analyzing hierarchies, calculating final results in decision trees, or summing final nodes in various kinds of trees used in computer algorithms. In this article, we are going to learn how can find the sum of all leaf nodes in a binary tree in the C++ language. What are Leaf Nodes in a Binary Tree? The leaf nodes of a binary tree are the nodes that do not have any children. Both the ...
Read MoreFind the Angle Between Hour and Minute Hands of a Clock in C#
The calculation of the angle between the hour and minute hands of a clock is a common problem in Logical Reasoning and programming. This calculation is used in various applications, such as analog clock simulations, scheduling software, and time-based animations In this article, we are going to discuss how we can calculate the angle between the hour and minute hands of a clock in C# using different approaches: What is the Angle Between the Hour and Minute Hands? The angle between the hour and minute hands is determined based on the positions of both hands on the clock ...
Read MoreReplace elements by its rank in the array in JavaScript
In this problem, we are given an array, and we have to replace each element with its rank. The rank of an element is the position of the element when element of the array is arranged in sorted order. In this article, we are going to learn about various approaches to replacing elements with their rank in an array using JavaScript. Below are the examples to understand the problem clearly - Example 1: Input: arr = [40, 10, 20, 30] Output: [4, 1, 2, 3] Explanation: The sorted, unique array is: [10, 20, ...
Read MoreKth largest Element in a 2D matrix where each row and column is sorted in C++
Finding the Kth largest element in a 2D matrix where each row and column is sorted is a common problem in computer science. This problem has many real-life applications, such as a ranking system, where we need to find the Kth highest score in a sorted dataset. In this article, we are going to discuss how we can find the Kth largest element in a 2D matrix e where each row and column is in sorted order in the C++ language. What is the Kth Largest Element? The Kth largest element refers to an element that is placed at ...
Read MoreSwap all odd and even bits using C++
We can swap all odd and even bits in a given integer. Swapping of odd and even bits means changing the bits present at odd positions with the bits at even positions in a binary representation of a number. One real-life application is optimizing data storage or modifying data patterns in memory. In this article, we are going to learn how we can swap all odd and even bits of a number in C++ using different approaches. Formula for Swapping Odd and Even Bits Extract all even-positioned bits using a bit mask and shift ...
Read More