Wednesday, December 31, 2008

Data Structure- Frequently Asked 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.

4.) 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.

5.) 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.

6.) Difference between calloc and malloc?


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

7.) 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.

8.) 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;

No comments: