You are browsing the archive for 2010 October.

Binary Tree Post-Order Traversal Iterative Solution

October 27, 2010 in binary tree

Given a binary tree, print the elements in post-order iteratively without using recursion.

Read the rest of this entry →

Print Edge Nodes (Boundary) of a Binary Tree

October 20, 2010 in binary tree

Print all edge nodes of a complete binary tree anti-clockwise.
That is all the left most nodes starting at root, then the leaves left to right and finally all the rightmost nodes.
In other words, print the boundary of the tree.

Variant: Print the same for a tree that is not complete.

Read the rest of this entry →

Implement strstr() to Find a Substring in a String

October 14, 2010 in string

Write C code to implement the strstr (Search for a substring) function. Do not use any system library such as strlen.

Read the rest of this entry →

Searching a 2D Sorted Matrix Part III

October 13, 2010 in divide and conquer

Write an efficient algorithm that searches for a value in an n x m table (two-dimensional array). This table is sorted along the rows and columns — that is,

Table[i][j] ≤ Table[i][j + 1],
Table[i][j] ≤ Table[i + 1][j]

Read the rest of this entry →

Searching a 2D Sorted Matrix Part II

October 8, 2010 in divide and conquer

Write an efficient algorithm that searches for a value in an n x m table (two-dimensional array). This table is sorted along the rows and columns — that is,

Table[i][j] ≤ Table[i][j + 1],
Table[i][j] ≤ Table[i + 1][j]

Read the rest of this entry →

Searching a 2D Sorted Matrix Part I

October 6, 2010 in divide and conquer

Write an efficient algorithm that searches for a value in an n x m table (two-dimensional array). This table is sorted along the rows and columns — that is,

Table[i][j] ≤ Table[i][j + 1],
Table[i][j] ≤ Table[i + 1][j]

Read the rest of this entry →

Excel Sheet Row Numbers

October 1, 2010 in Uncategorized

Given the sequence S1 = {a,b,c,d,…,x,y,z,aa,ab,ac…. } and given that this sequence corresponds (term for term) to the sequence S2 = {0,1,2,3,….}. Write code to convert an element of S2 to the corresponding element of S1.

Read the rest of this entry →