You are on page 1of 3

DATA STRUCTURES QUESTIONS (1) Reversing a linked list (2) Traversals of binary tree (3) traversals of graph (4)

Time complexity (5) deleting a node from a binary search tree (6) What data structure will you use for DFS,BFS? (7) Various sorting techniques. Write algo for any sorting. (10) What is hashing? (11) How do u detect a loop in a linked list? (12) Which sorting technique has the least worst case? --> heap sort. (13) code for Tower of Hanoi (14) Prefix and Postfix (15) Multiplication of number ( Recusive) Ans: a*b=a if b==1 a*b=a * (b-1) + a if b>1 (16) Recusive solution (trace the stack) (17) Preorder and postorder traversals (18) How to check out that graph is connected or not? (19) A binary search tree is given. Tell the 4th smallest value in it. (20) How can you insert different types of elements in one stack? We know the various types of elements that can be stored on the stack. (21) How will you sort a linked list?

(22) A list is ordered from smaller to largest when a sort is called. Which sort would take the shortest time to execute? (23) There are 8, 15, 13, and 14 nodes in 4 different trees. Which one of them can form a full binary tree? (24) Write code to sort a list such that all odd numbers come first, then all even numbers. (25) Deleting a node when a given a pointer only to that node, deleting last node in this case (26) How to read a singly linked list backwards? a: Using recursion
void display_reverse(struct node *head) { if(head->next != NULL) display_reverse(head->next); else { printf("\t%d",head->data); return; } }

(27) AVL tree rotations (28) How to represent binary tree, complete binary tree and full binary tree? (29) B, B+ tree (30) reversing, sorting, implementing priority queue, contrast with an array, which type is suitable for a queue, dequeue?, finding loop in a LL, merging 2 LL. (31) Find the common node in intersecting linked lists. (soln: let L1 and L2 be the lengths of the larger and smaller lists. Traverse L1-L2 node from larger list. Now the common node is equidistant from current ptrs) (32) Find the mid point of a link list w/o using counters. ( soln : take 2 ptr.. shift one by one node... and other by two nodes) ( (33) list the members of BST in descending order. (34) Tree traversals ---> inorder , preorder , postorder , converse preorder ,converse inorder , converse postorder , double order (35) number of possible binary tree with 3 nodes ---> 5 4 nodes ---> 12

n nodes ---> (2^n)-n (36) A full binary trees with 'n' non leaf nodes contains how many nodes??? ---> 2n+1 (37) full binary tree with height 'h' contains how many nodes??? ---> 2^(h+1)-1 (38) what is complete binary tree??? ---> n nodes & interval between [1...n] (39) how can u efficiently implement complete binary tree & full binary tree ??? ---> using array how can u efficiently implement binary tree ??? ---> using douly link list (40)if each node in a tree has 0 or 3 children and the tree contains 'n' nodes then what are the number of leaf nodes??? ---> (2n+1)/3 let the students solve it using examples.. (41) minimal number of states in a DFA that accepts all strings of 'a' & 'b' of length "Excatly n" ---> n+2 "Almost n" ---> n+2 "Atleast n" ---> n+1 (42) minimal number of states in a DFA that accepts all binary number divisible by 4 contains hw many states?? ---> 4 states divisible by 5 contains hw many states?? ---> 5 states divisible by n contains hw many states?? ---> n states (43) minimal number of states in a DFA that accepts all strings of 'a' & 'b' such that 'n'th from LHS is 'a' contains hw many state??? ---> n+2 states (44) minimal number of states in a DFA that accepts all strings of 'a' & 'b' such that 'n'th from RHS is 'a' contains hw many state??? ---> 2^n states (45) minimal number of states in a DFA that accepts all strings of 'a' & 'b' such that number of 'a' divisible by 2 & number of 'b' by 3 --- 2*3= 6 states (46) minimal number of states in a DFA that accepts all strings of 'a' & 'b' such that number of 'a' divisible by 2 as well by 4 --- 4 states (47) minimal number of states in a DFA that accepts all strings of 'a' & 'b' such that number of 'a' divisible by 2 & number of 'b' by 4 --- 2*4= 8 states (48) minimal number of states in a DFA that accepts all strings of 'a' & 'b' such that number of 'a' divisible by 2,3,5,7 --- 2*3*5*7= 210 states

You might also like