Advanced Database Management System - Tutorials and Notes: Questions and answers in Data Structures and Algorithms 04

# TRUE/FALSE Quiz Questions with Answers in Data Structures and Algorithms, Data Structures interview questions

## Data Structures and Algorithms TRUE / FALSE Questions – Set 04

### 1. The time complexity of adding 5 to each element of a array of N numbers is O(N).

(a) TRUE                                                   (b) FALSE

 Answer: TRUE The time complexity will be O(N) because each element will be accessed only once to add number 5.

2. Let us suppose that there is a variable declaration int x = 50, *ptr. Then, the statement *ptr = &x is a valid statement in main() function.
(a) TRUE                                                   (b) FALSE

 Answer: FALSE *ptr is a pointer, &x is the address of x. The correct way to assign the address to the pointer variable is, ptr = &x.

### 3. Minimum and maximum height of a binary heap with N keys will be ⌊ log2N ⌋.

(a) TRUE                                                   (b) FALSE

The height of binary heap with N keys will be floor(log2N).

### A binary heap is a heap data structure that takes the form of a binary tree. They are useful in the implementation of priority queues. The properties of binary heap are;

• All child nodes must be less (or greater) than its parent node for a max (or min) heap.
• The leaves must either fill the h or h-1 node where h is the height of the tree; it means it must be a complete binary tree.

#### 4. Inserting an element to the beginning of an array (that is A element) is more difficult than inserting an element to the beginning of a linked list.

(a) TRUE                                                   (b) FALSE

Inserting an element at the beginning of an array is easy only if array is empty. Otherwise, we need to move all the other elements that are stored in that array to create space. Hence, it is difficult to insert an element at the beginning of an array.

### 5. The largest value in a binary search tree is always stored at the root of the tree.

(a) TRUE                                                   (b) FALSE

 Answer: FALSE An important reason that BSTs are widely used is that they allow us to keep the keys in order. A binary search tree is a binary tree with the following properties: The data stored at each node has a distinguished key which is unique in the tree and belongs to a total order. (That is, for any two non-equal keys, x,y either x < y or y < x.) The key of any node is greater than all keys occurring in its left subtree and less than all keys occurring in its right subtree.

***********