Question 1 \"Given the following array, how many comparisons to an array entry a
ID: 3685219 • Letter: Q
Question
Question 1 "Given the following array, how many comparisons to an array entry are performed to search for the number 2 if you use the binary search algorithm? -- 2 3 5 7 11 13 17 19 23 29 31 37" a) 3 b) 8 c) 5 d) 1 Question 2 "Given the following array, how many comparisons to an array entry are performed to search for the number 23 if you use the binary search algorithm? -- 2 3 5 7 11 13 17 19 23 29 31 37" a) 4 b) 9 c) 5 d) 3 Question 3 "When searching an unsorted array of items, the recursive search performs ______ comparisons than the iterative search." a) fewer b) more c) the same number of d) almost as many Question 4 "Given the following array, how many comparisons to an array entry are performed to search for the number 11 if you use the binary search algorithm? -- 2 3 5 7 11 13 17 19 23 29 31 37" a) 7 b) 5 c) 10 d) 2 Question 5 "Given the following array, how many comparisons to an array entry are performed to search for the number 37 if you use the binary search algorithm? -- 2 3 5 7 11 13 17 19 23 29 31 37" a) 7 b) 12 c) 2 d) 24 Question 6 A sequential search of a sorted array can tell whether an item is present in the array in _____ comparisons than a sequential search of an unsorted array. a) more b) the same number of c) fewer d) none of the above Question 7 "Using an iterative sequential search on an unsorted array, what happens when the inArray method does not find the entry we are searching for?" a) it returns 0 b) it returns false c) it throws an ElementNotFoundException d) it returns null Question 8 "Given the following array, how many comparisons to an array entry are performed to search for the number 13 if you use the binary search algorithm? -- 2 3 5 7 11 13 17 19 23 29 31 37" a) 12 b) 6 c) 2 d) 1 Question 9 "When you truncate a positive real number to an integer, you are computing the number s" a) fractional portion b) ceiling c) truncation factor d) floor Question 10 "If you have a list object to search that is an instance of ADT list, you search it by using the list operation" a) search b) inList c) contains d) has QUESTION 11 "In a circular array-based implementation of a queue, what is the performance when the enqueue operation must resize the array?" a) O(n) b) O(log n) c) O(n^2) d) O(1) QUESTION 12 1. When adding a node to a two-part circular linked chain implementation of a queue a) check to see if the linked chain needs resized b) first check if a node is already available in the chain c) allocate a new node and assign the reference to freeNode d) all of the above QUESTION 13 1. When would you choose a two-part circular chain over a circular chain? a) when you rarely add entries after removing one b) when you are space constrained c) when you don t want the garbage collector running d) when you frequently add an entry after removing one QUESTION 14 1. To efficiently remove a node at the end of a linked chain implementation of a queue requires as a) tail reference b) traversal c) extra reference in the node pointing to the previous node d) none of the aboveExplanation / Answer
Question 1 "Given the following array, how many comparisons to an array entry are performed to search for the number 2 if you use the binary search algorithm? -- 2 3 5 7 11 13 17 19 23 29 31 37" a) 3 b) 8 c) 5 d) 1
=> first the algorithm will go to the middle element and compare 2 with 13, 2 is less than 13 , so the algorithm will go to left subarray, now comparing 2 with 5 (which is mid of left subarray), again 2 is less than 5, algorithm goes to mid point of left subarray which is 2, comparing 2 with 2 . which then returns the answer. therefore total comparisons for getting 2 are 3
Answer -> 3
Question 2 "Given the following array, how many comparisons to an array entry are performed to search for the number 23 if you use the binary search algorithm? -- 2 3 5 7 11 13 17 19 23 29 31 37" a) 4 b) 9 c) 5 d) 3
=> first the algorithm will go to the middle element and compare 23 with 13, 23 is greater than 13 , so the algorithm will go to right subarray, now comparing 23 with 23 (which is mid of right subarray), which then returns the answer. therefore total comparisons beforing getting 23 are 3
Answer -> 2
Question 3 "When searching an unsorted array of items, the recursive search performs ______ comparisons than the iterative search." a) fewer b) more c) the same number of d) almost as many Question
= > the recursuion search performs more number of comparisons as it uses divide and concur method due to which , their is some repetition is the range of array between which the comparisons take place.
4 "Given the following array, how many comparisons to an array entry are performed to search for the number 11 if you use the binary search algorithm? --
2 3 5 7 11 13 17 19 23 29 31 37" a) 7 b) 5 c) 10 d) 2
=> first the algorithm will go to the middle element and compare 11 with 13, 11 is less than 13 , so the algorithm will go to left subarray, now comparing 11 with 5 (which is mid of left subarray), now 11 is greater than 5, algorithm goes to mid point of right subarray which is 7, comparing 11 with 7 , now 11 is greater than 7, algorithm goes to mid point of right subarray which is 11, comparing 11 with 11 which then returns the answer. therefore total comparisons beforing getting 37 are 4
Answer -> 4
Question 5 "Given the following array, how many comparisons to an array entry are performed to search for the number 37 if you use the binary search algorithm? -- 2 3 5 7 11 13 17 19 23 29 31 37" a) 7 b) 12 c) 2 d) 24
=> first the algorithm will go to the middle element and compare 37 with 13, 37 is grater than 13 , so the algorithm will go to right subarray, now comparing 37 with 23 (which is mid of right subarray), now 37 is greater than 23, algorithm goes to mid point of right subarray which is 31, comparing 37 with 31 , now 37 is greater than 31, algorithm goes to mid point of right subarray which is 37, comparing 37 with 37 which then returns the answer. therefore total comparisons beforing getting 2 are 4
Answer -> 4
Question 6 A sequential search of a sorted array can tell whether an item is present in the array in _____ comparisons than a sequential search of an unsorted array. a) more b) the same number of c) fewer d) none of the above
=> d) none of the above as it depends on the element needed to be found in the array, if the array is partially sorted we might the lemeent is less time than sequential search
Question 7 "Using an iterative sequential search on an unsorted array, what happens when the inArray method does not find the entry we are searching for?" a) it returns 0 b) it returns false c) it throws an ElementNotFoundException d) it returns null Question
=> The whole array gets parsed and we do not find an the required element then the function returns false, i.e the element is not present in the array
8 "Given the following array, how many comparisons to an array entry are performed to search for the number 13 if you use the binary search algorithm? -- 2 3 5 7 11 13 17 19 23 29 31 37" a) 12 b) 6 c) 2 d) 1
= > first the algorithm will go to the middle element and compare 13 with 13, since bothe are equal return statement is executed. therefore total comparisons for getting 13 is 1
Answer -> 1
Question 9 "When you truncate a positive real number to an integer, you are computing the number s" a) fractional portion b) ceiling c) truncation factor d) floor
=> First the truncation factor first which is the number after the deciaml element, if it is greater than 0.5, the number is truncated to one integer higher than number, otherwize if it is leff than 0.5, the number is truncated to one integer lower.
Question 10 "If you have a list object to search that is an instance of ADT list, you search it by using the list operation" a) search b) inList c) contains d) has
= > list object to search that is an instance of ADT list can be serached using inList function.
QUESTION 11 "In a circular array-based implementation of a queue, what is the performance when the enqueue operation must resize the array?" a) O(n) b) O(log n) c) O(n^2) d) O(1)
= > enque and deque operation is circular array-based implementation of a queue takes o(1) time.
QUESTION 12 1. When adding a node to a two-part circular linked chain implementation of a queue a) check to see if the linked chain needs resized b) first check if a node is already available in the chain c) allocate a new node and assign the reference to freeNode d) all of the above
= > adding a node to a two-part circular linked chain implementation of a queue we need check to see if the linked chain needs resized ,check if a node is already available in the chain, allocate a new node and assign the reference to freeNode. All of these
QUESTION 13 1. When would you choose a two-part circular chain over a circular chain? a) when you rarely add entries after removing one b) when you are space constrained c) when you don t want the garbage collector running d) when you frequently add an entry after removing one
= > two-part circular chain over a circular chain is selected when we are frequently adding an entry after removing one . it reduces the time complexity in this case significantly
QUESTION 14 1. To efficiently remove a node at the end of a linked chain implementation of a queue requires as a) tail reference b) traversal c) extra reference in the node pointing to the previous node d) none of the abov
=> To efficiently remove a node at the end of a linked chain implementation of a queue requires extra reference in the node pointing to the previous node which is neede while freeing the last node.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.