All Easy Articles

## Implement Stack using Queues 2.5

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 »

## Operating Systems | Set 17 2

Following question has been asked in GATE 2012 CS exam. Fetch_And_Add(X,i) is an atomic Read-Modify-Write instruction that reads the value of memory location X, increments… Read More »

## Pascal’s Triangle 2.9

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 »

## Output of Java Program | Set 3 2.8

Predict the output of following Java Programs: filter_none edit close play_arrow link brightness_4 code // filename: Test.java class Test {     int x  = 10;       public… Read More »

## Disjoint Set (Or Union-Find) | Set 1 (Detect Cycle in an Undirected Graph) 2.8

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 »

## Iterative Preorder Traversal 2.1

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… Read More »

## Output of C++ Program | Set 18 2.5

Predict the output of following C++ programs. Question 1 filter_none edit close play_arrow link brightness_4 code #include <iostream> using namespace std;    template <int N>… Read More »

## Floor and Ceil from a BST 2.5

There are numerous applications we need to find floor (ceil) value of a key in a binary search tree or sorted array. For example, consider… Read More »

## Space and time efficient Binomial Coefficient 2.5

Write a function that takes two parameters n and k and returns the value of Binomial Coefficient C(n, k). For example, your function should return… Read More »

## Shuffle a given array using Fisher–Yates shuffle Algorithm 2.9

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 »

## When should we write our own assignment operator in C++? 2.6

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 »

## Function overloading and const keyword 2.6

Predict the output of following C++ program. filter_none edit close play_arrow link brightness_4 code #include<iostream> using namespace std;    class Test { protected:     int x;… Read More »

## Check divisibility by 7 2.3

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 »

## Find the row with maximum number of 1s 2.7

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… Read More »

## What happens when a function is called before its declaration in C? 2.1

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… Read More »

## Output of C++ Program | Set 15 2.5

Predict the output of following C++ programs. Question 1 filter_none edit close play_arrow link brightness_4 code #include <iostream> using namespace std;    class A {… Read More »

## Output of C++ Program | Set 14 2.6

Predict the output of following C++ program. Difficulty Level: Rookie Question 1 filter_none edit close play_arrow link brightness_4 code #include <iostream> using namespace std;   … Read More »

## Find four elements that sum to a given value | Set 1 (n^3 solution) 2.6

Given an array of integers, find all combination of four elements in the array whose sum is equal to a given value X. For example,… Read More »

## Microsoft Interview | Set 2 2

Please find the details of my Microsoft Interview below. Date Of Interview: 3rd August,2012 No. of Rounds: 2 online exams + 4 rounds of PI… Read More »

## Maximum Length Chain of Pairs | DP-20 2.6

You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. A pair (c, d) can… Read More »