Data Structure Interview Questions – Set 02

What are the advantages of Selecetion Sort?

  • It is simple and easy to implement.
  • It can be used for small data sets.
  • It is 60 per cent more efficient than bubble sort.

List the types of tree.

There are six types of tree given as follows.

  • General Tree
  • Forests
  • Binary Tree
  • Binary Search Tree
  • Expression Tree
  • Tournament Tree

List the data structures which are used in RDBMS, Network Data Modal, and Hierarchical Data Model.

  • RDBMS uses Array data structure
  • Network data model uses Graph
  • Hierarchal data model uses Trees

What are the advantages of Linked List over an array?

  • The size of a linked list can be incremented at runtime which is impossible in the case of the array.
  • The List is not required to be contiguously present in the main memory, if the contiguous space is not available, the nodes can be stored anywhere in the memory connected through the links.
  • The List is dynamically stored in the main memory and grows as per the program demand while the array is statically stored in the main memory, size of which must be declared at compile time.
  • The number of elements in the linked list are limited to the available memory space while the number of elements in the array is limited to the size of an array.

What is the difference between PUSH and POP?

PUSH and POP operations specify how data is stored and retrieved in a stack.

PUSH: PUSH specifies that data is being “inserted” into the stack.

POP: POP specifies data retrieval. It means that data is being deleted from the stack.

List some applications of queue data structure.

The Applications of the queue is given as follows:

  • Queues are widely used as waiting lists for a single shared resource like a printer, disk, CPU.
  • Queues are used in the asynchronous transfer of data (where data is not being transferred at the same rate between two processes) for eg. pipes, file IO, sockets.
  • Queues are used as buffers in most of the applications like MP3 media player, CD player, etc.
  • Queues are used to maintain the playlist in media players to add and remove the songs from the play-list.
  • Queues are used in operating systems for handling interrupts.

Write the recursive C function to count the number of nodes present in a binary tree.

int count (struct node* t)
{
if(t)
{
int l, r;
l = count(t->left);
r=count(t->right);
return (1+l+r);
}
else
{
return 0;
}
}

Differentiate among cycle, path, and circuit?

Path: A Path is the sequence of adjacent vertices connected by the edges with no restrictions.
Cycle: A Cycle can be defined as the closed path where the initial vertex is identical to the end vertex. Any vertex in the path can not be visited twice
Circuit: A Circuit can be defined as the closed path where the intial vertex is identical to the end vertex. Any vertex may be repeated.

What are Binary trees?

A binary Tree is a special type of generic tree in which, each node can have at most two children. Binary tree is generally partitioned into three disjoint subsets, i.e. the root of the node, left sub-tree and Right binary sub-tree.

What is a multidimensional array?

The multidimensional array can be defined as the array of arrays in which, the data is stored in tabular form consists of rows and columns. 2D arrays are created to implement a relational database lookalike data structure. It provides ease of holding the bulk of data at once which can be passed to any number of functions wherever required.