Exam Questions and Answers
What is a Data Structure? - Answer- A data structure is a way of organizing the data
so that the data can be used efficiently.
What are linear and non linear data Structures? - Answer- 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.
What are the various operations that can be performed on different Data Structures?
- Answer- Insertion, Deletion, Traversal, Searching, Sorting
How is an Array different from a Linked List - Answer- array size is fixed, Linked Lists
size are Dynamic
insertion and deletion is easily done in Linked Lists, but for arrays is expensive
No Random access in Linked List
link lists need Extra memory space for a pointer
Arrays have better cache locality
What is Stack and where it can be used? - Answer- Stack is a linear data structure
which the order LIFO(Last In First Out) for accessing elements.
Basic operations of stack are : Push, Pop , Peek
What is a Queue, how it is different from stack and how is it implemented? - Answer-
Queue is a linear structure which follows the order is First In First Out (FIFO) to
access elements
queue is FIFO while stack is LIFO
implemented using Arrays or Linked Lists
What are Infix, prefix, Postfix notations? - Answer- Infix notation: X + Y Operators are
written in-between their operands.
Postfix notation: X Y + Operators are written after their operands.
Prefix notation: + X Y Operators are written before their operands.