Static keyword is used for almost same purpose in both C++ and Java. There are some differences though. This post covers similarities and differences of… Read More

All Easy Articles

In this article, we are going to discuss how Divide and Conquer technique is helpful and how we can solve the problem with the DAC… Read More

A graph is a data structure that consists of the following two components: 1. A finite set of vertices also called as nodes. 2. A… Read More

An array of size n is given. The array contains digits from 0 to 9. Generate the largest number using the digits in the array… Read More

Predict the output of following Java Programs: Question 1 // file name: Main.java class Base { protected void foo() {} } class Derived extends… Read More

The problem is opposite of this post. We are given a Queue data structure that supports standard operations like enqueue() and dequeue(). We need to… Read More

Pascal’s triangle is a triangular array of the binomial coefficients. Write a function that takes an integer value n as input and prints first n… Read More

Predict the output of following Java Programs: Java // filename: Test.java class Test { int x = 10; public static void main(String[] args) { Test… Read More

A disjoint-set data structure is a data structure that keeps track of a set of elements partitioned into a number of disjoint (non-overlapping) subsets. A… Read More

Given a Binary Tree, write an iterative function to print Preorder traversal of the given binary tree.Refer this for recursive preorder traversal of Binary Tree.… Read More

Predict the output of following C++ programs. Question 1 #include <iostream> using namespace std; template <int N> class A { int arr[N]; public: virtual… Read More

Given a binary tree and a key(node) value, find the floor and ceil value for that particular key value. Floor Value Node: Node with greatest… Read More

Write a function that takes two parameters n and k and returns the value of Binomial Coefficient C(n, k). Example: Input: n = 4 and… Read More

Given an array, write a program to generate a random permutation of array elements. This question is also asked as “shuffle a deck of cards”… Read More

The answer is same as Copy Constructor. If a class doesn’t contain pointers, then there is no need to write assignment operator and copy constructor.… Read More

Predict the output of following C++ program. #include<iostream> using namespace std; class Test { protected: int x; public: Test (int i):x(i) { } void… Read More

Given a number, check if it is divisible by 7. You are not allowed to use modulo operator, floating point arithmetic is also not allowed.… Read More

Given a boolean 2D array, where each row is sorted. Find the row with the maximum number of 1s. Example: Input matrix 0 1 1 1… Read More

In C, if a function is called before its declaration, the compiler assumes return type of the function as int.For example, the following program fails… Read More