Articles on Trending Technologies

Technical articles with clear explanations and examples

Sum of squares of Fibonacci numbers in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 354 Views

Fibonacci series is a mathematical sequence of number which starts from 0 and the sum of two numbers is equal to the next upcoming number, for example, the first number is 0 and the second number is 1 sum of 0 and 1 will be 1F0=0, F1=1AndFn=Fn-1+Fn-2, F2=F0+F1 F2=0+1 F2=1then when we add number 1 and 1 then the next number will be 2F1=1, F2=1AndFn=Fn-1+Fn-2, F3=F1+F2 F3=1+1 F3=2Fibonacci sequence is 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …We have to find the square of the fuel energy series and then we have to sum it and find ...

Read More

How to check if a file is readable, writable, or, executable in Java?

Maruthi Krishna
Maruthi Krishna
Updated on 11-Mar-2026 4K+ Views

In general, whenever you create a file you can restrict/permit certain users from reading/writing/executing a file.In Java files (their abstract paths) are represented by the File class of the java.io package. This class provides various methods to perform various operations on files such as read, write, delete, rename, etc.In addition, this class also provides the following methods −setExecutble() − This method issued to set the execute permissions to the file represented by the current (File) object.setWritable() − This method is used to set the write permissions to the file represented by the current (File) object.setReadable() − This method is used ...

Read More

Check if a large number is divisible by 5 or not in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 755 Views

Here we will see how to check a number is divisible by 5 or not. In this case the number is very large number. So we put the number as string.To check whether a number is divisible by 5, So to check divisibility by 5, we have to see the last number is 0 or 5.Example#include using namespace std; bool isDiv5(string num){    int n = num.length();    if(num[n - 1] != '5' && num[n - 1] != '0')    return false;    return true; } int main() {    string num = "154484585745184258458158245285265";    if(isDiv5(num)){       cout

Read More

Check if a Binary Tree (not BST) has duplicate value in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 451 Views

Consider we have a binary tree, this binary tree is not a BST. We have to check whether the binary tree contains same element more than one time or not. To solve this, we will use hashing. We will traverse the given tree, for each node, we will check whether the node is present in the table or not, if that is already present, then return false, otherwise true.Example#include #include using namespace std; class Node {    public:    int data;    Node *left;    Node *right; }; Node* getNode(int data){    Node *newNode = new Node;   ...

Read More

Out of memory exception in Java:

Maruthi Krishna
Maruthi Krishna
Updated on 11-Mar-2026 1K+ Views

Whenever you create an object in Java it is stored in the heap area of the JVM. If the JVM is not able to allocate memory for the newly created objects an exception named OutOfMemoryError is thrown.This usually occurs when we are not closing objects for long time or, trying to act huge amount of data at once.There are 3 types of errors in OutOfMemoryError −Java heap space.GC Overhead limit exceeded.Permgen space.Example 1public class SpaceErrorExample {    public static void main(String args[]) throws Exception {       Float[] array = new Float[10000 * 100000];    } }OutputRuntime exceptionException in ...

Read More

Check if a Binary Tree contains duplicate subtrees of size 2 or more in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 340 Views

Consider we have a binary tree. We have to find if there are some duplicate subtrees of size 2 or more in the tree or not. Suppose we have a binary tree like below −There are two identical subtrees of size 2. We can solve this problem by using tree serialization and hashing process. The idea is serializing the subtrees as string, and store them in hash table. Once we find a serialized tree which is not leaf, already exists in hash table, then return true.Example#include #include using namespace std; const char MARKER = '$'; struct Node { ...

Read More

Check if a large number is divisible by 75 or not in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 325 Views

Here we will see how to check a number is divisible by 75 or not. In this case the number is very large number. So we put the number as string.A number will be divisible by 75, when the number is divisible by 3 and also divisible by 25. if the sum of digits is divisible by 3, then the number is divisible by 3, and if last two digits are divisible by 25, then the number is divisible by 25.Example#include using namespace std; bool isDiv75(string num){    int n = num.length();    long sum = accumulate(begin(num), end(num), 0) ...

Read More

Angular Sweep Algorithm in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 794 Views

The algorithm to find the maximum number of points that can be enclosed in a circle of a given radius. This means that for a circle of radius r and a given set of 2-D points, we need to find the maximum number of points that are enclosed (lying inside the circle not on its edges) by the circle.For, this is the most effective method is the angular sweep algorithm.AlgorithmThere are nC2 points given in the problem, we need to find the distance between each of these points.Take an arbitrary point and get the maximum number of points lying in ...

Read More

Check if a large number is divisible by 8 or not in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 574 Views

Here we will see how to check a number is divisible by 8 or not. In this case the number is very large number. So we put the number as string.A number will be divisible by 8, if the number formed by last three digits are divisible by 8.Example#include using namespace std; bool isDiv8(string num){    int n = num.length();    int last_three_digit_val = (num[n-3] - '0') * 100 + (num[n-2] - '0') * 10 + ((num[n-1] - '0'));    if(last_three_digit_val % 8 == 0)       return true;       return false; } int main() {    string num = "1754586672360";    if(isDiv8(num)){       cout

Read More

Check if a large number is divisible by 9 or not in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 434 Views

Here we will see how to check a number is divisible by 9 or not. In this case the number is very large number. So we put the number as string.A number will be divisible by 9, if the sum of digits is divisible by 9.Example#include using namespace std; bool isDiv3(string num){    int n = num.length();    long sum = accumulate(begin(num), end(num), 0) - '0' * n;    if(sum % 9 == 0)       return true;       return false; } int main() {    string num = "630720";    if(isDiv3(num)){       cout

Read More
Showing 28921–28930 of 61,299 articles
Advertisements