Data Structures - MCQs from AMIE exams (Summer 2018)

Answer the following questions (10 x 2)

1. Binary search can be performed if data items are stored in an:
(a) unordered array
(b) ordered array
(c) unordered linked list
(d) ordered linked list

2. Strings can be defined directly by using the data type:
(a) char
(b) string
(c) String
(d) Str

3. The Linked list is preferred over arrays for the following operation:
(a) search
(b) insertion
(c) bubble-sorting
(d) heap-sorting

4. When the input size is not known in advance we prefer linked lists over arrays due to:
(a) Static memory allocation
(b) random memory allocation
(c) heap allocation
(d) dynamic memory allocation

5. What is the postfix representation of the following infix expression?
(A + B) * C – D * E / F
(a) A B + C * D E * F - /
(b) A B * C + D E * F / -
(c) A B + C – D E * F / *
(d) A B + C * D E * F / -

6. If a queue is implemented by a circular array QUEUE The number of elements in the queue if
FRONT - 10 and REAR - 3 will be (number of memory locations are 12):
(a) 3
(b) 4
(c) 5
(d) 6

7. The number of null links in a binary tree with n nodes:
(a) n + 1
(b) 2n
(c) 2n - 1
(d) n - 1

8. Assuming the height of a single node is zero the maximum possible height of a binary tree with n nodes is:
(a) ⌈log(n)⌉
(b) ⌊log(n)⌋
(c) ⌊log(n + 1)⌋ + 1
(d) n - 1

9. The maximum number of edges in a connected simple graph G = (V, E) is:
(a) |V|
(b) |V| - 1
(c) |V|(|V| - 1)/2
(c) |V|²

10. To perform computation on a sparse graph G = (P, E) we would prefer the following data structure:
(a) Adjacency Matrix
(b) Incidence Matrix
(c) Adjacency List
(d) Incidence List.

Answer

1. (b) Binary Search is a searching algorithm used in a sorted array by repeatedly dividing the search interval in half. The idea of binary search is to use the information that the array is sorted and reduce the time complexity to O(log n). 

2. (a) Declaring a string is as simple as declaring a one-dimensional array. Below is the basic syntax for declaring a string.
     char str_name[size];
In the above syntax str_name is any name given to the string variable and size is used to define the length of the string, i.e the number of characters strings will store. 

3. (b) Linked lists are often used because of their efficient insertion and deletion. They can be used to implement stacks, queues, and other abstract data types.

4. (d) A linked list is a dynamic data structure that can grow and shrink in size at runtime by allocating and deallocating memory. As a result, there is no need to specify the linked list's initial size.

5. (d) 

Concept:
() has the highest precedence
* and / has the same precedence while + and – have the same precedence
(* and /) and higher precedence than (+, -)
Associativity is left to right:

Explanation:
(A + B) * C – D * E / F
A B + * C – D * E / F
A B + C * – D * E / F
A B + C * – D E * / F
A B + C * – D E * F /
A B + C * D E * F / –

6. (d)
Case 1: Rear ≥ Front
Number of elements = Rear - Front + 1

Case 2: Front > Rear
Number of elements = N + (Rear - Front) + 1
where N = number of memory locations

7. (a) The number of null links (i.e., absent children of the nodes) in a binary tree of n nodes is (n+1).

8. (d) In a binary tree, a node can have a maximum of two children. If there are n nodes in a binary tree, the maximum height of the binary tree is n-1.

9. (c)

10. (c) Given a graph G = (V, E) the adjacency list representation consists of an array Adj of |E| elements. Adjacency lists require space Θ (|V|+|E|) and are preferable for sparse graphs with a low density of connections.

---
  • The study material for AMIE/B Tech/Junior Engineer exams is available at https://amiestudycircle.com
  • If you like the post please share your thoughts in the comment section 


Comments