The idea is to traverse both trees and compare values at their root node. If the value matches, recursively check if the first tree’s left subtree is identical to the left subtree of the second tree and the right subtree of the first tree is identical to the right subtree of the second tree. If the value at their root node differs, the trees violate data property. If at any point in the recursion, the first tree is empty and the second tree is non-empty, or the second tree is empty and the first tree is non-empty, the trees violate structural property, and they cannot be identical.
#Data_structure
#Source_code
#Data_structure
#Source_code
code.png
511.2 KB
ATM program Java
In Java, we can create an ATM program for representing ATM transection. In the ATM program, the user has to select an option from the options displayed on the screen. The options are related to withdraw the money, deposit the money, check the balance, and exit.
#Source_code
#79
In Java, we can create an ATM program for representing ATM transection. In the ATM program, the user has to select an option from the options displayed on the screen. The options are related to withdraw the money, deposit the money, check the balance, and exit.
#Source_code
#79
Sunny Number
A number is called a sunny number if the number next to the given number is a perfect square. In other words, a number N will be a sunny number if N+1 is a perfect square.
Let's understand it through an example.
#Source_code
#72
A number is called a sunny number if the number next to the given number is a perfect square. In other words, a number N will be a sunny number if N+1 is a perfect square.
Let's understand it through an example.
#Source_code
#72
Java
Sunny Number A number is called a sunny number if the number next to the given number is a perfect square. In other words, a number N will be a sunny number if N+1 is a perfect square. Let's understand it through an example. #Source_code #72
Steps to Find Sunny Number
The logic is very simple. To find the sunny number, we need only to check whether N+1 is the perfect square or not.
Read or initialize a number (num).
Add 1 to the given number i.e. num+1.
Find the square root of num+1.
If the square root is an integer, the given number is sunny, else not a sunny number.
Let's implement the above steps in a Java program.
#Output
#72
The logic is very simple. To find the sunny number, we need only to check whether N+1 is the perfect square or not.
Read or initialize a number (num).
Add 1 to the given number i.e. num+1.
Find the square root of num+1.
If the square root is an integer, the given number is sunny, else not a sunny number.
Let's implement the above steps in a Java program.
#Output
#72
Forwarded from Java
Find prime numbers between two numbers
You can also find prime numbers between two specified numbers.
#Source_code
#11
You can also find prime numbers between two specified numbers.
#Source_code
#11
We can add two matrices in java using binary + operator. A matrix is also known as array of arrays. We can add, subtract and multiply matrices.
#Source_code
#74
#Source_code
#74
Fascinating Number Java Program
The base condition to check whether a number is fascinating or not is that the number must have at least 3 or more than three digits.
#Source_code
#75
The base condition to check whether a number is fascinating or not is that the number must have at least 3 or more than three digits.
#Source_code
#75
Check if a string is a rotated palindrome or not
A naive solution is to consider all rotations of the given string and check if any rotation is a palindrome or not. If we have found a rotation that is a palindrome, return true; otherwise, return false.
#Source_code
#Data_structure
A naive solution is to consider all rotations of the given string and check if any rotation is a palindrome or not. If we have found a rotation that is a palindrome, return true; otherwise, return false.
#Source_code
#Data_structure
Media is too big
VIEW IN TELEGRAM
JVM Language Summit 2023 Keynote
Presented by Georges Saab - Senior Vice President (Java Platform Group - Oracle), Chair (OpenJDK Governing Board) and Mark Reinhold - Chief Architect (Java Platform Group - Oracle) during the JVM Language Summit 2023 (Santa Clara CA).
Presented by Georges Saab - Senior Vice President (Java Platform Group - Oracle), Chair (OpenJDK Governing Board) and Mark Reinhold - Chief Architect (Java Platform Group - Oracle) during the JVM Language Summit 2023 (Santa Clara CA).
DiffOddEven.png
759.6 KB
In this program, we need to calculate the difference between the sum of nodes present at odd levels and sum of nodes present at even levels. Suppose, if a tree contains 5 levels, then
Difference = (L1 + L 3 + L5) - (L2 + L4)
#Source_code
#77
Difference = (L1 + L 3 + L5) - (L2 + L4)
#Source_code
#77