You are on page 1of 5

Q1.

If an array is declared an int a[5]={3,0,1,2}, then values assigned to a[0] and


a[4] will be
(A) 3,2
(B) 0,2
(C) 3,0
(D) 0,4
Q2. Consider the following declaration of a ‘two-dimensional array in C:
char a[100][100];
Assuming that the main memory is byte-addressable and that the array is stored
starting from memory address 0, the address of a[40][50] is:
(A) 4040
(B) 4050
(C) 5040
(D) 5050
Q3. How do you initialize an array in C?
(a) int arr[3] = (1,2,3);
(b) int arr(3) = {1,2,3};
(c) int arr[3] = {1,2,3};
(d) int arr(3) = (1,2,3);
Q4. What are the advantages of arrays?
(a) Objects of mixed data types can be stored
(b) Elements in an array cannot be sorted
(c) Index of first element of an array is 1
(d) Easier to store elements of same data type
Q5. Assuming int is of 4bytes, what is the size of int arr[15];?
(a) 15 (b) 19
(c) 11 (d) 60
Q6. In general, the index of the first element in an array is ____
(a) 0 (b) -1
(c) 2 (d) 1
Q7. Elements in an array are accessed _____________
(a) randomly
(b) sequentially
(c) exponentially
(d) logarithmically
Q8. The time required to search an element in a linked list of length n is ____
(a) O (log n)
(b) O (n)
(c) O (1)
(d) O (n2)
Q9. Consider a singly linked list of the form where F is a pointer to the first element
in the linked list and L is the pointer to the last element in the list. The time of which
of the following operations depends on the length of the list?
(a) Delete the last element of the list
(b) Delete the first element of the list
(c) Add an element after the last element of the list
(d) Interchange the first two elements of the list
Q10. What is the worst-case time complexity of inserting n elements one by one
into an empty linked list, if the linked list needs to be maintained in sorted order?
(a) Θ(n)
(b) Θ(n log n)
(c) Θ(n2)
(d) Θ(1)
Q11. What does the following function do for a given Linked List with first node
as head?
void fun1(struct node* head)
{
if(head == NULL)
return;

fun1(head->next);
printf("%d ", head->data);
}
(a) Prints all nodes of linked lists
(b) Prints all nodes of linked list in reverse order
(c) Prints alternate nodes of Linked List
(d) Prints alternate nodes in reverse order
Q12. Which of the following points is/are true about Linked List data structure when
it is compared with array
(a) It is easy to insert and delete elements in Linked List
(b) Random access is not allowed in a typical implementation of Linked Lists
(c) The size of array has to be pre-decided, linked lists can change their size any
time.
(d) All of the above
Q13. Which of the following sorting algorithms can be used to sort a random linked
list with minimum time complexity?
(a) Insertion Sort
(b) Quick Sort
(c) Heap Sort
(d) Merge Sort
Q14. What is the output of following function for start pointing to first node of
following linked list? 1->2->3->4->5->6
void fun(struct node* start)
{
if(start == NULL)
return;
printf("%d ", start->data);
if(start->next != NULL )
fun(start->next->next);
printf("%d ", start->data);
}
(a) 1 4 6 6 4 1
(b) 1 3 5 1 3 5
(c) 1 2 3 5
(d) 1 3 5 5 3 1

Solutions:
1. C
2. B
3. C
4. D
5. D
6. A
7. A
8. B
9. A
10. C
11. B
12. D
13. D
14. D

You might also like