## Diameter of a Binary TreeMarch 15, 2010

The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two leaves in the tree.

## gets() is risky to use!

Consider the below program. The code looks simple, it reads string from standard input and prints the entered string, but it suffers from Buffer Overflow… Read More »

## Implement Queue using StacksMarch 13, 2010

The problem is opposite of this post. We are given a stack data structure with push and pop operations, the task is to implement a… Read More »

## Result of sizeof operator

Asked by Kapil Predict the output of below program.

## Multiply two integers without using multiplication, division and bitwise operators, and no loopsMarch 11, 2010

By making use of recursion, we can multiply two integers with the given constraints. To multiply x and y, recursively add x y times. Time… Read More »

## C Language | Set 6March 9, 2010

Following questions have been asked in GATE CS 2006 exam.

## How does “void *” differ in C and C++?March 8, 2010

C allows a void* pointer to be assigned to any pointer type without a cast, whereas C++ does not; this idiom appears often in C… Read More »

## Data Structures and Algorithms | Set 16March 7, 2010

Following questions have been asked in GATE CS 2009 exam.

## C function to Swap stringsMarch 6, 2010

Let us consider the below program.

## An Uncommon representation of array elementsMarch 4, 2010

Consider the below program.

## Storage for Strings in CMarch 3, 2010

In C, a string can be referred either using a character pointer or as a character array.

## Output of C Programs | Set 13March 2, 2010

Difficulty Level: Rookie Question 1 Predict the output of below program.

## k largest(or smallest) elements in an array | added Min Heap methodMarch 1, 2010

Question: Write an efficient program for printing k largest elements in an array. Elements in array can be in any order.

## Segregate 0s and 1s in an arrayFebruary 28, 2010

You are given an array of 0s and 1s in random order. Segregate 0s on left side and 1s on right side of the array.… Read More »

## calloc() versus malloc()February 27, 2010

The name malloc and calloc() are library functions that allocate memory dynamically. It means that memory is allocated during runtime(execution of the program) from heap… Read More »