Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Qusstion 3: In each of the following, highligh the only correct response. (9 mar

ID: 3909723 • Letter: Q

Question

Qusstion 3: In each of the following, highligh the only correct response. (9 marks) 1. The time complexity formula fin)- gtn) means that: a) gin) is a lower bound on fn): no upper bound is specified b) gin) is an upper bound on fin): no lower bound is specified. c)gn) is both a lower bound and an upper bound on f(n). d) g(n) is an upper bound but not a lower bound on fn). e) None of the above. we use a linked structure based implementation of the Stack ADT. The operations that must be implemented are: a) Constructor, copy constructor, destructor. b) Constructor, destructor, assignment operator. ) Constructor, copy constructor, destructor, assignment operator d) Constructor, copy constructor, destructor, comparison operator . destructor, assignment operator, comparison operator 3. Consider a circular array based implementation of the Queue ADT. We create an empty queue of size 6, then enqueue in order 1, 5, 8, 3, and 4, dequeue twice, enqueue 6, 7, and 1, dequeue twice again, and enqueue 0. The array is now c) 146219 e) 108341 1 Assuming that Node* ptr points at the first node of a linked structure, which of the for" loops below will correctly iterate through every node? 4. a) for ( Node* node = NULL; node != ptr; node = node->next ) b) for (Node" node ptr, node f NULL: node node >next) c) for ( Node" node-per, node node-next node != NULL ) d) for ( Node" node ptr, node I NULL: node++ c) None of the above. Which operation is faster in the array based version of the Unsorted List ADT, as compared to the linked structure based version? 5. a) Deleting an item from the list. Emptying the list of all items. c) Inserting an item in the list. d) Searching for an item in the list. e) None of the above. 6. Binary Search can be employed in the following Sorted List operations: a) Retrieval only b) Retrieval and Deletion only. c) Insertion and Retrieval only. d) Insertion, Retrieval, and Deletion only e) Insertion, Retrieval, Deletion, and Iterator. 3/5

Explanation / Answer

Answers:-

1.C).g(n) is both the lower bound and upper bound on f(n).

2.C).Constructor,Copy Constructor,destructor and Assignment Operator.

->Constructor is to Allocate the memory for an Object.
->Copy Constructor is called when a new object is created from an existing object, as a copy of the existing object.
->And assignment operator is called when an already initialized object is assigned a new value from another existing object.
->Destructor is called to free the Memory.

3.A).[7      1      0      _   4   6]


4.B).for(Node *node=ptr;ptr!=NULL;node=node->next)

Which means initially we Assigned/linked ptr to the node
i.e node->ptr contains the Head/first node of of list,
To print the Data we have to check the condition i.e it doesn't point to NULL.
if it is true then Check with Next Node i.e node=node->next Now new node will be linked.


5.D).Searching for an item in the list.

->Insertion and deletion of the Data in arrays will take much time
why because Its Need to do lot of Shifting.

->Using an array, we simply compute the offset for the index and have the element at the index
so the Searching of index in array is faster than linked List.

6.E).Insertion,Retrieval,Deletion and Iterator.

->Binary Search tree can be Employed to insert the Data,delete the data and Traverse the Data in three different Techniques
   called in-order,pre-order and post order.
->And Also used implement an iterator over a binary search tree (BST).
Your iterator will be initialized with the root node of a Binary Search tree.
The first call to next() will return the smallest number in Binary Search tree.
Calling next() again will return the next smallest number in the Binary Search tree, and so on