ANSWER IN ONE NUMBER/WORD/SENTENCE
1.A sorted array contains 300,000 elements. The maximum number of operations needed by binary search to check if an element is present in the array would be
2.The correct statement indicating the recurrence relation for mergesort is Blank 1
302: T(n) = T(n/2) + n
303: T(n) = 2T(n/2) + n/2
304: T(n) = 2T(n/2) + n
306: T(n) = T(n – 1) + 3n
3.Put the most appropriate statement number here
171: Insertion at the end of an array structure takes O(1) time and insertion at the end of a linked list takes O(n) time.
172: Searching the largest element in a random array takes O(log n)
173: Deletion of first element takes O(1) for an array and O(1) for a linked list
174: Searching for mid element takes O(log n) both for a sorted array and a sorted linked list
4.An array contains following elements: 20 42 8 66 12 39 11 26 33
The mergesort method we discussed in the class calls a merge function. The number of times the merge function is going to be called when mergesort is applied on the array is
5.Mergesort is applied on an array containing 50 elements. Once the array gets sorted mergesort is applied a second time on the sorted array. The correct statement number is
6.Find the prefix 7 5 8 * 20 10 – / + 5 –
7.Each node in the list stores an integer and link to next node. Indicate the correct statement number corresponding to following code Blank 1
void fun1(struct Node* head) {
temp = head;
while (temp != NULL)
temp = temp->next;
printf("%d, ", temp->data);
}
200: Fails to print any data of the list 202: Prints the list in first-to-last order.
204: Prints the data of the last node 206: Prints the data in reverse order
8.
struct node {
int data;
struct node *next;
} *AA, *BB;
// create linked list AA with 28 nodes
BB = AA;
Assume that the code shown above creates the linked list AA. Study various choices given below. Out of the following, the most appropriate statement is Blank 1
300: If we use the statement BB= NULL after this,
the complete list is lost and we cannot get access to any of the nodes of the list
302: If we use the statement AA=AA->next after this,
we will not be able to access the first node of AA or BB.
304: If we use the statement AA=AA->next after this,
it will result in AA having 27 nodes while BB will remain unchanged.
306: This will result in creating a copy of the list accessed by BB.
9.M integers have been stored in Stack A, and N integers have been stored in stack B. It is desired to POP all the integers from stack B and PUSH in stack A. The correct statement indicating Big-O for this job is
10. The mergesort method we discussed in the class is applied on the array containing following elements
50 15 39 11 26 33 42 20
After the 3rd merge the correct contents of the array are shown in statement number Blank 1
202: 15 50 11 39 26 33 20 42
204: 11 15 20 26 33 39 42 50
206: 11 15 39 50 26 33 42 20
208: 15 50 11 39 26 33 42 20
Trending nowThis is a popular solution!
Step by stepSolved in 7 steps with 2 images
- Given the following array, what is the content of the array after Two levels of merge function calls applied in Merge Sort with function call MergeSort(array, 0, 5); array: 44 12 50 3 40 23 Question 3 options: 44 12 50 3 23 40 12 44 50 3 23 40 12 3 40 23 44 50 3 12 23 40 44 50arrow_forward2. Suppose the function MergeSort( Vis a recursive implementation of the merge sort algorithm, which takes as input an integer array A. How many times is MergeSort( ) recursively called, if A is of size n? Answer: Select T Select Olnlogn 3. How many times is the Merge routine called in total, O(1) Oln 2) nswer. ISelect ]arrow_forwarddef sorting(x, i, j) if j+1-i < 10 then Mergesort(x, i, j); t1 = i + (j+1-i)/3 t2 = i + 2*(j+1-i)/3 Sorting(x, i, t2) Sorting(x, i, j) Sorting(x, i, t2) // x is an array, I and j are first and last indices of this part of the array // on k elements, takes O(k log k) time worst case analysis?arrow_forward
- 6. Which of the following code snippet performs linear search recursively?arrow_forwardshow example on implementing Merge sort and Quick sortarrow_forwardfor this assignment, import pandas and numpy. Set the random seed to 12 for this assignment. 1 Use multi-indexing to create the following series. Words Numbers One 1 2 1 2 Three 1 2 dtype: int64 Two Assign it to Q1. 11 111 22 222 333 Index 01 to obtain the followingarrow_forward
- True or False For each statement below, indicate whether you think it is True or False. If you like, you can provide a description of your answer for partial credit in case you are incorrect. 4) Delete is O(1) in the worst case because there is no shift after removing the node 5) Update is O(n) because it needs to perform a search for the element in the list 6) In the delete algorithm, the “previous” node reference is needed in case the element is not found in the listarrow_forwardCreate and test assumptions regarding the running times of insertion sort and selection sort for arrays with just two key values, assuming the values are equally likely to occur.arrow_forward6. Below is a table that shows the timing of three different algorithms using an array of integers as input. Explain which of the algorithms is most likely the selection sort and which is the merge sort, explain in details your answer. Algorithm 1 Algorithm 2 Algorithm 3 time to process 2000 integers 0.1431 sec 0.8011 sec 0.0132 sec time to process 4000 integers 0.5722 sec 1.4300 sec 0.0304 sec time to process 8000 integers 2.2989 sec 2.4512 sec 0.0634 secarrow_forward
- numbers: 13 18 72 26 62 74 Merge(numbers, 0, 2, 5) is called. Complete the table for leftPos and rightPos at the moment an element is copied into merged Numbers. mergePos leftPos rightPos 0 1 2 3 4 LO 5 0 Ex: 3 ŵ î î 3 ŵ Element copied to merged Numbers 13 18 26 62 72 74arrow_forwardGenerate pseudocode for searching for an Employee ID I was given this example but I don't understand what it means an employee ID (123) is hashed into a value of 5. For hDict(5) we store apointer to the first available spot in lValue, which at the time of the insertion was 2. We store a value of123 in lValue(2) and a value of null in lPtr(2) because there are no other elements right now, so weterminate the linked list. Later on another employee ID (135) needs to be inserted. It’s hash value isalso 5. In order to find where to insert it in lValue we need to traverse the linked list to get to the lastelement. The first element we come to is 2. lPtr(2) is null so we know we’re at the end of the linked list.So we get the next empty slot in lValue, which was 3, and assign the value 3 to lPtr(2). We assign thenew Employee ID (135) to next open slot lValue(3) and set lPtr(3) to null because it now becomes theend of the list.arrow_forward4- Sort the list A[]={ 20, 13,4, 34, 5, 15, 90, 100, 75, 102, 112, 1} a) Using Merge Sort and show the order that the Merge procedure is performed. b) Explain the average case of Merge Sort. Give a detail explanation of how we can estimate the mean in relationship with the worst and best-case scenarios (hint: use the answer for question 3 as a lower-bound for the average).arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education