Thursday, 14 May 2020

Questions and answers in Data Structures and Algorithms 03

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



Data Structures and Algorithms TRUE / FALSE Questions – Set 03



1. The running time of inserting an item into an unsorted list is O(n)

(a) TRUE                                                   (b) FALSE


View Answer

Answer: FALSE
The running time is O(1) for inserting an item into an unsorted list.
We are about to insert an item into an unsorted list, so we can insert the item at the end of the list if we use an array data structure.

2. Suppose an array X is declared as int X[5]; The base address of the array is 100 and integers take up 4 bytes. Then, the address of X[2] is 110.

(a) TRUE                                                   (b) FALSE


View Answer

Answer: FALSE
The address of X[2] is 108.
Address of an array element

3. Stack follows First In First Out (FIFO) rule

(a) TRUE                                                   (b) FALSE


View Answer

Answer: FALSE
Stack is Last In First Out (LIFO), where the last element inserted will be accessed first then the next last and so on. Stack supports operations PUSH (insert) and POP (delete) functions. Both will be executed from the top of the stack.

Stack push and pop operations


4. In a circular doubly linked list with 10 nodes, we will need to change 4 links if we want to delete a node other than the head node.

(a) TRUE                                                   (b) FALSE


View Answer

Answer: FALSE
We can change the link fields of the nodes that precede and follow the node we want to delete. So we just need to change 2 links if we want to delete a node other than the head node.

Circular doubly linked list


5. When using linked list to perform insertion sort, each time we remove an element from the input list and insert it to the correct position in the linked list. Assume that we have n numbers to be sorted, the time complexity for sorting these numbers using the insertion sort algorithm is O(n2).

(a) TRUE                                                   (b) FALSE


View Answer

Answer: TRUE
The worst case is that we have to search all numbers in the list before we insert a new number.
1 + 2 + ... + n = n(n − 1)/2
The time complexity for sorting these numbers using the insertion sort algorithm is O(n2).


***********

Interview questions and answers in data structure and algorithms

DSA quiz questions with answers explained

Solved true or false questions in DSA

Practice questions in data structures

TRUE  or FALSE questions in data structures and algorithms

No comments:

Post a comment

Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents