Data Structures Using C

Last Updated :
Discuss
Comments

Question 1

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

Question 2

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

Question 3

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

Question 4

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?

  • front = rear

  • rear = NULL

  • rear = front

  • front = rear = NULL

Question 5

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);
}


  • Height of the tree

  • Number of leaf nodes

  • Total number of nodes

  • Number of internal nodes

There are 5 questions to complete.

Take a part in the ongoing discussion