# Data structure Interview Question

## -: Data structure Interview Question :-

1. Is it possible to find a loop in a Linked list ?

Ans: Yes it is Possilbe at O(n).

2. Two linked lists L1 and L2 intersects at a particular node N1 and from there all other nodes till the end are common. The length of the lists are not same. What are the possibilities to find N1?.

Ans:Yes Linear solution is possible.

3. void PrintTree (Tree T)

Ans:{

1. void PrintTree (Tree T)

Ans:{

if (T != NULL)

{

PrintTree (T-> Left);

PrintElement (T-> Element);

PrintTree (T->Right);

}

}

The above method ‘PrintTree’ results in which of the following traversal

a Inorder

1. Preorder
2. Postorder
3. None of the above

Solution: a. Inorder

Inorder:

void PrintTree (Tree T)

{

if (T != NULL)

{

PrintTree (T-> Left);

PrintElement (T-> Element);

PrintTree (T->Right);

}

}

For preorder use this order

PrintElement (T-> Element);

PrintTree (T-> Left);

PrintTree (T->Right);

For postorder use this order

PrintTree (T-> Left);

PrintTree (T->Right);

PrintElement (T-> Element);

4.Given a Binary Search Tree (BST), print its values in ascending order

Ans:By performing Perform Inorder traversal,which is property of BST.

5.Is it possible to implement a queue using Linked List ?. Enqueue & Dequeue should be O(1).

Ans:Yes  Both Enqueue and Dequeue is possible at O(1).

6.How many stacks are required to implement a Queue.

Ans:Two stacksare required for impliment a Queue.

7.Is it possible to find a loop in a Linked list ?

Ans:yes Possible at O(n).

8.In Which method PrintTree results  in which of the following traversal

Ans: Inorder

9.How many type of sort technique is there

Ans: 3 type of technique is there.

1.Quick sorrt

2.marge sort

3.binary sarch.

10.Which two method follow Greddy method

Ans:1.Short path algorithm and Knapsack algorithm.

11.Discusee 5 different type of Dynamic programming Technique

Ans:

1.Travelling salseman

2.Depth first search

3.Breath first search

4.Flow shop scheduling

5.Knapsack problem.

12.What is the need of Data Structure

Ans:In the simplest from That computer can be defined as a fast electronic calculating Machine.

13.How data can be organized in  Memory

Ans: it can be organized By two way 1.Logical, anpother is 2.Mathamatical.

14.what are The Application of various Data structure

Ans 1. compiler desinge

2.Operating system

3.DBMS

4.Graphical desinge

5.Simulation and modaling 6.communicational system.

15.What is algorithm

Ans:Algorithm is a construction of flow of logic.The solution of pertucular Problem.

16.What is program in DS

Ans: Algorithm along with Data structure is a program.

17.What is spars Matrix

Ans:The matrix with filled with most zero M*N matrics. That Type of matrix is called spars Matrix.

18.How many way you can insert element in an Array

Ans:

1.at the starting

2.In the end and

3.In betwwn Two element.

19.How can be delete an element from an Array

Ans:1.at the starting

2.In the end and

3.In betwwn Two element.

20.Write a cod for deletion Element from array

Ans:

int delete(inta[],int n,int i)

{

Int j,x;

x=a[i];

for(j=1; j<=n-1; j++)

a[j]=a[j+1];

n–;

return (x);

}

21.why running out of memory occur

Ans:Due to recursive function call.

22.How many Value can be held by an array

Ans:m to the power of 2 value can be held.

Campus Interview

23.Which type of expressions dose not require Precedence rule For evaluated

Ans:More the one of the full parenthesized infix ,prefix partially parenthesized.

24.The expression which access the(ij)th entry of a m*n matrix stord in column major from is

Ans:m*(j-1)+1;25.POP function occour in

1.Stack

2.queue

4.None of theseAns:Stack.

26.What are the two different Function of Stack

Ans:PUSH and POP.

27.Give a methamatical expression for Prefix,postfix and infix

Ans:Infix: A+B;    Prefix:+AB; Postfix:AB+;]

28.What is Queue

Ans: A queue is an abstruct Data type,which have two function QINSERT and QDELETE.It follow the rule of FIFO i.e. First in First Out.

29.What is priority Queue

Ans:A priority Queue is a Data structure used for storing a set S of element,based on a Key value,which denotes the priority of the element.

30.Which Tehnique is used in BFS Graphical

Ans:Queue Technique is used there.

31.Which Tehnique is used in DFS Graphical

Ans:DFS graphical trevarsel used the Stack Technique.

32.Write an Advantage of Dubly linked list

Ans:Both way trevarsel can be possiable through Nodes and its address.The time requered to search an element in a linked list of length n is Ans:o(n)