Introduction to Data Structures
What are Data Structures?
A Data Structure is a way of organizing and storing data so that it can be used efficiently.
Types of Data Structures
1. Linear Data Structures: Arrays, Linked Lists, Stacks, Queues. 2. Non-Linear Data Structures:
Trees, Graphs.
Arrays
An array is a collection of elements stored in contiguous memory locations. Example: int arr[5] =
{1,2,3,4,5};
Stacks & Queues
Stack: Follows LIFO (Last In First Out). Queue: Follows FIFO (First In First Out).
Trees & Graphs
Tree: Hierarchical data structure with a root node. Graph: Collection of nodes connected by edges.
Sample Questions
1. Define Data Structure. 2. Differentiate between linear and non-linear data structures. 3. What is
an array? Give an example. 4. Explain LIFO and FIFO with examples.