All Easy Articles

## Data type of character constants in C and C++ 2

In C, data type of character constants is int, but in C++, data type of same is char. If we save below program as test.c… Read More »

## A nested loop puzzle 2.7

Which of the following two code segments is faster? Assume that compiler makes no optimizations. filter_none edit close play_arrow link brightness_4 code /* FIRST */… Read More »

## Merge two sorted linked lists 2.7

Write a SortedMerge() function that takes two lists, each of which is sorted in increasing order, and merges the two together into one list which… Read More »

## G-Fact 8 2

To uniquely construct a Binary Tree, Inorder together with either Postorder or Preorder must be given (See this for details). However, either Postorder or Preorder… Read More »

## Alternating split of a given Singly Linked List | Set 1 2.4

Write a function AlternatingSplit() that takes one list and divides up its nodes to make two smaller lists ‘a’ and ‘b’. The sublists should be… Read More »

## Practice Questions for Recursion | Set 2 2.4

Explain the functionality of following functions. Question 1 filter_none edit close play_arrow link brightness_4 code /* Assume that n is greater than or equal to… Read More »

## A Product Array Puzzle 2.5

Given an array arr[] of n integers, construct a Product Array prod[] (of same size) such that prod[i] is equal to the product of all… Read More »

## Intersection of two Sorted Linked Lists 2.5

Given two lists sorted in increasing order, create and return a new list representing the intersection of the two lists. The new list should be… Read More »

## Maximum width of a binary tree 2.5

Given a binary tree, write a function to get the maximum width of the given tree. Width of a tree is maximum of widths of… Read More »

## Run Length Encoding 2.2

Given an input string, write a function that returns the Run Length Encoded string for the input string. For example, if the input string is… Read More »

## Practice Questions for Recursion | Set 1 2.3

Explain the functionality of following functions. Question 1 filter_none edit close play_arrow link brightness_4 code int fun1(int x, int y)  {   if(x == 0)     return… Read More »

## Ceiling in a sorted array 2.4

Given a sorted array and a value x, the ceiling of x is the smallest element in array greater than or equal to x, and… Read More »

## Reverse words in a given string 2.5

Example: Let the input string be “i like this program very much”. The function should change the string to “much very program this like i”… Read More »

## Double Tree 2.3

Write a program that converts a given tree to its Double tree. To create Double tree of the given tree, create a new duplicate for… Read More »

## When is copy constructor called? 2.4

In C++, a Copy Constructor may be called in following cases: 1. When an object of the class is returned by value. 2. When an… Read More »

## C Language | Set 7 2.8

Following questions have been asked in GATE CS 2010 exam. 1. What does the following program print? filter_none edit close play_arrow link brightness_4 code #include<stdio.h>… Read More »

## Given a binary tree, print all root-to-leaf paths 2.4

For the below example tree, all root-to-leaf paths are: 10 –> 8 –> 3 10 –> 8 –> 5 10 –> 2 –> 2 Recommended:… Read More »

## Do not use sizeof for array parameters 2.6

Consider the below program. filter_none edit close play_arrow link brightness_4 code #include<stdio.h> void fun(int arr[])   {   int i;         /* sizeof should not be used… Read More »

## Maximum difference between two elements such that larger element appears after the smaller number 2.7

Given an array arr[] of integers, find out the maximum difference between any two elements such that larger element appears after the smaller number. Examples… Read More »

## Root to leaf path sum equal to a given number 2.5

Given a binary tree and a number, return true if the tree has a root-to-leaf path such that adding up all the values along the… Read More »