1. What is non-primitive data structure? Give an example.
Non-primitive data structures are complex structures built from primitive data types and used to store larger,
more complex data efficiently.
Example: Array, Linked List, Stack, Queue, Tree, Graph.
2. What are asymptotic notations? List out the types of asymptotic notations.
Asymptotic notations describe the running time or space requirement of an algorithm as the input size grows.
Types:
- Big O: Worst case
- Omega: Best case
- Theta: Average or tight bound
3. What are linear arrays? Give an example.
A linear array is a collection of elements stored in contiguous memory locations and accessed by index.
Example (Python):
arr = [10, 20, 30, 40]
print(arr[2]) # Output: 30
4. What are the characteristics of linked list?
- Dynamic size
- Each node stores data and a pointer to the next node
- No memory wastage
- Fast insertion/deletion compared to arrays
- Sequential (no random access)
5. Explain stack as ADT.
Stack is a linear data structure that follows LIFO (Last In First Out).
Operations:
- Push: insert element
- Pop: remove top element
- Peek: view top element
- IsEmpty: check if stack is empty
6. What is the difference between linear queue and circular queue?
Linear Queue:
- Simple queue ending at rear
- Unused front space after deletions
Circular Queue:
- Rear wraps to front forming a circle
- Utilizes entire array space efficiently
7. Define binary tree and binary search tree.
Binary Tree: Each node has at most two children.
Binary Search Tree (BST): A binary tree where left child < parent < right child.
8. What is hashing? What are its advantages?
Hashing maps data to a fixed-size value (hash code) with a hash function.
Advantages:
- Fast access, insert, delete
- Efficient indexing in hash tables and databases
9. What is a sparse matrix? Mention the types of sparse matrix.
A sparse matrix is a matrix with most elements equal to zero.
Common representations:
- Triplet/3-tuple list
- Compressed Sparse Row (CSR)
- Compressed Sparse Column (CSC)
10. Give an example for directed graph and undirected graph.
Directed Graph: A -> B (edge has direction)
Undirected Graph: A - B (edge has no direction)