Data_Structure_Assignment_Answers_7_Pages
Data_Structure_Assignment_Answers_7_Pages
A data structure is a way of organizing and storing data so that it can be accessed and modified
efficiently.
Examples:
2. Arrays are collections of elements stored in contiguous memory locations, while linked lists
consist of nodes that contain data and pointers to the next node.
3. Time complexity is a way to express the amount of time an algorithm takes to run as a function of
5. Space complexity is the amount of memory an algorithm uses as a function of the input size.
Example: A recursive function may use stack space for function calls.
6. A stack is a linear data structure that follows the Last In First Out (LIFO) principle.
8. A circular queue connects the last position back to the first position, allowing efficient utilization of
Collision in hashing occurs when two keys hash to the same index.
11. A circular queue reuses empty spaces left by dequeued elements, reducing memory wastage
12. A binary tree is a data structure in which each node has at most two children.
Complete binary tree: All levels are completely filled except possibly the last.
13. Dynamic memory allocation in linked lists allows allocation of memory at runtime using pointers,
14. Recursive formula for Fibonacci series: F(n) = F(n-1) + F(n-2), F(0)=0, F(1)=1
F(5) = 5
17. Divide and conquer solves problems by dividing into subproblems, solving them independently,
Greedy algorithms make locally optimal choices hoping for global optimum (e.g., Kruskal's
algorithm).
18. Recursion is a method where the solution depends on solutions to smaller instances of the same
problem.
Push(x):
Pop():
20. A priority queue is a special type of queue in which each element is associated with a priority.
Unlike normal queues, elements with higher priority are dequeued before lower priority.