Govt Exams
Contiguous allocation places array elements next to each other in memory, improving cache hits and CPU performance through spatial locality.
Level-order traversal requires BFS which uses a queue. Dynamic queue allocation handles arbitrary tree sizes efficiently.
Each malloc() call has fixed metadata overhead (typically 8-16 bytes). Single allocation of 1000 ints has less overhead than 1000 separate allocations.
While both work, inserting at beginning provides O(1) insertion; end requires traversal. Choice depends on use case.
Doubly-linked list nodes require both next and previous pointers to enable bidirectional traversal unlike singly-linked lists.
NULL return from malloc indicates allocation failure; ignoring causes dereferencing NULL which leads to crash.
Proper way requires dynamic allocation with malloc, adding 1 for null terminator, and using fgets for safe input.
Using dynamic arrays (vectors in C++) with doubling strategy provides O(1) amortized time for appending edges.
Buffer overflow by accessing beyond allocated boundaries causes segmentation fault as it accesses invalid memory pages.
A circular buffer requires head and tail pointers minimum to track current positions in the circular structure.