You are on page 1of 3

Tree Questions: 1) Convert the structure Tree1 to structure Tree2. Tree1 is a general tree structure.

Tree2 structure contains one pointer to first child and one pointer to sibling. Note: You need to free the memory allocated for structure tree1 struct Tree1 { ElementType value; struct Tree child[10]; } struct Tree2 { Element Type value; struct Tree * firstChild; strcut Tree * sibling; } 2) You will be given a NxN matrix. In which each row represents one node of a tree. Each row contains the ancestor details of that node. Construct the tree back from the given NxN matrix. For ex: Input: A B C D Output: A 0 1 1 1 B 0 0 0 0 C 0 0 0 1 D 0 0 0 0

3) Given a binary tree assume each node has one unfilled pointer that should point to immediate node that is in the same level of the node. Given tree fill the pointer of each node. 4) Given a binary search tree and a value V. Return the node of binary search tree such that key of the node is > V. [Inorder successor of the tree] 5) In a Red-Black tree change the red nodes to black nodes. Linked List Questions: 1) Given an linked list you need to free the even nodes of the list. You need to change single line of the code you have written so that it should free odd nodes. 2) Given an linked list you need to interchange alternative nodes.

eg: Input: 1 -> 2 -> 3 -> 4 -> 5 -> 6 Output: 3 -> 4 -> 1 -> 2 -> 5 -> 6 3) Given an linked list pick a random node from the list. Each node should get equal chance. Strings Questions: 1) Given a string you need to find the first non repeating character in that string. Give as many unit testcases as you can. Input: abcbacd output: d Binary Search Questions: 1) You will be given a perfect square you need to find the square root of the number. Dynamic programming: 1) Given a string you need to find the longest palindromic substring in that string. 2) Given a string you need to find the maximum number of palindromic substrings exist in that string. [ Note: substring length should be at least 2] 3) given a NxN matrix you need to start at (1,1), in how many ways you will reach (NxN). You can move right or down. Graph Questions: 1) Given two strings string1 and string2. You need to transform string1 to string2. Allowed operations are edit,insert and delete but each time you perform any operation on of these operations the resulting string should be there in the dictionary. ex: cat -> hate Answer: cat->hat->hate 2) Given a NxN matrix you need to start at (1,1), in how many ways you will reach (NxN). You can move left, right and down. General Questions: 1) Given an array A, you need to find out two indexes i, j such that i<j and distance between A[i] and A[j] should be minimum. 2) Question 1 in General question was posed in different way i.e you need to find out two indexes i, j such that i>j and distance between A[i] and A[j] should be maximum. 3) Convert decimal number to hexadecimal number. Few other questions are there i Will send them later. Mean while solve all the above problems:-)

You might also like