Search:     Advanced search
Browse by category:
Showing: 1-15 of 25    »»
Articles
 
document Q: What is DCLGEN ?
A: DeCLarations GENerator: used to create the host language copy books for the table definitions. Also creates the DECLARE table. 
rating 23 Jul, 2008 Views: 1015 Comments: 0
document 1.Can you construct a tree using postorder and preorder traversal?
No Consider 2 trees below   Tree1 a b Tree 2 a b preorder = ab postorder = ba Preorder and postorder do not uniquely define a binary tree. Nor do preorder and level order (same example). Nor do postorder and level order.
Not rated 03 May, 2008 Views: 292 Comments: 0
document Q: How would you retrieve rows from a DB2 table in embedded SQL?
A: Either by using the single row SELECT statements,or by using the CURSOR.
rating 23 Jul, 2008 Views: 485 Comments: 0
document Construct a tree given its inorder and preorder traversal strings. Similarly construct a tree given its inorder and post For Inorder And Preorder traversals
inorder = g d h b e i a f j c preorder = a b d g h e i c f j Scan the preorder left to right using the inorder sequence to separate left and right subtrees. For example, "a" is the root of the tree; "gdhbei" are in the left subtree; "fjc" are in the right subtree. "b" is the next root;
Not rated 03 May, 2008 Views: 478 Comments: 0
document Find the closest ancestor of two nodes in a tree.
Here is some working C code... #include typedef struct node { int value; struct node *right; struct node *left; }mynode; mynode *root; mynode *add_node(int value); void levelOrderTraversal(mynode *root); mynode *closestAncestor(mynode* root, mynode* p, mynode* q); int main(int argc, char* argv[]) { mynode *node_pointers[7], *temp; root = NULL; // Create the BST. // Store the node
Not rated 03 May, 2008 Views: 302 Comments: 0
document What is an AVL tree?
AVL trees are self-adjusting, height-balanced binary search trees and are named after the inventors: Adelson-Velskii and Landis. A balanced binary search tree has O(log n) height and hence O(log n) worst case search and insertion times. However, ordinary binary search trees have a bad worst case. When sorted data is inserted, the binary search tree is very unbalanced, essentially more of a linear list, with O(n) height and thus
Not rated 17 Mar, 2008 Views: 475 Comments: 0
document How many different trees can be constructed using n nodes?
Its 2^n - n So, if there are 10 nodes, you will have (1024 - 10) = 1014 different trees!! Confirm it yourself with a small number if you dont believe the formula.    
Not rated 17 Mar, 2008 Views: 195 Comments: 0
document Check if the 20th bit of a 32 bit integer is on or off?
if((num & x00001000)==x00001000)   Note that the digits represented here are in hex. 0 0 0 0 1 0 0 0 ^ | x0000 0000 0000 0000 0001 0000 0000 0000 = 32 bits ^ ^ ^ | | | 0th bit 20th bit 32nd bit
Not rated 19 Mar, 2008 Views: 265 Comments: 0
document How to reverse the bits in an interger?
Here are some ways to reverse the bits in an integer. Method1 unsigned int num; // Reverse the bits in this number. unsigned int temp = num; // temp will have the reversed bits of num. int i; for (i = (sizeof(num)*8-1); i; i--) { temp = temp | (num & 1); temp = 1; } temp = temp | (num
Not rated 19 Mar, 2008 Views: 247 Comments: 0
document What purpose do the bitwise and, or, xor and the shift operators serve?
The AND operator Truth Table ----------- 0 AND 0 = 0 0 AND 1 = 0 1 AND 0 = 0 1 AND 1 = 1 x AND 0 = 0 x AND 1 = x We use bitwise "and" to test if certain bit(s) are one or not. And'ing a value against a pattern with ones only in the
Not rated 19 Mar, 2008 Views: 299 Comments: 0
document Write a C program to count bits set in an integer?
This is one of the most frequently asked interview questions of all times... There are a number of ways to count the number of bits set in an integer. Here are some C programs to do the same. Method1 This is the most basic way of doing it. #include int main() { unsinged int num=10; int ctr=0; for(;num!=0;num>>=1) {
Not rated 19 Mar, 2008 Views: 202 Comments: 0
document What is a threaded binary tree?
Since traversing the three is the most frequent operation, a method must be devised to improve the speed. This is where Threaded tree comes into picture. If the right link of a node in a tree is NULL, it can be replaced by the address of its inorder successor. An extra field called the rthread is used. If rthread is equal to 1, then it means that the right
Not rated 19 Mar, 2008 Views: 253 Comments: 0
document A full N-ary tree has M non-leaf nodes, how many leaf nodes does it have?
Use Geometric progression. M + (N ^ (n-1)) = (1 - (N ^ n)) / (1 - N) Here (N ^ (n-1)) is the number of leaf-nodes. Solving for this leads to the answer Leaf nodes = M * (N - 1) + 1   Suppose you have a 3-ary tree A B C D E F G H I J K L M   So,
Not rated 19 Mar, 2008 Views: 201 Comments: 0
document Write a C program to count bits set in an integer?
This is one of the most frequently asked interview questions of all times... There are a number of ways to count the number of bits set in an integer. Here are some C programs to do the same. Method1 This is the most basic way of doing it. #include int main() { unsinged int num=10; int ctr=0; for(;num!=0;num>>=1) {
Not rated 19 Mar, 2008 Views: 163 Comments: 0
document Implement Breadth First Search (BFS) and Depth First Search (DFS)
Depth first search (DFS) Depth First Search (DFS) is a generalization of the preorder traversal. Starting at some arbitrarily chosen vertex v, we mark v so that we know we've visited it, process v, and then recursively traverse all unmarked vertices adjacent to v (v will be a different vertex with every new method call). When we visit a vertex in which all of its neighbors have been
Not rated 19 Mar, 2008 Views: 310 Comments: 0



RSS