






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
COSC 2436 Exam 2 Questions And complete answers.
Typology: Exams
1 / 10
This page cannot be seen from the preview
Don't miss anything!
A sorting algorithm that does not change the relative order of objects that are equal is called - answer stable The quick sort algorithm uses a ________ to divide the array into two pieces. - answer pivot Which sorting algorithm divides the array into two pieces based on the selection of a pivot element? - answer quick sort Which statements are true about the pivot element in quick sort? - answer all of the above In quick sort, dividing the array portions before and after the pivot are called - answer partitions In quick sort, the partition step takes at most ______ comparisons for n items. - answer n The ideal situation in quick sort is when the pivot moves - answer to the center of the array In quick sort, having every partition form sub array of roughly the same size - answer is optimal The best-case performance of quick sort for n items is - answer O(n log n) The average-case performance of quick sort for n items is - answer O(n log n) The worst-case time efficiency of a sequential search on an array is - answer O(n) When searching an unsorted array of items, the recursive search performs ______ comparisons the iterative search. - answer the same number of comparisons as A sequential search of a sorted array can tell whether an item is present in the array in _____ a sequential search of an unsorted array. - answer fewer comparisons than A search on a data set that divides the data roughly in half every iteration is called a(n) _____ search - answer binary In an array of 100 items sorted in ascending order, if you are searching for the number 165 and the entry at array index [50] has a value of 72, what can we conclude? - answer all of the above What is the base case in the recursive algorithm for a binary search of a sorted array? -
answer first index > last 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 - answer 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 - answer 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 - answer 7 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 - answer 7 What ADT dictionary method creates an iterator that traverses all the values in the dictionary? - answer getValueIterator In the ADT (Abstract Data Type) dictionary, a key-null pair - answer is not stored In the ADT (Abstract Data Type) dictionary, you can traverse - answer all of the above If you create a keyIterator and a valueIterator for the same dictionary, the keyIterator is _____ the valueIterator. - answer the same length as A sorted dictionary must use search keys that belong to a class that implements the interface - answer Comparable The class Scanner can break a string into substrings called - answer tokens
In the unsorted array-based dictionary, the worst-case time efficiency of removing a key- value pair is - answer O(n) In the unsorted array-based dictionary, the worst-case time efficiency of retrieving a key- value pair is - answer O(n) In the unsorted array-based dictionary, the worst-case time efficiency of traversing the dictionary is - answer O(n) In a sorted array-based dictionary, you add an entry by - answer shifting subsequent array entries up by one position In the sorted array-based dictionary, the worst-case time efficiency of adding a key-value pair is - answer O(n) Duplicate hash code - answer create collisions If a search key's data type is _____ you can use the key itself as the hash code. - answer int If a search key is an instance of _____ , it can be cast to an int to get a hash code. - answer all of the above Dividing a long search key into pieces and combining them through addition or a bit-wise boolean operation is called - answer folding
We want to distribute hash codes throughout the index range - answer 0 through n- The recommended size of a hash table is a(n) - answer prime number greater than 2 Finding an unused location in the hash table is called - answer open addressing Resolving a collision in a hash table by examining consecutive locations in the table to find the next available one, beginning at the original hash index, is called - answer linear probing In open addressing with linear probing, what happens if the search key is not in the table?
binary A tree in which each node may have no more than n children is called a(n) _____ tree. - answer n-ary The _____ node is the only node that has no parent. - answer root Any node and its descendants form a _____ of the original tree. - answer subtree A subtree of a node is a tree rooted at - answer a child of that node The number of levels in a tree is called the - answer height A binary tree has at most two children called - answer both answers A complete traversal of an n-node binary tree is an O(n) operation if visiting a node is _____ for the iterative implementation. - answer O(1) Given the following binary expression tree, what value is returned from the method evaluate in the class ExpressionTree if w = 7, x = 2, y = 1, and z = 8? - answer 64 The postorder traversal of a general tree is the same as the _____ traversal of a binary tree.
A node in a binary tree is an object that references a data object and - answer two child nodes in the tree An iterative version of a preorder traversal for a binary tree uses a(n) - answer stack An iterative version of a postorder traversal for a binary tree uses a(n) - answer stack An iterative version of a level order traversal for a binary tree uses a(n) - answer queue A complete traversal of an n-node binary tree is a(n) _____ operation if visiting a node is O(1) for the recursive implementation. - answer O(n) A complete traversal of an n-node binary tree is a(n) _____ operation if visiting a node is O(1) for the iterative implementation. - answer O(n) The inorder predecessor of a node N is - answer the largest entry in N's left subtree The inorder successor of a node N is - answer the smallest entry in N's right subtree The largest entry in a node N's left subtree is - answer the subtree's rightmost node The largest entry in a node N's right subtree is - answer the subtree's rightmost node The smallest entry in a node N's left subtree is - answer the subtree's leftmost node
In the array-based heap, assuming heap entries start at index 1, when removing the heap's largest object, you remove - answer the root In the class MaxHeap method removeMax, the heap's root is replaced with its - answer last leaf In the array-based heap implementation, the method add has efficiency - answer O(log n) In the array-based heap implementation, creating a heap using the add operation has efficiency - answer O(n log n) It is more efficient to create a heap using - answer the reheap method In the class MaxHeap method reheap, we begin at - answer the first nonleaf closest to the end of the array