1. Define Data Structures.
A data structure is a way of organizing and storing data so that it can be accessed and modified efficiently.
Common data structures include arrays, linked lists, stacks, queues, trees, and graphs.
2. What is abstract data type?
An Abstract Data Type (ADT) is a data type where only behavior (operations) is defined but not
implementation. Examples include Stack, Queue, List, etc. The implementation is hidden from the user.
3. What is Time and space complexity?
Time Complexity refers to the amount of time an algorithm takes to run as a function of the size of its input.
Space Complexity refers to the amount of memory space an algorithm uses as a function of the size of the
input.
Example: For linear search, time complexity is O(n).
4. Mention the applications of Sparse Matrices.
Sparse matrices are used when most of the elements in a matrix are zero. Applications include:
- Storing large graphs
- Image compression
- Network data storage
- Solving partial differential equations
5. Write any two built in functions of strings with syntax and example.
a) len() - returns length of string
Example:
s = "Hello"
print(len(s)) # Output: 5
b) upper() - converts string to uppercase
Example:
s = "hello"
print(s.upper()) # Output: HELLO
6. Mention the operations of linear arrays.
- Traversal - accessing elements one by one
- Insertion - adding an element
- Deletion - removing an element
- Searching - finding an element
- Updating - modifying an element
7. What are the characteristics of linked list?
- Dynamic memory allocation
- Each node contains data and a pointer to the next node
- Efficient insertion and deletion
- No memory wastage
- Linear data structure
8. Define Recursion.
Recursion is a technique where a function calls itself to solve smaller instances of the same problem.
Example:
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
9. Mention different types of queries.
- Select Query - to retrieve data
- Update Query - to modify data
- Insert Query - to add new data
- Delete Query - to remove data
- Join Query - to combine data from multiple tables
10. Distinguish between tree and binary Tree.
Tree:
- Can have any number of children
- General hierarchical structure
Binary Tree:
- At most two children (left and right)
- More specific structure
11. Define graph with an example.
A graph is a collection of nodes (vertices) and edges that connect pairs of nodes.
Example:
Vertices: A, B, C
Edges: (A-B), (B-C), (A-C)
12. What is Hashing?
Hashing is a technique to convert a given key into an index using a hash function. This index determines
where the data should be stored or retrieved from in a hash table.