data structures final

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Given the queue myData 12, 24, 48 (front is 12), where will the new item 72 be enqueued? A. After 48 B. After 24 C. Before 12 D. After 12

A. After 48

Consider a hash table named marksTable that uses linear probing and a hash function of key % 5. What would be the location of item 46? HashInsert(marksTable, item 49) HashInsert(marksTable, item 41) HashInsert(marksTable, item 42) HashInsert(marksTable, item 44) HashInsert(marksTable, item 46) A. Bucket 0 B. Bucket 1 C. Bucket 2 D. Bucket 3

A. Bucket 0

What operation returns, but does not remove, the item at the front of a deque? A. PeekFront(deque) B. PushFront(deque) C. PopFront(deque) D. PeekBack(deque)

A. PeekFront(deque)

Which abstract data type (ADT) is most suitable to store a list of perishable products such that the product with the nearest expiry date is removed first? A. priority queue B. deque C. queue D. linked list

A. Priority queue

A hash function uses an item's _____ to compute the item's bucket index. A. bucket B. key C. function D. location

B. key

Insertion sort requires at most _____ swaps to sort a list of 20 elements. A. 20 B. 40 C. 190 D. 400

C. 190

Which of the following lists is sorted? A. Ted, Tom, Thomas, Tim B. apple, orange, banana, pear C. 89, 79, 63, 22 D. 1.01, 1.01, 1.1, 1.001

C. 89, 79, 63, 22

Which of the following is a constant time operation? A. Finding the minimum value in an unsorted array B. Finding the occurrence of a string in a sorted array C. Finding the sum of two numbers input by the user D. Concatenating two strings entered by the user

C. Finding the sum of two numbers input by the user

An algorithm is written to return the first name beginning with "L" in a list of employee names. Which of the following is the algorithm's worst case scenario? A. The first half of the list has names beginning with letters before "L," and the second half of the list has names beginning with letters after "L." B. The first name in the list begins with "L." C. No names in the list begin with "L." D. The last name in the list begins with "L."

C. No names in the list begin with "L."

What is the merge sort algorithm's runtime? A. O(logN) B. O(N) C. O(N log(N)) D. O(N²)

C. O(N log(N))

Given the doubly linked list, students (Tom, Sam, Hal, Pam), what is the student list's head node after the operation ListInsertAfter(students, node Tom, node Tim)? A. Tim B. Sam C. Tom D. Pam

C. Tom

Identify the new priority queue after enqueueing 40. [29, 36, 42, 52] A. [29, 36, 42, 54, 40] B. [40, 29, 36, 42, 54] C. [29, 36, 40, 42, 54] D. [29, 36, 42, 40, 54]

C. [29, 36, 40, 42, 54]

Given the doubly-linked list animalList (Cat, Dog), which nodes will be the head and tail nodes after the following operations? ListInsertAfter(animalList, node Cat, node Bird) ListInsertAfter(animalList, node Dog, node Fish) ListRemove(animalList, node Cat) ListRemove(animalList, node Fish) A. head = node Cat tail = node Dog B. head = node Bird tail = node Fish C. head = node Bird tail = node Dog D. head = node Fish tail = node Dog

C. head = node Bird tail = node Dog

Complexity analysis helps in avoiding algorithms with A. low memory usage B. low runtime C. high memory usage D. high computational efficiency

C. high memory usage

In a tree representing a file system, _____. A. leaf nodes represent only empty directories B. leaf nodes represent only non-empty directories C. leaf nodes represent either files or empty directories D. Leaf nodes represent only files

C. leaf nodes represent either files or empty directories

In selection sort, the smallest element is selected and swapped with the _____ unsorted element. A. next B. middle C. leftmost D. rightmost

C. leftmost

Which is an abstract data type (ADT)? A. float B. boolean C. list D. string

C. list

Given a doubly-linked list (2, 3, 4, 5, 6, 7), node 2's pointers point to _____. A. node 3 B. null C. node 3 and null D. the head and node 3

C. node 3 and null

Which data type is best suited to store the names and grades of students? A. graph B. array C. record D. stack

C. record

The C++ MergeSort() function _____. A. only merges partitions of length 1 B. merges the array's left and right partitions, then recursively sorts each partition C. recursively sorts the array's left and right partitions, then merges the sorted partitions D. does not use recursion

C. recursively sorts the array's left and right partitions, then merges the sorted partitions

A constant time operation is independent of _____. A. the programming language B. the output of the code C. the input values of the code D. the hardware running the code

C. the input values of the code

Given the array-based list (20, 30, 40, 50), what will the new array look like after the following operations? ArrayListPrepend(list, 10) ArrayListSearch(list, 25) ArrayListRemoveAt(list, 3) ArrayListSearch(list, 40) A. 20, 30, 40, 50, 10 B. 10, 20, 40, 50 C. 10, 20, 25, 40, 50 D. 10, 20, 30, 50

D. 10, 20, 30, 50

Set A = {12, 24, 26, 38, 42} and Set B = {10, 20, 26, 30, 42}. Identify A ∩ B. A. 10, 12, 20, 24, 30, 38 B. 12, 24, 38 C. 10, 12, 20, 24, 26, 30, 38, 42 D. 26, 42

D. 26, 42

Given the singly-linked list (80, 81, 82, 83), what is returned from ListSearch(list, 84)? A. 1 B. Node 80 C. True D. Null

D. Null

What operation is used to compute a bucket index in the range 0 to 16 from a key? A. key * 17 B. key - 17 C. key / 17 D. key % 17

D. key % 17

If a stack is implemented as a linked list, then a push will be a _____ operation. A. replace B. insert C. append D. prepend

D. prepend

A(n) _____ is a function f(N) that is defined in terms of the same function and operates on a value less than N A. recurrence relation B. recursive tree C. constant relation D. infinite tree

A. recurrence relation

The space complexity of a BST insertion algorithm is _____. A. O(N) B. O(logN) C. O(log₂N) D. O(1)

D. O(1)

Identify the correct way to add 10 to the start of the array list: 11, 12, 13, 14. A. ArrayListAppend(list, 10) B. ArrayListPrepend(list, 10) C. ArrayListInsertBefore(list, 10) D. ArrayListAppend (list, 0, 10)

B. ArrayListPrepend(list, 10)

Identify the correct statement about binary space partitioning. A. Regions are always split down the middle either horizontal or vertical. B. Half the objects are eliminated each level while traversing down a BSP tree C. A BSP tree can be used to store all objects in a two-dimensional world. D. In animation only one region is analyzed at a time.

C. A BSP tree can be used to store all objects in a two-dimensional world.

Given the deque 10, 12, 14, 16 (front is 10), what will the deque look like after the following operations? 1. push-front 2 2. push-back 13 3. push-front 8 4. pop-front 5. pop-back 6. push-back 18 A. 2, 10, 12, 14, 16, 13, 18 B. 8, 10, 12, 14, 16, 13, 18 C. 8, 10, 12, 14, 16, 18 D. 2, 10, 12, 14, 16, 18

D. 2, 10, 12, 14, 16, 18

What is the height of a BST built by inserting nodes in the order 20, 10, 30? A. 3 B. 2 C. 1 D. 0

C. 1

Identify the statement that is true of linked list traversal. A. A list traversal algorithm starts with the list's next node B. A doubly-linked list does not support list traversal C. A doubly linked list's reverse traversal starts with the list's tail node D. A singly-linked list supports reverse traversal

C. A doubly linked list's reverse traversal starts with the list's tail node

Identify the correct way to remove 18 from the singly-linked list (18, 20, 22, 24) A. ListRemoveAfter(list, 18) B. ListRemoveAfter(list, node 0) C. ListRemoveAfter(list, node 18) D. ListRemoveAfter(list, null)

D. ListRemoveAfter(list, null)

ListSearch visits _____ when searching for 83 in the singly-linked list (80, 81, 82, 83). A. only the first node B. only the last node C. only the first and last nodes D. all the nodes

D. all the nodes

Which of the following is best represented by a graph? A. A telephone network B. A work scheduling operation C. The undo command in a word processor D. A file system on a computer

A. A telephone network

Which of the following is an example of constant time O(1)? A. Accessing an element of an array B. Finding the minimum value of an array C. Binary Search D. Bubble sort

A. Accessing an element of an array

Which of the following should be a dynamic set? A. Guest list in a hotel B. Days of the week C. Names of colors D. Names of planets in the solar system

A. Guest list in a hotel

What represents the size of a adjacency list graph? A. O(V + E) B. O(V - E) C. (V * E) D. (V * 2E)

A. O(V+E)

The process of providing only the essentials and hiding the details is known as A. abstraction B. optimization C. data structure D. algorithm

A. abstraction

If a queue is implemented as a linked list, an enqueue inserts a new item _____. A. after the last item B. before the first item C. before the last item D. after the first item

A. after the last item

An algorithm's _____ is the scenario where the algorithm does the minimum possible number of operations A. best case B. best time C. average case D. worst case

A. best caes

If a stack is implemented as a linked list, then a pop will remove the which node? A. head node B. tail node C. middle node D. null

A. head node

A stack abstract data type (ADT) is implemented using a(n) A. linked list B. array C. binary search tree D. heap

A. linked list

A perfect hash function _____. A. maps items to buckets with no collisions B. uses chaining to resolve collisions C. uses open addressing to resolve collisions D. has O(N) time complexity for inserting into a hash table

A. maps items to buckets with no collisions

The worst-case runtime of an algorithm is the _____ number of steps taken to execute a problem A. maximum B. minimum C. average D. optimum

A. maximum

In a recursive function, the base case _____ the function. A. terminates B. provides input to' C. passes a parameter to D. loops

A. terminates

If a queue is implemented as a linked list, a dequeue removes _____ node. A. the head B. the tail C. the middle D. a random

A. the head

Given the list (27, 40, 15, 25, 10, 19, 30), what are the new partitioned lists if the pivot is 25? A. (19, 27, 30, 40) and (10, 15, 25) B. (10, 15, 19, 25) and (27, 30, 40) C. (27, 40, 15, 25) and (10, 19, 30) D. (25, 10, 19, 30) and (27, 40, 15)

B. (10, 15, 19, 25) and (27, 30, 40)

What is the minimum possible height of an AVL tree with the following nodes in order? 320, 470, 500, 540, 700, 650, 870 A. 1 B. 2 C. 3 D. 4

B. 2

Identify the number of elements in a set formed by adding the following: element 10, 4 times element 15, 5 times element 20, 6 times A. 2 B. 3 C. 15 D. 16

B. 3

What is the height of a BST built by inserting nodes in the order 12, 24, 23, 48, 47? A. 4 B. 3 C. 2 D. 1

B. 3

Given the list (75, 76, 68), identify the commands for the following operations: 1. Insert 80 at the end of the list 2. Remove 68 3. Insert 82 at the end of the list 4. Get the total number of items in the list A. Append(list, 80) Append(list, 82) Remove(list, 68) GetLength(list) B. Append(list, 80) Remove(list, 68) Append(list, 82) GetLength(list) C. Append(list, 80, 82) Remove(list, 68) GetList(list) D. Append(list, 80) Insert(list, 82) Remove(list, 68) GetItem(list)

B. Append(list, 80) Remove(list, 68) Append(list, 82) GetLength(list)

Which of the following algorithms has the same best, average, and worst case runtime complexity? A. Quicksort B. Merge sort C. Shell sort D. Insertion Sort

B. Merge sort

What is the Big O notation for an algorithm with exactly 50 constant time operation? A. O(50) B. O(1) C. O(50N) D. 50 · O(1)

B. O(1)

What is the worst-case runtime complexity of a peek operation on a priority queue? A. O(logN) B. O(1) C. O(N) D. O(NlogN)

B. O(1)

Which of the following is a fast sorting algorithm? A. Selection sort B. Quicksort C. Shell sort D. Insertion sort

B. Quicksort

"Major" becomes "Pmdru" after encryption. Identify the correct Caesar cipher used A. Right shift of 2 B. Right shift of 3 C. Left shift of 3 D. Left shift of 2

B. Right shift of 3

In a computational problem for finding the highest salary of an employee in a company, what is the input? A. The number of employees B. The list of employees' salaries C. The highest salary D. The computation of the highest salary

B. The list of employees' salaries

When removing curNode from a doubly-linked list with at least 2 elements, the list's tail may be assigned with A. curNode B. curNode's predecessor C. curNode's successor D. null

B. curNode's predecessor

ADTs allow programmers to A. choose the runtime and memory usage of a program B. focus on higher-level operations as per a program's needs C. access underlying implementations of a program D. debug a program

B. focus on higher-level operations as per a program's needs

During insertions, if the bucket is occupied, iterating over i values to determine the next empty bucket is called _____. A. arithmetic sequence B. probing sequence C. geometric sequence D. hashing sequence

B. probing sequence

What is the operation to add an item to the back of a deque? A. push-front B. push-back C. pop-front D. pop-back

B. push-back

Appending an element in an array involves increasing the array's A. item B. size C. value D. data type

B. size

For forward traversal of a singly-linked list, the ListTraverseRecursive(node) function must _____. A. call ListTraverseRecursive(node->next), then visit the node B. visit the node, then call ListTraverseRecursive(node->next) C. call ListTraverseRecursive(node), then visit the node D. visit the node, then call ListTraverseRecursive(node)

B. visit the node, then call ListTraverseRecursive(node->next)

The lower bound of an algorithm's runtime complexity is _____. A. ≥ the best case B. ≤ the best case C. ≤ the worst case D. ≥ the worst case

B. ≤ the best case

Given a stack myData: 34, 56, 78, 12, 66 (top is 34), what is the output after the following operations? Push(myData 43) Pop(myData) Pop(myData) print(Peek(myData)) Pop(myData) print(Peek(myData)) A. 43 34 B. 34 56 C. 56 78 D. 12 66

C. 56 78

Identify the correct way of denoting the union of sets A and B. A. A ∩ B B. A \ B C. A ∪ B D. A * B

C. A ∪ B

What is not a characteristic of an NP-complete problem? A. If an NP-complete problem has an efficient solution, then all NP-complete problems will have an efficient solution B. An efficient algorithm to solve an NP-complete problem may be possible C. All NP-complete problems can be solved efficiently D. No efficient algorithm has been found to solve an NP-complete problem

C. All NP-complete problems can be solved efficiently

What function is first called for removing a node from an AVL tree? A. AVLTreeRemoveNode B. AVLTreeRebalance C. BSTSerach D. AVLTreeGetBalance

C. BSTSerach

Which of the following rules does a valid BST follow? A. Right subtree keys ≤ node's keys B. Left subtree keys ≥ node's keys C. Left subtree keys ≤ node's keys D. Right subtree keys ≤ left subtree keys

C. Left subtree keys ≤ node's keys

What is the sequence of steps when performing a binary search? A. 1. Binary search first checks the first element of the list. 2. If the search key is not found, the algorithm: (i) checks the middle element of the list or (ii) checks the right sublist if the search key is greater than the middle element. B. 1. Binary search first checks the middle element of the list. 2. If the search key is not found, the algorithm: (i) checks the right sublist if the search key is less than the middle element or (ii) checks the left sublist if the search key is greater than the middle element. C. 1. Binary search first checks the middle element of the list. 2. If the search key is not found, the algorithm: (i) checks the left sublist if the search key is less than the middle element or (ii) checks the right sublist if the search key is greater than the middle element. D. 1. Binary search first checks the last element of the list. 2. If the search key is not found, the algorithm: (i) checks the first element of the list or (ii) checks the right sublist if the search key is greater than the middle element.

C. 1. Binary search first checks the middle element of the list. 2. If the search key is not found, the algorithm: (i) checks the left sublist if the search key is less than the middle element or (ii) checks the right sublist if the search key is greater than the middle element.

Consider a hash table with the items 10, 31, 23, 54, 66, 88, 9, with a has function of (key % 10). Which of the following items will result in a collision if the numbers are inserted in order? 55, 46, 77, 99, 93, 92, 97 A. 55, 77, 99, 92 B. 55, 77, 92, 97 C. 46, 99, 93, 97 D. 46, 77, 99, 93

C. 46, 99, 93, 97

Which of the following statements is true with reference to searching? A. An algorithm is an outcome of a search after a program is executed. B. Linear search starts from the middle of the list to check all elements until the search key is found. C. Linear search will compare all elements if the search key is not present. D. Linear search is used only on sorted lists to find the required element.

C. Linear search will compare all elements if the search key is not present.

What is the typical runtime for insertion sort for singly-linked lists? A. O(N) B. O(N ⋅ logN) C. O(N²) D. O(N ⋅ (N-1))

C. O(N²)

Which is the worst case runtime for a quicksort algorithm? A. O(N) B. O(Nlog(N)) C. O(N²) D. O(2ᴺ)

C. O(N²)

What is the Big O notation of the composite function? 5N³ + O(N²) A. O(5N³) B. O(N³+N²) C. O(N³) D. O(N⁵)

C. O(N³)

Identify the notation for an algorithm complexity that has a positive c for all: T(N) ≥ c * f(N) A. T(N) = Θ(f(N)) B. T(N) = O(f(N)) C. T(N) = Ω(f(N)) D. T(N) = N(f(N))

C. T(N) = Ω(f(N))

Given an empty stack menuItems, what will be the result of the following operations? StackPush(menuItems, item Pizza) StackPush(menuItems, item Chips) StackPush(menuItems, item Nachos) StackPush(menuItems, item Tea) print(StackPop(menuItems)) A. Tea Nachos Chips Pizza B. Pizza C. Tea D. Pizza Chips Nachos Tea

C. Tea

What happens when a leaf node is removed? A. The root node becomes null B. The parent node becomes null C. The parent's right or left child becomes null D. The internal node becomes null

C. The parent's right or left child becomes null

Which of the following is not an example of sorting a list? A. arranging patient records alphabetically B. arranging employee details based on beginning dates C. arranging student records neatly on a desk D. arranging musical instruments based on the number of strings they have

C. arranging student records neatly on a desk

A recursive function calls _____. A. at least two more functions B. another function C. itself D. the main function

C. itself

Which of the following is not a valid set? A. {10, 15, 20} B. {12, 14, 16} C. {11, 22, 33, 11} D. {5, 10, 15}

C. {11, 22, 33, 11}

Which statement is true about the insertion of a new node in an AVL tree? A. AVLTreeInsert updates heights on all child nodes before inserting the node B. AVLTreeInsert updates heights on all child nodes after inserting the node C. AVLTreeInsert updates heights on all ancestors before inserting the node D. AVLTreeInsert updates heights on all ancestors after inserting the node

D. AVLTreeInsert updates heights on all ancestors after inserting the node

Identify the equation to calculate the balance factor, B, of an AVL tree node N. A. B = min(Height(RightSubTree(N)),Height(LeftSubTree(N))) B. B = max(Height(RightSubTree(N)),Height(LeftSubTree(N))) C. B = Height(LeftSubTree(N))+Height(RightSubTree(N)) D. B = Height(LeftSubTree(N))−Height(RightSubTree(N))

D. B = Height(LeftSubTree(N))−Height(RightSubTree(N))

Which of the following is an optional characteristic of a password has function? A. Store the user's password as has in database B. Difficult to convert from output hash value back to original password C. No two different passwords have the same has value D. Extra random data stored alongside the password hash value

D. Extra random data stored alongside the password hash value

What is the Big O notation of the algorithm? 7 + 12N + 3N² A. 7 B. 12N C. 3N² D. N²

D. N²

The best case runtime complexity of an algorithm that searches an array of size N is _____. A. O(N) B. O(N - 1) C. O(N / 2) D. O(1)

D. O(1)

Identify the priority queue after the following operations, assuming the queue is initially empty. EnqueueWithPriority(Tom, 2) EnqueueWithPriority(Sam, 6) EnqueueWithPriority(Carl, 5) EnqueueWithPriority(Tina, 1) A. Tom, Sam, Carl, Tina B. Tina, Carl, Sam, Tom C. Sam, Carl, Tom, Tina D. Tina, Tom, Carl, Sam

D. Tina, Tom, Carl, Sam

In a doubly-linked list with 2 dummy nodes, the list's _____. A. head pointer may be null B. tail pointer may be null C. head and tail pointer may point to the same node D. head node's next pointer may point to the list's tail node

D. head node's next pointer may point to the list's tail node

The C++ Partition() function used by Quicksort selects _____ as the pivot? A. the array's median value B. the array's mean value C. the array's most frequent value D. the element at the array's midpoint

D. the element at the array's midpoint

In a queue, a dequeue operations always removes _____ element. A. a random B. the middle C. the back D. the front

D. the front

In the ListInsertAfter function for singly-linked lists, the curNode parameter is ignored when _____. A. the list's head and tail pointers point to different nodes B. the newNode argument is also null C. the list has more than 2 items D. the list's head pointer is null

D. the list's head pointer is null

Given the list (24, 36, 48), which way is the correct way to add 12 to the start of the list? A. Append(list, 12) B. Prepend(list, 12) C. InsertBefore(list, 12) D. Append(list, 0, 12)

Prepend(list, 12)


संबंधित स्टडी सेट्स

CH. 2 The Internet, the Web, and Electronic Commerce

View Set

Introduction to Joint Multi-TDL Network (MTN) Operations JT101

View Set

Chapter 8 Test: Emergency Care, First Aid, & Disasters Practice Questions

View Set

Spanish Subject Pronoun Replacement

View Set

Education 300 Final JMU, Education 300 Final, Education 300 Midterm JMU Ch. 1, 11, 10, 6, 5

View Set

AP Environmental Science Key Terms

View Set

Notes 4, Chpt 3 Pt 3 - 422: Integrity Constraints

View Set

Chapter 10 Fetal Development and Genetics

View Set