Ds 2 Marks
Ds 2 Marks
A circular linked list is a type of linked list in which the last node
points back to the first node, forming a circle.
Diagram:
o .
10
/ \
20 30
/ \ \
40 50 60
In this tree, 10 is the root, with two children 20 and 30. Each of those
children can have their own sub-branches.
4.Write the underflow and overflow conditions in stack?
prefix expression:
*+ab-cd
Applications of Queues:
1. Scheduling: Used in operating systems for scheduling tasks or
processes (e.g., CPU scheduling).
2. Buffering: Used in data streaming or network buffering, where
data is stored temporarily before being processed.
Cyclic Graph:
• Has at least one cycle (a loop where you can return to the
starting node).
Acyclic Graph:
• No cycles (no loop, can't return to the starting node).
External Sorting:
• Used when data is too large to fit in memory.
• Data is stored on external storage like a disk.
Internal Sorting:
• Data fits entirely in memory (RAM).
22. Does the minimum spanning tree of a graph give the shortest
distance between any twospecified nodes? Justify the answer.
No, the Minimum Spanning Tree (MST) does not give the shortest
distance between two specific nodes.
Reason:
• The MST connects all nodes with the minimum total weight,
but it doesn't always provide the shortest path between two
nodes.
24. Give the time complexities of linear search and binary search.
Time Complexities:
1. Linear Search:
o Time Complexity: O(n)
o Explanation: It checks each element one by one, so the
time increases with the number of elements.
2. Binary Search:
o Time Complexity: O(log n)
o Explanation: It divides the list in half with each step, so
it’s much faster for large lists (works only on sorted lists).
B+ Tree:
A B+ Tree is a type of tree used to store data in an organized way. In
this tree, data is stored only in the leaf nodes, while the internal
nodes store keys to help find the data quickly.
Example:
[20]
/ \
[10] [30]
/ \ / \
[5] [15] [25] [35]
Directed Graph:
A directed graph is a graph where edges go in a specific direction.
Example:
A→B→C
↑ ↓
D←E
• The arrows show the direction from one node to another.