You are on page 1of 12

Interview Data Structures Questions and

Answers
OCT 18 • ENGINEERING SAMPLE PAPERS • 1000 VIEWS • 0 COMMENTS

Data Structures and Algorithm is considered as one of the important subject for the

preparation of any technical interview. Candidates preparing for different technical

interviews, find the latest and most asked Data structures questions and answers in a

interview with all the fundamental concepts. Questions has been listed after consulting

from different technical recruiters and successful candidates. Still if it need any

improvement please do let us know through the comment section. You can give your

valuable feedback through the comments. Any type of suggestions will be highly

appreciated.

Introduction : Data structure is the way or concept of storing and organizing data

inside a computer. Different applications used different methodology of arranging or

storing data using the Data structures techniques. Some data structures are used for

some highly specialized application. Data structures are the main technique or concept

for designing an efficient algorithm. In this section, there are lots of Data Structure

questions and answers which will surely help to build some basic concepts related to

Data Structure.

Types of Data Structures

 Linear Data Structure

 Non- Linear Data Structure

data structure

Important Data Structures Questions and Answers


1.(a) List out the areas in which data structures are applied extensively?

The areas where data structures are applied extensively are

 Operating System

 Compiler Design

 Database Management System

 Artificial Intelligence

 Statistical analysis package

 Numerical Analysis

 Graphics

 Simulation

(b) What are the major data structures used in the following areas : RDBMS,

Network data model & Hierarchical data model. ?

These are the major data structure used:

 In RDBMS – Array (i.e. Array of structures)

 In Network Data model – Graph

 In Hierarchical Data model – Trees

(c)If you are using C language to implement the heterogeneous linked list,

what pointer type will you use?

The heterogeneous linked list includes different data types in its nodes and we need a

link, pointer to connect them. It is not possible to use ordinary pointers for this. So we

use void pointer. Void pointer has the ability of storing pointer to any type as it is

a generic pointer type.

(d) Minimum number of queues needed to implement the priority queue?

Two. ( One queue is used for actual storing of data and another for storing priorities.)

(e)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 uses system stack for

storing the return addresses of the function calls. Each and every recursive function has

its equivalent iterative function. Even when such equivalent iterative procedures are

written, explicit stack is to be used.

(f)What are the methods available in storing sequential files?

The methods available in storing sequential files are:

 Straight Merging

 Natural Merging

 Polyphase Sort

 Distribution of Initial runs

(g)List out few of the Application of tree data-structure?

The list is as follows:

 The manipulation of Arithmetic expression

 Symbol Table construction

 Syntax analysis

(h) Differentiate the Hashing Functions based on the various methods by

which the key value is found.

The list is as follows:

 Direct method

 Subtraction method

 Modulo-Division method

 Digit-Extraction method

 Mid-Square method

 Folding method
 Pseudo-random method

(i)Write the types of Collision Resolution Techniques and the methods used in

each of the type?

The types are:

 Open addressing

 The methods used include:

 Overflow block

 Closed addressing

 The methods used include:

 Linked list

 Binary tree

(j)In RDBMS, what is the efficient data structure used in the internal

storage representation?

B+ tree. As in B+ tree, leaf node stores all the data, that’s why the Searching is easier.

This corresponds to the records that shall be stored in leaf nodes.

2. What is a spanning Tree?

It is a tree associated with a network. All the nodes of the graph appear on the tree for

one time. A minimum spanning tree is a spanning tree organized so that the total edge

weight between nodes is minimized.

3. Does the minimum spanning tree of a graph give the shortest distance

between any 2 specified nodes?

No. Minimal spanning tree assures that the total weight of the tree is kept at

its minimum. But the distance between any two nodes involved in the minimum-

spanning tree is not minimum.

4. What is the difference between a queue and a stack?


A queue is FIFO while a stack Is typically LIFO. Elements get inserted at one end of a

queue and retrieved from the other end of the queue, while the removal and insertion

operations for a stack are done at the same end.

5.What is the difference between storing data on the heap vs. on the stack?

The stack is smaller, but faster for creating variables, while the heap is limited in size

only by how much memory can be allocated. Stack would contain most compile time

variables, while heap would contain anything created with malloc or new.

6. Consider the linear arrays AAA(5:50), BBB (-5:10) and CCC(18).

(a) Find the number of elements in each array

(b) Suppose Base(AAA) = 300 and w=4 words per memory cell for AAA. Find

the address of AAA[35] ,AAA[15], and AAA[55]

(a) Length = Upper Bound – Lower Bound +1

Length(AAA) = 50-5+1 = 46

Length(BBB) = 10-(-5)+1 = 16

Length(CCC) = 18-1+1 = 18

(b) Using the formula: LOC(AAA[k]) = Base(AAA)+w(K-LB)

LOC(AAA[15] )= 300+4(15-5) = 340

LOC(AAA[35] )= 300+4(35-5) = 420

AAA[55] is not an element of AAA since 55 exceeds UB = 50.

7. Determining the following stack of characters, where STACK is allocated N =

8 memory cells

STACK : A,C,D,F,K,_,_,_. ( _ means empty allocated cell)

Describe the stack as the following operations takes place:

(a) POP(STACK, ITEM)

(b) POP(STACK, ITEM)


(c) POP(STACK, ITEM)

(d) PUSH(STACK, R)

(e) PUSH(STACK,L)

(f) PUSH(STACK, S)

(g) PUSH(STACK,P)

(h) POP(STACK, ITEM)

(a) STACK: A,C,D,F,_,_,_,_

(b) STACK: A,C,D,_,_,_,_,_

(c) STACK: A,C,_,_,_,_,_,_

(d) STACK: A,C,R,_,_,_,_,_

(e) STACK:A,C,R,L,_,_,_,_

(f) STACK:A,C,R,L,S, _ ,_,_

(g) STACK: A,C,R,L,S,P,_,_

(h) STACK: A,C,R,L,S,_,_,_

8. List out few of the Application of tree data-structure?

The list is as follows:

 Manipulation of Arithmetic expression,

 The symbol Table construction,

 The syntax analysis.

9. What are priority queues?

It is a collection of elements such that each and every element has been assigned a

priority

10. Write the syntax for multiplication of matrices?

for (=0; < value;++)

for (=0; < value;++)


{

for (=0; < value;++)

arr[var1][var2] += arr[var1][var3] * arr[var3][arr2];

Data Structures (DS) Study Material for IBPS IT Officer Exam


Friends, here is the Study Material of Data Structures which will be useful for your
upcoming IBPS Specialist Officers (IT Officers) Exam. We made this PDF in
question and answer format so that it will be easier for you to prepare. We tried to
cover almost all basic important points of Data Structures which are important for the
IT Officers exam. It hardly will take 30 minutes to complete reading this file.
Just download this pdf file and prepare well. You can download more study
materials, Data Structure Questions of IBPS Specialist Officers here.
Data Structures Study Material for IT Professional Knowledge
Every Single mark in the competitive examination is very important for the students
to the grab the opportunity. Knowing this value we are framing out all the possible
information for the candidates about the examination. We are sure our materials help
the candidates a lot in scoring high in the exam. Download Data Structures (DS)
Study Material for IBPS IT Officer here and prepare for exam.
Data Structures – 3 – 4 Questions
1. Array
2. Linked List
3. Stacks
Data Structure Questions for IBPS IT Officer Exam:
In computer science, a data structure is a particular way of storing and organizing data
in a computer so that it can be used efficiently. Different kinds of data structures are
suited to different kinds of applications, and some are highly specialized to specific
tasks. For example, B-trees are particularly well-suited for implementation of
databases, while compiler implementations usually use hash tables to look up
identifiers.
Data structures provide a means to manage large amounts of data efficiently, such as
large databases and internet indexing services. Usually, efficient data structures are a
key to designing efficient algorithms. Some formal design methods and programming
languages emphasize data structures, rather than algorithms, as the key organizing
factor in software design.Storing and retrieving can be carried out on data stored in
both main memory and in secondary memory.

Data Structures
Arrays:
An array is a collection of homogeneous elements that can be placed in contiguous
memory locations that can be individually referenced by using their indexes.
For example, three values of type int can be declared as an array without declaring
three different variables.
Single-Dimensional Array:
Declaring Arrays:
To declare an array, we require the type of the element and the number of elements.
Syntax: type arrayname [ arraysize ] ;
Here, the arraysize must be an integer constant that is greater than zero and the type
can be any valid data type.
Ex: double id [5];
It means that 5-element array which is named as id of data type double.
Initializing Arrays:
We can initialize arrays in different types. For example,
double id [] = {1, 2, 3, 4, 5}; Here if we did not mention any size, then it will
allocated for the number of values we have entered in braces {}.
double id [5] = {1, 2, 3, 4, 5}; Here the number of values in braces {} should not be
greater than the value specified in square brackets [].
double id [4] = 4; This type is for inserting an element into a particular index of an
array.
Accessing Array Elements:
An element from an array can be accessed by using its index number.
For example, double empCode = id [2];

Multi-Dimensional Array:
Declaring Arrays:
The general form of a multidimensional array declaration is given as:
type name [size1] [size2] . . . [sizeN];
For example, four dimensional array can be declared as,
int fourdim [3][4][5][6];
The simplest form of multidimensional array is the two-dimensional array. The
syntax for declaring the two-dimensional array of size x,y is
type arrayname [x] [y];
where type can be any data type and arrayname can be an identifier. And the two-
dimensional array can be considered as a table with x number of rows and y number of
columns.
For example, a two-dimensional array a, which contains three rows and four columns
can be given as:
Hence every element in array a can be identified by the name of the form a[i][j],
where i and j are subscripts that uniquely identify each element in a.

Initializing Two-Dimensional Array:


Initialization of a two-dimensional array can be done by specifying the values for two
rows and three columns can be given as,
int a[2][3] = {
{1, 2, 3},
{4, 5, 6}
};
This can also be done as
int a[2][3] = {1, 2, 3, 4, 5, 6};
Accessing Two-Dimensional Array Elements:
The element in two dimensional array can be accessed by using the subscripts, which
are row index and column index of an array.
For example, int value= a[1][2]; gives the third element of second row.

Linked Lists:
A Linked List is a data structure which consists of a group of nodes which are placed
together in a sequence having data and a reference to the next node in the sequence.
The linked lists are the most common and simplest data structures which are used for
implementing several other common abstract data types like lists, stacks, queues etc.,
The main advantage of using this linked list is that it allows the elements to be
inserted and deleted easily without causing any reorganisation of entire structure
because the data items need not be stored in contiguous memory locations.
These linked lists are dynamic data structures which allocates the memory required
while running the program. And the linear data structures like stacks and queues can
be easily executed with the linked list.
Linked lists can reduce the access time and can expand in real time without memory
overhead. But linked lists also have some disadvantages like, pointers require extra
storage space, hence they have a tendency of wasting the memory.
Nodes in a linked list can be read in a sequential order from the starting to ending as
they are in sequential access. For reverse traversing, linked lists face difficulties as
singly linked lists are extremely difficult to navigate backwards, whereas doubly
linked lists are somewhat easier to read but memory will be wasted for back pointer.
The record in the linked list is called as node or element. Each node contains the data
or information and the address of the next node. The head of the list will be the first
node and thetail will be the next node of the list or the end of the list.
There are different types of linked lists. They are:
Singly Linked List:
In Singly linked list, it have the data field and the next field which is pointed towards
the next node. In this linked list, we can perform insertion, deletion of the nodes and
traversal.

Doubly Linked List:


In a doubly linked list, each node will have the previous node link, the data and the
next node link. In this linked list, we can move forward and backward.

Multiply Linked List:


In multiply linked list, each node will have two or more links which are used to
connect the same set of data in a different order. Hence doubly linked lists can be
known as multiply linked lists, where the orders are opposite to each other.

Circular Linked List:


In this circular linked lists, the last node link is pointed to the first node where as in a
list it will be pointed to a null value.
Similarly for circular doubly linked lists, the tail of last node will be pointed back to
the head of the first node and vice versa.
Stacks:
A Stack is an abstract data type which performs some operations like inserting an
element, known as push and the removal of the element, known as Pop.
This stack works under a structure called as Last-In-First-Out (LIFO) data structure
which means that the element inserted last will be first element that should be deleted.
It is a limited access data structure as the elements must be inserted and removed from
one end only which is named as top of the stack.
For example, consider a stack of books in which a book can be inserted on top of the
stack and the book which is on top only can be removed.

A stack is a recursive data structure. The structural definition of a stack is that, a stack
is either empty or may contain some elements in top.

Queues
A queue is an abstract data type in which the elements can be inserted to the rear
terminal position, known as enqueue, and the removal of the elements from the front
terminal position, known as dequeue. Hence this queue is a First-In-First-Out (FIFO)
data structure.
In the FIFO data structure, the first element entered into it is the first element that
should be removed. It means that if a new element is inserted and that element should
be dequeued only after removing of the elements that are inserted before the new
element.
For example, the line of people for the ticket in railway reservation counter. The new
people will be added back to the line and the removing will be done from the front.
The difference between stacks and the queues is that only in removing of the
elements. In stack the element that is added recently will be deleted first, where as in
queue, the element that is added first will be removed first.

You might also like