BCA-2Sem Data Structure
BCA-2Sem Data Structure
4. Pushing an element into stack already having five elements and stack size of 5, then
stack becomes ___________
a) Overflow
b) Crash
c) Underflow
d) User flow
Answer a
Ans d
6. A linear list of elements in which deletion can be done from one end (front) and
insertion can take place only at the other end (rear) is known as _____________
a) Queue
b) Stack
c) Tree
d) Linked list
Answer a
7. The data structure required for Breadth First Traversal on a graph is?
a) Stack
b) Array
c) Queue
d) Tree
View c
10. If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a
time, in what order will they be removed?
a) ABCD
b) DCBA
c) DCAB
d) ABDC
Ans a
11. A linear collection of data elements where the linear node is given by means of
pointer is called?
a) Linked list
b) Node list
c) Primitive list
d) Unordered list
Answer a
12. Consider an implementation of unsorted singly linked list. Suppose it has its
representation with a head pointer only. Given the representation, which of the following
operation can be implemented in O(1) time?
a) I and II
b) I and III
c) I, II and III
d) I, II and IV
Answer b
13. In linked list each node contains a minimum of two fields. One field is data field to
store the data second field is?
a) Pointer to character
b) Pointer to integer
c) Pointer to node
d) Node
Ans c
14. What would be the asymptotic time complexity to add a node at the end of singly
linked list, if the pointer is initially pointing to the head of the list?
a) O(1)
b) O(n)
c) θ(n)
d) θ(1)
Answer c
15. What would be the asymptotic time complexity to insert an element at the front of the
linked list (head is known)?
a) O(1)
b) O(n)
c) O(n2)
d) O(n3)
Answer c
17. What is/are the disadvantages of implementing tree using normal arrays?
a) difficulty in knowing children nodes of a node
b) difficult in finding the parent of a node
c) have to know the maximum number of nodes possible before creation of trees
d) difficult to implement
Answer d
18. What must be the ideal size of array if the height of tree is ‘l’?
a) 2l-1
b) l-1
c) l
d) 2l
Answer c
19. What are the children for node ‘w’ of a complete-binary tree in an array
representation?
a) 2w and 2w+1
b) 2+w and 2-w
c) w+1/2 and w/2
d) w-1/2 and w+1/2
Answer d
20. What is the parent for a node ‘w’ of a complete binary tree in an array representation
when w is not 0?
a) floor(w-1/2)
b) ceil(w-1/2)
c) w-1/2
d) w/2
Answer c
Research Enquiry
1.A program P reads in 500 integers in the range [0..100] exepresenting the scores of 500
students. It then prints the frequency of each score above 50. What would be the best way for
P to store the frequencies?
A. An array of 50 numbers
B. An array of 100 numbers
C. An array of 500 numbers
D. A dynamically allocated array of 550 numbers
Ans D.
2. Consider an array A[20, 10], assume 4 words per memory cell and the base address of
array A is 100. What is the address of A[11, 5] ? Assume row major storage.
A. 560
B. 565
C. 570
D. 575
Ans A
3. Which of the following is an illegal array definition?
a. Garbage value
b. 10
c. 50
d. None of the above
Ans a
A. Two
B. eight
C. sixteen
D. Theoratically no limit. The only practical limits are memory size and compilers
Ans d
a. 12
b. 11
c. 5
d. 4
Ans c
7. If the elements '1', '2', '3' and '4' are inserted in a queue, what would be order for the
removal?
a. 1234
b. 4321
c. 3241
d. None of the above
Ans a
8. Which one of the following is the overflow condition if linear queue is implemented using
an array with a size MAX_SIZE?
a. rear = front
b. rear = front+1
c. rear=MAX_SIZE -1
d. rear = MAX_SIZE
Ans b
a. O(1)
b. O(n)
c. O(logn)
d. O(nlogn)
Ans a
10. Which one of the following is the correct way to increment the rear end in a circular
queue?
a. rear =rear+1
b. (rear+1) % max
c. (rear % max) + 1
d. None of the above
Ans b
a) I and II
b) I and III
c) I,II and III
d) I,II and IV
Ans b
struct node
{
int data;
struct node * next;
}
typedef struct node NODE;
NODE *ptr;
a) ptr=(NODE*)malloc(sizeof(NODE));
b) ptr=(NODE*)malloc(NODE);
c) ptr=(NODE*)malloc(sizeof(NODE*));
d) ptr=(NODE)malloc(sizeof(NODE));
Ans a
14. In worst case, the number of comparison need to search a singly linked list of length n for
a given element is
a) log n
b) n/2
c) log2n-1
d) n
Ans d
A. FAEKCDBHG
B. FAEKCDHGB
C. EAFKHDCBG
D. FEAKDCHBG
Ans b
16. In linked representation of Binary trees LEFT[k] contains the ........ of at the node N,
where k is the location.
A. Data
D. Null value
Ans a
Ans c
18.What is the average case time complexity for finding the height of the binary
tree?
a) h = O(loglogn)
b) h = O(nlogn)
c) h = O(n)
d) h = O(log n)
Ans d
19.In a full binary tree if number of internal nodes is I, then number of nodes N
are?
a) N = 2*I
b) N = I + 1
c) N = I – 1
d) N = 2*I + 1
Ans d
20. Suppose we have a O(n) time algorithm that finds median of an unsorted array. Now
consider a QuickSort implementation where we first find median using the above algorithm,
then use median as pivot. What will be the worst case time complexity of this modified
QuickSort.
A. O(n^2 Logn)
B. O(n^2)
C. O(n Logn Logn)
D. O(nLogn)
Ans d
Information & Digital LiteIracy
Ans b
b. Caching
c. Spatial locality
d. Scheduling of Processes
Ans b
4. Which of the following operations is not O(1) for an array of sorted data. You may assume
that array elements are distinct.
Ans d
Ans c
a. A+B*C
b. +A*BC
c. ABC+*
d. None of the above
Ans a
8. A list of elements in which enqueue operation takes place from one end, and dequeue
operation takes place from one end is__
a. Binary tree
b. Stack
c. Queue
d. Linked list
Ans c
a. LIFO principle
b. FIFO principle
c. Linear tree
d. Ordered array
Ans b
10. Which one of the following is not the type of the Queue?
a. Linear Queue
b. Circular Queue
c. Double ended Queue
d. Single ended Queue
Ans d
11. Which of the following that determines the need for the Circular Queue?
Ans a
Global Citizen
Ans a
2. In linked list each node contain minimum of two fields. One field is data field to
store the data second field is?
a) Pointer to character
b) Pointer to integer
c) Pointer to node
d) Node
Ans c
3.What would be the asymptotic time complexity to add a node at the end of singly linked
list, if the pointer is initially pointing to the head of the list?
a) O(1)
b) O(n)
c) θ (n)
d) θ (1)
Ans c
Ans c
a) One pointer
b) Two pointer
c) Three pointer
d) None
Ans b
6.The post order traversal of a binary tree is DEBFCA. Find out the pre order Traversal.
A. ABFCDE
B. ADBFEC
C. ABDECF
D. ABDCEF
Ans c
A. endpoints of e
B. adjacent nodes
C. neighbours
A. a tree graph
B. free tree
C. a tree
D. All of above
Ans d
A. isolated
B. complete
C. finite
D. strongly connected
Ans b
10. Three standards ways of traversing a binary tree T with root R .......
5.In a stack, if a user tries to remove an element from empty stack it is called _________
a) Underflow - Answer
b) Empty collection
c) Overflow
d) Garbage Collection
7. A linear list of elements in which deletion can be done from one end (front) and
insertion can take place only at the other end (rear) is known as a ?
a) Queue - Answer
b) Stack
c) Tree
d) Linked list
8.
A normal queue, if implemented using an array of size MAX_SIZE, gets full when
a) Rear = MAX_SIZE – 1 Answer
b) Front = (rear + 1)mod MAX_SIZE
c) Front = rear + 1
d) Rear = front
10. In linked list each node contain minimum of two fields. One field is data field to store
the data second field is?
a) Pointer to character
b) Pointer to integer
c) Pointer to node Answer
d) Node
12. The type of expression in which operator succeeds its operands is?
a) Infix Expression
b) Prefix Expression
c) Postfix Expression Answer
a) B and E
b) C and D
c) A and E
d) C and B Answer
17. For the given graph(G), which of the following statements is true?
a) -G is a complete graph
b) G is not a connected graph
c) The vertex connectivity of the graph is 2
d) The edge connectivity of the graph is 1 Answer
19. 2) If the number of records to be sorted is small, then …… sorting can be efficient.
A. Merge
B. Heap
C. Selection Answer
D. Bubble
D. O(n logn)
Ans b
Ans c
6. When does the ArrayIndexOutOfBoundsException occur?
a) Compile-time
b) Run-time
c) Not an error
d) Not an exception at all
Ans b
7. 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
Ans d
8. Assuming int is of 4bytes, what is the size of int arr[15];?
a) 15
b) 19
c) 11
d) 60
Ans d
Ans a
10. Elements in an array are accessed _____________
a) randomly
b) sequentially
c) exponentially
d) logarithmically
Ans b
b. Caching
c. Spatial locality
d. Scheduling of Processes
Ans b
9. Which of the following operations is not O(1) for an array of sorted data. You may assume
that array elements are distinct.
Ans d
1. The post order traversal of binary tree is DEBFCA. Find out the pre order traversal.
A. ABFCDE
B. ADBFEC
C. ABDECF
D. ABDCEF
Ans c
2. While converting binary tree into extended binary tree, all the original nodes in binary tree
are .......
4. A binary tree whose every node has either zero or two children is called .........
D. E2 tree
Ans c
5. If every node u in G is adjacent to every other node v in G,A graph is said to be ........
A. isolated
B. complete
C. finite
D. strongly connected.
Ans b
6. The post order traversal of a binary tree is DEBFCA. Find out the pre order Traversal.
A. ABFCDE
B. ADBFEC
C. ABDECF
D. ABDCEF
Ans c
B. adjacent nodes
C. neighbours
A. a tree graph
B. free tree
C. a tree
D. All of above
Ans d
A. isolated
B. complete
C. finite
D. strongly connected
Ans b
10. Three standards ways of traversing a binary tree T with root R .......
A. Absolute
B. Entire
C. Inclusive
D. Complete
Ans d
A. Insertion sort
B. Selection sort
C. Bubble sort
D. Merge sort
Ans b
2. If the number of records to be sorted is small, then …… sorting can be efficient.
A. Merge
B. Heap
C. Selection
D. Bubble
Ans c
3. What is the advantage of bubble sort over other sorting techniques?
A. It is faster
B. Consumes less memory
C. Detects whether the input is already sorted
D. All of the mentioned
Ans c
4. Consider the situation in which assignment operation is very costly. Which of the
following sorting algorithm should be performed so that the number of assignment operations
is minimized in general?
A. Insertion sort
B. Selection sort
C. Heap sort
D. None
Ans b
5.The worst-case occur in linear search algorithm when …….
A. Item is somewhere in the middle of the array
Ans a
C. Selection
D. Distribution
Ans a
11. Which of the following sorting algorithm is of divide and conquer type?
A. Bubble sort
B. Insertion sort
C. Merge sort
D. Selection sort
Ans c
12. Suppose we have a O(n) time algorithm that finds median of an unsorted array. Now
consider a QuickSort implementation where we first find median using the above algorithm,
then use median as pivot. What will be the worst case time complexity of this modified
QuickSort.
A. O(n^2 Logn)
B. O(n^2)
C. O(n Logn Logn)
D. O(nLogn)
Ans d
1. The given array is arr = {1,2,4,3}. Bubble sort is used to sort the array elements. How
many iterations will be done to sort the array?
A. 4
B. 2
C. 1
D. 0
Ans a
2.The total number of comparisons in a bubble sort is ....
A. O(n logn)
B. O(2n)
C. O(n2)
D. O(n)
Ans a
3 .f the number of record to be sorted large and the key is long, then ...... sorting
can be efficient.
A. Merge
B. Heap
C. Quick
D. Bubble
Ans c
4.The given array is arr = {1,2,4,3}. Bubble sort is used to sort the array elements.
How many iterations will be done to sort the array with improvised version?
a) 4
b) 2
c) 1
d) 0
Ans b
5.Suppose we are sorting an array of eight integers using quicksort, and we have just finished
the first partitioning with the array looking like this:
2 5 1 7 9 12 11 10
Which statement is correct?
A. ABFCDE
B. ADBFEC
C. ABDECF
D. ABDCEF
Ans c
9. While converting binary tree into extended binary tree, all the original nodes in binary tree
are .......