Play and learn 300 000+ tabs online

Thursday, May 27, 2010

DataStructure Interview Questions

1.) What is Heap data structure?

The binary heap data
structures is an array that can be viewed as a complete binary tree.
Each
node of the binary tree corresponds to an element of the array.
The
array is completely filled on all levels except possibly lowest.

2.)
What are the major data structures used in the following areas : RDBMS,
Network data model & Hierarchical data model?

1. RDBMS Array
(i.e. Array of structures)
2. Network data model Graph
3.
Hierarchical data model Trees

3.) Why is the isEmpty() member
method called?

The isEmpty() member method is called within the
dequeue process to determine if there is an item in the
queue to be
removed i.e. isEmpty() is called to decide whether the queue has at
least one element.
This method is called by the dequeue() method
before returning the front element.
What method is used to place a
value onto the top of a stack?
push() method, Push is the direction
that data is being added to the stack.
push() member method places a
value onto the top of a stack.

4.) What is Linked List ?

Linked
List is one of the fundamental data structures. It consists of a
sequence of? nodes,
each containing arbitrary data fields and one or
two (”links”) pointing to the next and/or previous nodes.
A linked
list is a self-referential datatype because it contains a pointer or
link to another data of the same type.
Linked lists permit insertion
and removal of nodes at any point in the list in constant time, but do
not allow random access.

5.) Difference between calloc and
malloc?

malloc: allocate n bytes calloc: allocate m times n bytes
initialized to 0

6.) How many parts are there in a declaration
statement?

There are two main parts, variable identifier and data
type and the third type is optional
which is type qualifier like
signed/unsigned.

7.) What is the difference bitween NULL AND VOID
pointer?

NULL can be value for pointer type variables. VOID is a
type identifier which has not size.
NULL and void are not same.
Example: void* ptr = NULL;
Core Dimension is a Dimension table which
is used dedicated for single fact table or Datamart.
Conform
Dimension is a Dimension table which is used across fact tables or
Datamarts.

8.) How can a node be inserted in the middle of a
linked list?

By repointing the previous and the next elements of
existing nodes to the new node. You can insert a
node in the middle
of a linked list by repointing the previous and the next elements of
existing nodes to the new node.

9.) What are the various kinds of
sorting techniques? Which is has best case?

Bubble sort Quick
sort Insertion sort Selection sort Merge sort Heap sort Among the
sorting algorithms quick sort is the best one

10.) Without using
/,% and * operators. write a function to divide a number by 3?

#include

#include
void main()
{
int i,n;
float
j=0;
clrscr();
printf("enter the no");
scanf("%d",&n);
for(i=n;i>2;i=i-3)
{
j=j+1;
if(i==4)
{
j=j+1.333333;
}
if(i==5)
{
j=j+1.666666;
}
printf("%f",j);
getch();
}

11.)
What is the use of fflush() function?

The function fflush forces
a write of all buffered data for the given output or update stream via
the stream's underlying write function.

12.) What is binary tree?

A
binary tree is a tree in which every node has exactly two links i.e
left and right link

13.) Which one is faster? A binary search of
an orderd set of elements in an array or a sequential search of the
elements.

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.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.