##
Output of C Programs | Set 1
June 27, 2009

Predict the output of below programs.

June 27, 2009

Predict the output of below programs.

Mirror of a Tree: Mirror of a Binary Tree T is another Binary Tree M(T) with left and right children of all non-leaf nodes interchanged.

To delete a tree we must traverse all the nodes of the tree and delete them one by one. So which traversal we should use – Inorder or Preorder or Postorder. Answer is simple – Postorder, because before deleting the parent node we should delete its children nodes first We can delete tree with other… Read More »

Given a binary tree, find height of it. Height of empty tree is 0 and height of below tree is 3.

June 26, 2009

Two trees are identical when they have same data and arrangement of data is also same.

June 23, 2009

Size of a tree is the number of elements present in the tree. Size of the below tree is 5.

Unlike linear data structures (Array, Linked List, Queues, Stacks, etc) which have only one logical way to traverse them, trees can be traversed in different ways. Following are the generally used ways for traversing trees.

June 22, 2009

The eight queens problem is the problem of placing eight queens on an 8×8 chessboard such that none of them attack one another (no two are in the same row, column, or diagonal). More generally, the n queens problem places n queens on an n×n chessboard. There are different solutions for the problem. Backtracking |… Read More »

In the below code, change/add only one character and print ‘*’ exactly 20 times.

What should be the “condition” so that the following code snippet prints both HelloWorld !

Power Set Power set P(S) of a set S is the set of all subsets of S. For example S = {a, b, c} then P(s) = {{}, {a}, {b}, {c}, {a,b}, {a, c}, {b, c}, {a, b, c}}. If S has n elements in it then P(s) will have 2^n elements