VIVA
VIVA
Data Structure
1. What is a data structure?
2. What are the different types of data structures?
3. What is the difference between a linear and non-linear data
structure?
4. What is an abstract data type?
5. What is an array, and what are its advantages and
disadvantages?
6. What is a linked list, and how is it different from an array?
7. What is a stack, and what are some common operations
performed on a stack?
8. What is a queue, and what are some common operations
performed on a queue?
9. What is a tree, and what are its different types?
10. What is a graph, and what are its different types?
11. What is a hash table, and how is it used?
12. What is recursion, and how is it used in data structures?
13. What is the time complexity of searching for an element in an
array? What about a binary search tree?
14. What is the difference between a min heap and a max heap?
15. What is the difference between breadth-first search and
depth-first search?
16. What is dynamic programming, and how is it used in data
structures?
17. What is a priority queue, and how is it implemented?
18. What is an AVL tree, and what is its advantage over a regular
binary search tree?
19. What is a red-black tree, and how is it balanced?
20. What is a trie, and how is it used for string matching?
ANSWERS –
1. A data structure is a way of organizing data in a computer so that it can be used effectively.
2. There are several types of data structures, including arrays, linked lists, stacks, queues, trees,
graphs, and hash tables.
3. A linear data structure stores data in a sequential order, whereas a non-linear data structure
does not.
4. An abstract data type is a data type that is defined by its behavior (i.e., what operations it can
perform) rather than its implementation.
5. An array is a data structure that stores a fixed-size sequential collection of elements of the
same type. Its advantages include fast access to elements and efficient use of memory, while its
disadvantages include the need for a fixed size and slow insertions/deletions.
6. A linked list is a data structure that consists of a sequence of nodes, where each node
contains data and a reference (i.e., a link) to the next node. Unlike arrays, linked lists can grow
or shrink during execution. However, accessing elements can be slower than arrays.
7. A stack is a data structure that stores elements in a last-in-first-out (LIFO) order. Common
operations performed on a stack include push (adding an element to the top), pop (removing
the top element), and peek (retrieving the top element without removing it).
8. A queue is a data structure that stores elements in a first-in-first-out (FIFO) order. Common
operations performed on a queue include enqueue (adding an element to the back), dequeue
(removing the front element), and peek (retrieving the front element without removing it).
9. A tree is a hierarchical data structure consisting of nodes (represented as circles) connected
by edges (represented as lines). There are several types of trees, including binary trees, AVL
trees, and red-black trees.
10. A graph is a non-linear data structure consisting of nodes (vertices) and edges that connect
them. There are several types of graphs, including directed graphs, undirected graphs, and
weighted graphs.
11. A hash table is a data structure that maps keys to values using a hash function. It is
commonly used for fast lookups and insertions.
12. Recursion is a technique in which a function calls itself to solve a problem. It is commonly
used in data structures for tasks such as traversing trees and graphs.
13. The time complexity of searching for an element in an array is O(n), where n is the size of
the array. The time complexity of searching for an element in a binary search tree is O(log n),
where n is the number of nodes in the tree.
14. A min heap is a binary tree in which the parent node is smaller than its children nodes. A
max heap is a binary tree in which the parent node is larger than its children nodes.
15. Breadth-first search (BFS) is a graph traversal algorithm that visits all the vertices of a graph
in breadth-first order. Depth-first search (DFS) is a graph traversal algorithm that visits all the
vertices of a graph in depth-first order.
16. Dynamic programming is a technique for solving problems by breaking them down into
smaller subproblems and solving each subproblem only once. It is commonly used in data
structures for tasks such as finding the shortest path in a graph.
17. A priority queue is a data structure that stores elements in a way that allows them to be
retrieved in order of priority. It is commonly implemented using a binary heap.
18. An AVL tree is a self-balancing binary search tree in which the heights of the two child
subtrees of any node differ by at most one. This ensures that the tree remains balanced and