Data Structures Using C (original) (raw)
What is one primary advantage of using a linked list over an array?
- Linked list allows faster element access using indices
- Linked list uses less memory for each element
- Linked list supports dynamic memory allocation efficiently
- Linked list elements are stored in contiguous memory
Why is linked list preferred over array for implementing a stack when the size is not known in advance?
- Arrays allow O(1) push operation
- Linked lists avoid stack overflow due to fixed size
- Linked lists store data in contiguous memory
- Arrays do not support push and pop
Which statement is true about adjacency list representation of a graph?
- It uses a 2D matrix to represent edges
- It is suitable only for dense graphs
- It is space efficient for sparse graphs
- It cannot represent directed graphs
A queue is implemented using the following structure:
C `
struct QNode { int data; struct QNode* next; }; struct Queue { struct QNode *front, *rear; };
`
Which operation should be performed after a dequeue() that removes the last element?
What does the following function compute?
C `
int count(struct Node* root) { if (root == NULL) return 0; return 1 + count(root->left) + count(root->right); }
`
There are 5 questions to complete.
Take a part in the ongoing discussion