Articles on Trending Technologies

Technical articles with clear explanations and examples

Find a pair from the given array with maximum nCr value in C++

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

ConceptWith respect of given an array arr[] of n positive integers, the task is to determineelements arr[i] and arr[j] from the array such that arr[i]Carr[j] is at most possible. With respect of more than 1 valid pairs, print any one of them.Input arr[] = {4, 1, 2}Output 4 2 4C1 = 4 4C2 = 4 2C1 = 4 (4, 2) is the only pairs with maximum nCr.MethodnCr is treated as a monotonic increasing function, that is n+1Cr > nCr. We can apply this fact to get close to our answer; we will select the max n among all the given integers. In ...

Read More

Find the largest Complete Subtree in a given Binary Tree in C++

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

ConceptWith respect of a given Binary Tree, the task is to determine the size of maximum complete sub-tree in the given Binary Tree.Complete Binary Tree – A Binary tree is treated as Complete Binary Tree if all levels are completely filled without possibly the last level and the last level has all keys as left as possible.It has been noted that all Perfect Binary Trees are Complete Binary tree but reverse in NOT true. It has been seen that if a tree is not complete then it is also not Perfect Binary Tree.Input       2      / \ ...

Read More

C program to print employee details using Structure

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 2K+ Views

Here, we are given a structure containing details of employees. Our task is to create a C program to program to print employee details using structure.The details of the employee that are in the structure are name, age, phone number, salary, and our program will print these details.The details of the employees are pre-declared in the program and we will one by one print all the values. For this, we will create a function that will access the object of the structure and then print all the members of the structure using this object.C Program to print employee details using ...

Read More

Find the Largest Cube formed by Deleting minimum Digits from a number in C++

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

ConceptWith respect of given number N, our task is to determine the largest perfect cube that can be formed by deleting minimum digits (possibly 0) from the number. So any digit can be deleted from the given number to reach the target.A is called a perfect cube if A = B^3 for some integer B.It has been seen that If the number cannot be perfect cube print -1.ExampleLet N = 1025. It has been seen that if we delete 0 from the above number we will get 125 as remaining number, which is cube root of 5(5 * 5 * ...

Read More

Java Program for Standard Normal Distribution (SND)

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 437 Views

Following is the Java program for Standard Normal Distribution −Exampleimport java.io.*; import java.util.*; public class Demo{    public static void main(String[] args){       double std_dev, val_1, val_3, val_2;       val_1 = 68;       val_2 = 102;       val_3 = 26;       std_dev = (val_1 - val_2) / val_3;       System.out.println("The standard normal deviation is: " + std_dev);    } }OutputThe standard normal deviation is: -1.3076923076923077A class named Demo contains the main function, where certain double values are defined, and the formula for standard deviation is applied ((val_1 - val_2) / val_3) on these values and the resultant output is displayed on the console.

Read More

Java Program for Reversal algorithm for array rotation

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 409 Views

Following is the Java program to implement Reversal algorithm for array rotation −Exampleimport java.io.*; public class Demo{    static void rotate_left(int my_arr[], int no_of_rotation){       int n = my_arr.length;       array_reversal(my_arr, 0, no_of_rotation - 1);       array_reversal(my_arr, no_of_rotation, n - 1);       array_reversal(my_arr, 0, n - 1);    }    static void array_reversal(int my_arr[], int start, int end){       int temp;       while (start < end) {          temp = my_arr[start];          my_arr[start] = my_arr[end];          my_arr[end] = temp; ...

Read More

Check for balanced parentheses in an expression - O(1) space - O(N^2) time complexity in C++

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

ConceptWith respect of given a string str containing characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, the task is to find if brackets are balanced or not.Brackets are denoted as balanced if −We close open brackets must be closed by the same type of brackets.Again we close open brackets according to the correct order.Input − str = “(()){}”Output − YesInput − str = “))(([][”Output − NoMethodAssign two variables a and b to keep track of two brackets to be compared.A count should be maintained whose value increments on encountering opening bracket and decrements on encountering a closing bracket.Assign b = ...

Read More

Static Control Flow in Java

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 1K+ Views

The Static Control Flow identify static members, executes static blocks, and then executes the static main method. Let us see an example −Examplepublic class Demo{    static int a = 97;    public static void main(String[] args){       print();       System.out.println("The main method has completed executing");    }    static{       System.out.println(a);       print();       System.out.println("We are inside the first static block");    }    public static void print(){       System.out.println(b);    }    static{       System.out.println("We are inside the second static block");    }   ...

Read More

Check if a given Binary Tree is height balanced like a Red-Black Tree in C++

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

ConceptWith respect of a Red-Black Tree, the largest height of a node is at most double the minimum height.For a given Binary Search Tree, we need to verify for following property.With respect of every node, length of the longest leaf to node path has not more than double the nodes on shortest path from node to leaf.Examples13    41 \    / \ 15  11 101 \   /    \ 17 61 151Above tree cannot be a Red-Black Tree Above tree can be Red-Black Tree with any color assignmentMax height of 13 is 1Min height of 13 is 3  ...

Read More

Static method in Interface in Java

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 1K+ Views

To implement static method in Interface, the Java code is as follows −Exampleinterface my_interface{    static void static_fun(){       System.out.println("In the newly created static method");    }    void method_override(String str); } public class Demo_interface implements my_interface{    public static void main(String[] args){       Demo_interface demo_inter = new Demo_interface();       my_interface.static_fun();       demo_inter.method_override("In the override method");    }    @Override    public void method_override(String str){       System.out.println(str);    } }OutputIn the newly created static method In the override methodAn interface is defined, inside which a static function is defined. Another ...

Read More
Showing 26901–26910 of 61,297 articles
Advertisements