|
Data Structure Interview Questions |
|
What is data structure? |
|
A data structure is a way of organizing data that considers not only the items stored,
but also their relationship to each other. Advance knowledge about the relationship
between data items allows designing of efficient algorithms for the manipulation
of data |
|
What is the data structures used to perform
recursion? |
|
Stack. Because of its LIFO (Last In First Out) property it remembers
its caller, so knows whom to return when the function has to return. Recursion makes
use of system stack for storing the return addresses of the function calls. Every
recursive function has its equivalent iterative (non-recursive) function. Even when
such equivalent iterative procedures are written, explicit stack is to be used. |
|
In RDBMS, what is the efficient data structure
used in the internal storage representation? |
|
B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes
searching easier. This corresponds to the records that shall be stored in leaf nodes. |
|
What is a spanning Tree? |
A spanning tree is a tree associated with a network. All the nodes of the graph
appear on the tree once. A minimum spanning tree is a spanning tree organized so
that the total edge weight between nodes is minimized.
Does the minimum spanning tree of a graph give the
shortest distance between any 2 specified nodes?
Minimal spanning tree assures that the total weight of the tree is kept at its minimum.
But it doesn't mean that the distance between any two nodes involved in the minimum-spanning
tree is minimum.
|
|
What is the difference between an ARRAY and a LIST? |
|
Array |
List |
|
Array is collection of homogeneous elements. |
List is collection of heterogeneous elements.
|
|
For Array memory allocated is static and continuous. |
For List memory allocated is dynamic and Random.
|
|
User need not have to keep in track of next memory allocation. |
User has to keep in Track of next location where memory is allocated.
|
Array uses direct access of stored members
Object x = a[5]; // x takes directly a reference to 5th element of array |
List uses sequencial access for members.
//With the list you have to cross all previous nodes in order to get the 5th node:
list mylist; list::iterator it;
for( it = list.begin() ; it != list.end() ; it++ )
{
if( i==5)
{
x = *it;
break;
}
i++; |
|
|
|
|
|
|