You are on page 1of 6

Viva Questions:

1. What are linear and non linear data Structures?


Linear: A data structure is said to be linear if its elements form a sequence or a linear list.
Examples: Array. Linked List, Stacks and Queues
Non-Linear: A data structure is said to be non-linear if traversal of nodes is nonlinear in nature.
Example: Graph and Trees.

2.What do you mean by an


Array? Array is a set of similar
data type.
Arrays objects store multiple variables with the same
type. It can hold primitive types and object references.
Arrays are always fixed

3. List the advantages of Array


Ans:Advantages:
We can put in place other data structures like stacks, queues, linked lists, trees, graphs, etc. in
Array.
Arrays can sort multiple elements at a time.
We can access an element of Array by using an index.

4. List the disadvantages of Array


Ans:Disadvantages:
We have to declare Size of an array in advance. However, we may not know what size we
need at the time of array declaration.
The array is static structure. It means array size is always fixed, so we cannot increase or
decrease memory allocation.

5. What are 2 dimensional arrays?


Ans: A 2D array has a type such as int[][] or String[][], with two pairs of square brackets. The
elements of a 2D array are arranged in rows and columns, and the new operator for 2D
arrays specifies both the number of rows and the number of columns.
Viva Questions:
1. Define a stack?
Ans: Stack is an ordered collection of elements. Insertion and deletion of stack is done only from
one end, called top of the stack. It is also called LIFO(Last in first out)
2.Define Push
Ans:The push operation adds to the top of the list, hiding any items already on the stack, or
initializing the stack if it is empty.

3. Define Pop
Ans:The pop operation removes an item from the top of the list, and returns this value to the
caller. A pop either reveals previously concealed items, or results in an empty list.
4. Mention any two Applications of Stack
Ans: a)Infix to Postfix Conversion using
Stack
b)Evaluation of Postfix Expression

5. What do you mean by stack underflow?


Ans:An error condition that occurs when an item is called for from the stack, but the stack is
empty. Contrast with stack overflow. See stack.

Viva Questions:
1. What are the notations used in Evaluation of Arithmetic Expressions using prefix and
postfix forms?
Ans:Polish and Reverse Polish notations.
2. Which data structure is needed to convert infix notations to post fix
notations? Ans: stack.
3. What is the result of the given postfix expression ABC *+ where A 1 B 2 C
3? Ans:7.
4. What is the result of 456*+
Ans:34.
5. Define operations on Stack ?
Ans: The basic operation that can be performed on Stack are as follows:
a) PUSH
b) POP
6. Give the formula to find the number of movements in Tower of Hanoi
problem? Ans: x=pow(2,n)-1.
7. How many moves does it take to solve the Tower of Hanoi for 5
disks? Ans:31 moves
Viva Questions:

1. Whatis a Linked List?


Ans:A linked list is a linear data structure (like arrays) where each element is a separate object.
Each element (that is node) of a list is comprising of two items – the data and a reference to the
next node.

2. Define Singly Linked List


Ans : In this type of linked list, every node stores address or reference of next node in list and
the last node has next address or reference as NULL.
For example 1->2->3->4->NULL

1. What are the advantages of linked


list? Ans:Advantages are:
1. linked lists are dynamic data
structures 2.Efficient memory utilization
3. Insertion and deletions are easier and efficient

4. How to insert a node at a specific position in a linked


list Ans:a)Traverse the Linked list up to position-1 nodes.
a)Once all the position-1 nodes are traversed, allocate memory and the given data to
the new node.
c) Point the next pointer of the new node to the next of current node.
d) Point the next pointer of current node to the new node.

5.Mention what is traversal in linked lists?


Ans:Term Traversal is used to refer the operation of processing each element in the list.
Viva Questions:

1. Define Doubly Linked List : Here, here are two references associated with each node, One
of the reference points to the next node and one to the previous node.
Eg. NULL<-1<->2<->3->NULL
2. What type of memory allocation is referred for Linked
lists? Dynamic memory allocation is referred for Linked lists.
3. Mention what is the difference between singly and doubly linked
lists? Ans:A doubly linked list nodes contain three fields:
An integer value and Two links to other nodes one to point to the previous node and
other to point to the next node. Whereas a singly linked list contains points only to the next node.
4. Mention what are the applications that use Linked lists?
Ans:Both queues and stacks are often implemented using linked lists. Other applications are list,
binary tree, skip, unrolled linked list, hash table, etc.

Viva Questions:

1. Explain Graph in C
Ans:A graph is a data structure that consists of the following two components:
1. A finite set of vertices also called as nodes.
2. A finite set of ordered pair of the form (u, v) called as edge. The pair is ordered because (u,
v) is not the same as (v, u) in case of a directed graph(di-graph). The pair of the form (u, v)
indicates that there is an edge from vertex u to vertex v. The edges may contain
weight/value/cost.

2. Which are the most commonly used representation of Graph


Ans:The following two are the most commonly used representations of a graph.
1. Adjacency Matrix
2. Adjacency List

3. Differentiate NULL and VOID.


Ans: Null is actually a value, whereas Void is a data type identifier. A variable that is given a
Null value simply indicates an empty value. Void is used to identify pointers as having no
initial size
Viva Questions:

DATA STRUCTURES VIVA QUESTIONS


1Q) What is a Data Structure?
Ans) A Data Structure is a data object together with the relationships that exists among the
instances & among the individual elements that compose an instance.
2Q) Types of Data Structures and give
examples? Ans) There are two types of Data
Structures:
1. Linear Data Structures: A data structure is said to be linear if the elements form
a sequence. It is sequential and continues in nature i.e. access the data in sequential
manner.
In linear data structure we can not insert an item in middle place and it maintains a linear
relationship between its elements
egs: Array, Linked list, Stack, Queue, Dequeue etc.
2. Non Linear Data Structures: A data structure is said to be non-linear if elements do not
form a sequence. (Not sequential).
It does not maintain any linear relationship between their elements. Every data item is attached to
several other data items in a way that is specific for reflecting relationships. The data items are
not arranged in a sequential structure.
egs: Trees, Graphs.
[A data structure is linear if every item is related with next and previous item and it is non
linear if it is attach with many of the items in specific ways to reflect relationship.]
3Q) What is a Singly Linked List?
Ans) Singly Linked List is a Sequence of dynamically allocated Storage elements, each
element of which contains a pointer to its successor. A pointer to the first element of the
list is called as head and a pointer to the last element of the list is called as tail used to
keep track of the list elements.
4Q) What is Doubly Linked List?
Ans) In Doubly Linked List each element contains two pointers: One Pointer points to its
successor and another to its predecessor (previous element).It is also called as two way
linked list (traversing can be done in both directions).
5Q) Differentiate Array and Linked List?
Ans
)
STACKS: (LIFO DATA STRUCTURE)
6Q) What is a Stack? (LIFO Data Structure)
Ans) Stack is an ordered collection of items into which items can be inserted and deleted from
only one end called as “Top” of the Stack. It is also called as LIFO list.(Last In First
Out).
7Q) What is Stack Underflow?
Ans) Is Stack is empty and POP operation is performed it is not possible to delete the items.
This situation is called Stack Underflow.
8Q) What is Stack Overflow?
Ans) If Stack is full and PUSH operation is performed it is not possible to insert or Push the
new items into the stack. This situation is called Stack Overflow.
9Q) What are the Applications of Stack?
Ans) i) Stacks are used to convert Infix expression into Postfix.
ii) Stacks are used to Evaluate Postfix Expression.
iii) Stacks are used in recursion etc.
10Q) What is the use of Postfix expressions?
Ans) Postfix Expressions are easy to evaluate as postfix expressions does not make use of
operator precedence not does it require the use of parenthesis.
Array Linked List
1. Size of the array is fixed 1.Size of the linked list is not fixed
2. Memory is allocated Statically (or)
Dynamically (at run time).
(If the memory is allocated for an array
Statically(at compile time) it is called Static
Array and if memory is allocated at run
time (dynamically)using operator new it is
called Dynamic Array)
2. Memory is allocated dynamically (at
runtime).
3.Memory
wastage will be
there if all the
array positions
are not utilized
3.Memory is not
wasted as only
Required memory
is allocated

You might also like