0% found this document useful (0 votes)
25 views8 pages

DSA Viva Questions

The document provides a comprehensive set of questions and answers related to data structures and algorithms, covering fundamental concepts such as data structures, linked lists, stacks, queues, trees, graphs, and various sorting algorithms. It also discusses specific algorithms like Huffman's algorithm, Fibonacci search, and methods for implementing different data structures. Additionally, it includes definitions and differences between various data structures, their properties, and applications.

Uploaded by

sybar443
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views8 pages

DSA Viva Questions

The document provides a comprehensive set of questions and answers related to data structures and algorithms, covering fundamental concepts such as data structures, linked lists, stacks, queues, trees, graphs, and various sorting algorithms. It also discusses specific algorithms like Huffman's algorithm, Fibonacci search, and methods for implementing different data structures. Additionally, it includes definitions and differences between various data structures, their properties, and applications.

Uploaded by

sybar443
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

DSA – VIVA Questions:

Q1) What is data structure?

Ans) A data structure is a storage that is used to store and organize data. It is a way of arranging data on
a computer so that it can be accessed and updated efficiently.

Q2) What are the classification of Data Structure?

Ans)(i) Linear data structure: Static data structure, Dynamic data structure

(ii) Non-linear data structure

Q3) What does Abstract data type mean?

Ans) Data type is a collection of values and a set of operations on these values. Abstract data type refer
to the mathematical concept that defines the data type. It is a useful tool for specifying the logical
properties of a data type.

Q4) What are the various operations that can be performed on different Data Structures?

Ane) Insertion, Deletion, Traversal, Searching and Sorting.

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

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

Q7) Differentiate Array and Linked List?

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. 2. Memory is allocated dynamically.
3. Memory wastage will be there if all the array 3. Memory is not wasted as only Required memory
positions are not utilized. is allocated.

Q8) What is a Stack?

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.

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

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

Q12) What is a Queue?

Ans) It is an ordered collection of items into which items can be inserted from one end called as REAR
end and items are deleted from other end called as FRONT end of the Queue. It is also called as FIRST IN
FIRST OUT.

Q13) What is Huffman’s algorithm?

Ans) Huffman’s algorithm is used for creating extended binary trees that have minimum weighted path
lengths from the given weights. It makes use of a table that contains the frequency of occurrence for each
data element.

Q14) What is Fibonacci search?

Ans) Fibonacci search is a search algorithm that applies to a sorted array. It makes use of a divide-and-
conquer approach that can significantly reduce the time needed in order to reach the target element.

Q15) What is an AVL Search Tree? What is AVL Balance Condition?


Ans) An AVL Search Tree is a balanced binary search tree. An empty binary tree is AVL balanced. A non –
empty binary tree, T={r,TL,TR} is AVL balanced if both TL & TR are AVL balanced and | hL – hR | <=1,

Where : hL is the Height of the left subtree and hR is the Height of the right subtree.

Q16) What is a Full Binary Tree?

Ans) If a binary tree of height ‘h’ has exactly [2h+1 -1] nodes then that binary tree is called as Full Binary
Tree.

Q17) What is Binary Tree?

Ans) A binary tree is a 2-ary tree in which each node(N) has atmost 2 children (either 0 or 1). The node
with 2 children are called internal nodes, and the nodes with 0 children are called external nodes or leaf
nodes.

Q18) What is Complete Binary Tree?

Ans) A Binary tree is complete binary tree if all levels are completely filled except possibly the last/lowest
level are full and in the last/lowest level all the items are on the left.
Q19) What is a Binary Search Tree?

Ans) A BST(Binary Search Tree) is a binary tree in which each node satisfies search property. Each node's
key value must be greater than all values in its left subtree and must be less than all values in its right
subtree.

Q20) What is tree traversal?

Ans) Traversal is used to visit each node in the tree exactly once. A full traversal of a binary tree gives a
linear ordering of the data in the tree. There are 3 different type of tree traversal: (i) Inorder Traversal
(ii) Preorder Traversal (iii) Postorder Traversal

Q21) How does Inorder Traversal work?

1) Traverse the left sub tree of the root node R in inorder.


2) Visit the root node R.
3) Traverse the right sub tree of the root node R in inorder.

Q22) How does Preorder Traversal work?

1) Traverse the left sub tree of the root node R in preorder.


2) Traverse the right sub tree of the root node R in preorder.
3) Visit the root node R.

Q23) How does Postorder Traversal work?

1. Visit the root node R.


2. Traverse the left sub tree of the root node R in postorder.
3. Traverse the right sub tree of the root node R in postorder.

Q24) What is a AVL Tree?

Ans) AVL tree is a self-balancing binary search tree with height-balanced condition. For every node the
height of left subtree and right subtree can be differ by at most 1.

Q25) What is a B+ Tree?

Ans) A B+ Tree is a tree data structure which represents sorted data in a way that allows for efficient
insertion, retrieval and removal of records, each of which is identified by a key. It is a dynamic multilevel
index, with maximum and minimum bounds on the number of keys in each segment (usually called a
'block' or 'node')

Q26) What is a Binary Heap Tree?

Ans) A Binary Heap tree is a balanced binary tree where root node are compared with its children and
placed accordingly. Heap have two properties namely, structure and order property.
Q27) What is Structure Property?

Ans) It is a complete binary tree where all the levels except possibly the last/lower level are full and in the
last/lower level all the items are on the left. Due to this fact that binary heap is a complete binary it can
be implemented using a simple array.

Q28) What is Order Property?

Ans) The heap order property for MinHeap is 'a parent is less than (or equal to) its children' whereas for
MaxHeap 'a parent is greater than its children'.

Q29) What is a bubble sort?

Ans) Bubble sort is a simple sorting algorithm, it works by repeatedly stepping through the list to be sorted
comparing each pair of adjacent items and swapping if they are in the worng order.

Q30) What is Insertion Sort?

Ans) Insertion sort is a simple comparison sorting algorithm, every iteration of insertion sort removes an
element from the input data and insert it into the correct position in the already sorted list until no input
element remains.

Q31) What is Selection Sort?

Ans) Insertion sort is a simple comparison sorting algorithm, the algorithm works as follows:

1. Find the minimum value in the list.


2. Swap it with the minimum value in the first position.
3. Repeat the steps above for the remainder of the list (starting at the second position and advancing
each time).

Q32) What is Merge Sort?

Ans) Merge sort is an O(nlogn) comparison-based divide and conquer sorting algorithm, it works as
follows:

1. If the list is of length 0 or 1, then it is already sorted.


2. Divide the unsorted list into two sub lists of about half the size.
3. Sort each sublist recursively by re-applying merge sort algorithm.
4. Merge the two sublists back into one sorted list.

Q33) What is Heap Sort?

Ans) Heap Sort is a comparison-based sorting algorithm which is much more efficient version of selection
sort, it works by determining the largest (or smallest) element of the list, placing that at the end (or
beginning)of the list, then continuing with the rest of the list, but accomplishes this task efficiently by
using a data structure called a heap. Once the data list has been made into a heap, the root node is
gurantedd to be the largest (or smallest) element.
Q34) What is Quick Sort?

Ans) Quick sort sorts by employing a divide and conquer strategy to divide a list into two sub-lists. The
steps are:

Pick an element, called a pivot, from the list.

Reorder the list so the elements which are less than the pivot come before the pivot and the elements
greater than pivot come after it. After this partitioning the pivot is in its final positon.

Recursively sort the sub-list of lesser elements and the sub-list of greater elements.

Q35) What is a Graph?

Ans) A graph is a pair of sets (V,E), where V is the sets of vertices and E is the set of edges connecting the
pair of vertices.

Q36) What is a Directed and Undirected Graph?

 A graph is directed if each edge of graph has a direction between vertices.


 A graph is undirected if there are no direction between vertices.

Q37) What is a Connected Graph?

Ans) A undirected graph is connected if there is a path from every vertex to every other vertex. A directed
graph with this property is called strongly connected.

Q38) What is a Complete Graph?


Ans) A complete graph is a graph in which every vertex is connected to every other vertex. That means
each vertex's degree in undirected graph is n-1.

Q39) What is a Acyclic Graph?

Ans) An acyclic graph is a graph which does not have cycles.

Q40) How are graph represented?

Ans) A graph can be represented in two forms 'Adjacency matrix' and 'Adjacency list'.

 Adjacency matrix is a two dimensional arrays where for each edge, (u,v) A[u,v] = true otherwise it
will be false. The space complexity to represent a graph using this is O(|V|2).
 Adjacency list are used where each list stores adjacent vertices of the corresponding vertex. The
space complexity to represent a graph using this is O(|V|+|E|).

Q41) What is a Spanning Tree?

Ans) A Spanning tree is a graph which must include every vertex and if the graph contain n vertices,
spanning tree must contain exactly (n-1) edges and is a subgraph of G.

Q42) What is a Minimum Spanning Tree?

Ans) A Minimum Spanning tree is a spanning tree such that the summ of all the weights of edges in
spanning tree is minimum.
Q43) Explain algorithm for finding Minimum Spanning Tree?

Ans) There are 2 widely used algorithm for finding minimum spanning tree:

Prims Algorithm computes the minimum spanning tree by including appropriate vertex and thus one edge
into existing partially constructed tree in successive stages. The time complexity of the Prim’s Algorithm
is O((V+E)logV).

Kruskal Algorithm computes the minimum spanning tree by adding edges one by one into a growing
spanning tree.

Q44) Differentiate between stack and queue data structure.

Ans)

Stack Queue
Stack is a linear data structure where data is added Queue is a linear data structure where data is
and removed from the top. ended at the rear end and removed from the
front.
Stack is based on LIFO(Last In First Out) principle Queue is based on FIFO(First In First Out) principle
Insertion operation in Stack is known as push. Insertion operation in Queue is known as eneque.
Delete operation in Stack is known as pop. Delete operation in Queue is known as dequeue.
Only one pointer is available for both addition and Two pointers are available for addition and
deletion: top() deletion: front() and rear()
Used in solving recursion problems Used in solving sequential processing problems

Q45) What is the difference between the Breadth First Search (BFS) and Depth First Search (DFS)?

Ans)

Breadth First Search (BFS) Depth First Search (DFS)


It stands for “Breadth First Search” It stands for “Depth First Search”
BFS (Breadth First Search) finds the shortest path DFS (Depth First Search) finds the shortest path
using the Queue data structure. using the Stack data structure.
We walk through all nodes on the same level DFS begins at the root node and proceeds as far as
before passing to the next level in BFS. possible through the nodes until we reach the
node with no unvisited nearby nodes.
When compared to DFS, BFS is slower. When compared to BFS, DFS is faster.
BFS performs better when the target is close to the DFS performs better when the target is far from
source. the source.
BFS necessitates more memory. DFS necessitates less memory.
Nodes that have been traversed multiple times When there are no more nodes to visit, the visited
are removed from the queue. nodes are added to the stack and then removed.
Backtracking is not an option in BFS. The DFS algorithm is a recursive algorithm that
employs the concept of backtracking.
It is based on the FIFO principle (First In First Out). It is based on the LIFO principle (Last In First Out).
Q46) Define Red-Black Tree and its applications

Ans) Red Black Trees are a type of self-balancing binary search tree. Rudolf Bayer invented it in 1972 and
dubbed it "symmetric binary B-trees". A red-black tree is a Binary tree in which each node has a colour
attribute, either red or black.

Q47) What is a heap data structure?

Ans) Heap is a special tree-based non-linear data structure in which the tree is a complete binary tree.
Heaps are of two types: (i) Max-Heap (ii) Min-Heap

Q48) What is Max-Heap?

Ans) In a Max-Heap the data element present at the root node must be the greatest among all the data
elements present in the tree.

Q49) What is Min-Heap?

Ans) In a Min-Heap the data element present at the root node must be the smallest (or minimum) among
all the data elements present in the tree.

Q50) Explain the difference between file structure and storage structure?
Ans) File Structure: Representation of data into secondary or auxiliary memory say any device such as a
hard disk or pen drives that stores data which remains intact until manually deleted is known as a file
structure representation.

Storage Structure: In this type, data is stored in the main memory i.e RAM, and is deleted once the
function that uses this data gets completely executed.

The difference is that the storage structure has data stored in the memory of the computer system,
whereas the file structure has the data stored in the auxiliary memory.

Q51) Explain your program?

Q52) What struct in C program?

Q53) What is a pointer?

Q54) what is Malloc() function?

Q55) What is Hashing?

Q56) What is Collision?

Q57) Listout the Collision Resolutions.

Q58) What is Binary Search?

Q59) What is Linear Search?

Q60) What is Time complexity?

Q61) What is Space Complexity?


Q62) What is Asymptotic Notations?

Q63) Difference between Linear and Non-Linear Data structures give examples

Q64) What is Sparse matrix?

Q65) What is Recursion?

Q66) What is Recursive function?

Q67) which type of problems we can solved using recursive techniques.

Q68) How to Implement Stack using Array and Linked List?

Q69) How to Implement Queue using Array and Linked List?

Q70) How to Implement Binary Tree using Array and Linked List?

Q71) How to Implement Graph using Linked List?

Q72) How to Implement Circular Queue using Array and Linked List?

Q73) How to Implement circular linked list?

Q74) How to Implement double Linked List?

Q75) Difference between Circular and Linear Queue?

Q76) List out operations of Stack., PUSH, POP, PEEK

Q77) List out operations of Queue ,- Enqueue,Dequeue,QueueFront, QueueRear

Q78) List out the operations of Singly and doubly linked list.

Q79) What is Hash function?

Q80) List the difference of singly and double linked list.

You might also like