Data Structure Assignment - Arrays & Linked Lists
Section A: Multiple Choice Questions (Any 5)
1. Which of the following data structures stores elements in contiguous memory locations?
(a) Linked List (b) Stack (c) Array (d) Queue
2. What is the time complexity of inserting an element at the beginning of a linked list?
(a) O(n) (b) O(log n) (c) O(1) (d) O(n^2)
3. Which of the following correctly declares a dynamic array in C?
(a) int *arr = malloc(n * sizeof(int));
(b) int arr[n];
(c) int arr = malloc(n);
(d) malloc(int *arr);
4. In a singly linked list, what does the last node contain?
(a) Address of head node (b) NULL (c) Random value (d) Garbage value
5. Which operation is more efficient in linked lists than arrays?
(a) Accessing a random element (b) Inserting at a specific position (c) Binary search (d) Sorting
6. (New) Which of the following is NOT a type of linked list?
(a) Singly linked list (b) Doubly linked list (c) Circular linked list (d) Sequential linked list
7. (New) If an array starts at memory address 1000 and each element is 4 bytes, what will be the address of
arr[5]?
(a) 1020 (b) 1024 (c) 1028 (d) 1040
8. (New) In C, which operator is used to access the members of a structure through a pointer?
(a) . (dot) (b) -> (arrow) (c) & (d) *
Data Structure Assignment - Arrays & Linked Lists
Section B: Short Answer Questions (Any 5)
1. Write a C function to insert a node at the beginning of a singly linked list. (Include structure definition and
pointer logic.)
2. List any five differences between arrays and linked lists.
3. Write an algorithm to reverse an array in-place.
4. (New) Write a C function to count the number of nodes in a linked list.
5. (New) Explain the difference between static array allocation and dynamic array allocation in C with an
example.
Section C: Long Answer Questions (Any 5)
1. Write a complete C program to create a singly linked list and perform the following operations: Insert at
beginning, Insert at end, Traverse the list. Also explain the logic of each function.
2. (New) Write a C program to merge two sorted arrays into a single sorted array. Explain your approach.
3. (New) Write a C program to delete a node from a singly linked list at a given position.
4. (New) Write an algorithm to find the largest and smallest element in an array. Also mention its time
complexity.
5. (New) Compare arrays and linked lists in terms of memory allocation, insertion, deletion, and search
operations with examples.