Thursday, January 7, 2010

Data structure interview questions Part 9

Data structure interview question:Stack can be described as a pointer. Explain?
Answer:Because stack will contain a head pointer which will always point to the top of the Stack.All Stack Operations are done using Head Pointer. Hence Stack ca be Described as a Pointer

Data structure interview question:What do you mean by Base case, Recursive case, Binding Time, Run-Time Stack and Tail Recursion?

Answer:These terms are found in Recursion.1.Base Case:it is the case in recursion where the answer is known,or we can say the termination condition for a recursion to unwind back.For example to find Factorial of num using recursion:

int Fact(int num){

if(num==1 || num==0)//base case
return 1;
else // recursive case:
return num*Fact(num-1);
2.Recursive case:It is the case whcih brings us to the
closer answer.

Run Time Stack:It is a system stack us to save the frame stack of a function every recursion or every call.This frame stack consists of the return address,local variables and return value if any.

Tail Recursion:The case where the function consist of single recursive call and it is the last statement to be executed.A tail Recursion can be replace by iteration. The above funtion consists of tail recursion case.where as the below function does not.

void binary(int start,int end,int el){
int mid;
return mid;

Data structure interview question:What data structure would you mostly likely see in a non recursive implementation of a recursive algorithm?


Data structure interview question:what is binary tree?

Answer:Binary tree is a tree which has maximum no. of childrens either 0 or 1 or 2. i.e., there is at the most 2 branches in every node.

No comments:

Post a Comment