Sunday, February 7, 2010

Data structure interview questions Part 10

Data structure interview question:Create an singly linked lists and reverse the lists by interchanging the links and not the data?
struct node{ int data;
node * next;
node *pt1,*pt2=NULL:

Data structure interview question::What is B+ tree? 
Answer:A B+ tree is a type of tree which represents sorted data in a way that allows for efficient insertion, retrieval and removal of records, each of which is identified by a key. It is a dynamic, multilevel index, with maximum and minimum bounds on the number of keys in each index segment (usually called a 'block' or 'node'). In a B+ tree, in contrast to a B-tree, all records are stored at the lowest level of the tree; only keys are stored in interior blocks.
            The primary value of a B+ tree is in storing data for efficient retrieval in a block-oriented storage context. Given a storage system with a block size of b, a B+ tree which stores a number of keys equal to a multiple of b will be very efficient when compared to a binary search tree (the corresponding data structure for non-block-oriented storage

Data structure interview question:Which one is faster? A binary search of an orderd set of elements in an array or a sequential search of the elements.
Answer:Binary search is faster because we traverse the elements by using the policy of Divide and Conquer. we compare the key element with the approximately center element, if it is smaller than it search is applied in the smaller elements only otherwise the search is applied in the  larger set of elements. its complexity is as we all know is log n as compared to the sequential one whose complexity is n.

Data structure interview question:Parenthesis are never needed in prefix or postfix expressions. Why?
Answer:Basically Parenthesis indicate the operations which  need to be carried out first ie according to the BODMAS rule..SO in case of postfix or prefix expression they are actualy conversions of the orginal standard  equation.Where the brackets have already been taken into consideration,,,and the formed prefix/postfix  expression is the correct order of expansion of a given  mathematical statement.

Data structure interview question:How can one find a cycle in the linked list? IF found how to recognize the cycle and delete that cycle?
Answer: find_cycle(Node* head){
Node* ptr1 = head;
Node* ptr2 = head;

while(ptr1 != NULL && ptr2 != NULL && ptr2->next != NULL){
if(ptr1 == ptr2){
printf("\nClycle present in thr LinkList\n");
return true;
ptr1 = prt1->next;
ptr2 = ptr2->next->next;
return false;


  1. data structures interview questions covered in the this site is very good for all engineering graduates.

  2. ya simbu..i agree with u.We should inform these datastructure interview questions to all.

  3. This data structure question site is awesome...keep posting lot of post related to data structures questions while will guide us to success

  4. simply awesome !
    Good job ;-)