Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

15 Solved Questions on Operations of Table Insert - Quiz 11 | CS 331, Quizzes of Data Structures and Algorithms

Material Type: Quiz; Class: Data Structures and Algorithms; Subject: Computer Science (CS); University: Jacksonville State University; Term: Unknown 1989;

Typology: Quizzes

Pre 2010

Uploaded on 08/19/2009

koofers-user-mzo
koofers-user-mzo 🇺🇸

5

(1)

10 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 331 Chapter 11
Page 1 of 5
Chapter 11 Questions
Multiple Choice Questions:
1) The ADT table is also known as a ______.
a) map
b) queue
c) heap
d) dictionary
Answer: d.
2) The ______ operation of the ADT table throws a TableException.
a) tableInsert
b) tableDelete
c) tableRetrieve
d) tableTraverse
Answer: a.
3) If the item with a given search key does not exist in a table, the tableRetrieve operation returns ______.
a) the value -1
b) the value 0
c) the value false
d) a null reference
Answer: d.
4) An array based implementation of an ADT is a ______ implementation.
a) vertical
b) linear
c) nonlinear
d) compound
Answer: b.
5) Which of the following is true about a linear implementation of a table?
a) the unsorted implementations must insert a new item into its proper position as determined by the
value of its search key
b) the sorted implementations can insert a new item into any convenient location
c) the sorted implementations maintain a count of the current number of items in the table
d) the unsorted implementations do not maintain a count of the current number of items in the table
Answer: c.
6) In the sorted linear implementation of a table, the proper position of a new item to be inserted is determined
______.
a) by the data type of the item
b) by the size of the item
c) by the value of the item
d) by the value of the search key of the item
Answer: d.
7) A(n) ______ implementation of a table is nonlinear.
a) list
b) linked list
c) binary search tree
d) array
Answer: c.
pf3
pf4
pf5

Partial preview of the text

Download 15 Solved Questions on Operations of Table Insert - Quiz 11 | CS 331 and more Quizzes Data Structures and Algorithms in PDF only on Docsity!

Chapter 11 Questions

Multiple Choice Questions:

  1. The ADT table is also known as a ______. a) map b) queue c) heap d) dictionary Answer: d.

  2. The ______ operation of the ADT table throws a TableException. a) tableInsert b) tableDelete c) tableRetrieve d) tableTraverse Answer: a.

  3. If the item with a given search key does not exist in a table, the tableRetrieve operation returns ______. a) the value - b) the value 0 c) the value false d) a null reference Answer: d.

  4. An array based implementation of an ADT is a ______ implementation. a) vertical b) linear c) nonlinear d) compound Answer: b.

  5. Which of the following is true about a linear implementation of a table? a) the unsorted implementations must insert a new item into its proper position as determined by the value of its search key b) the sorted implementations can insert a new item into any convenient location c) the sorted implementations maintain a count of the current number of items in the table d) the unsorted implementations do not maintain a count of the current number of items in the table Answer: c.

  6. In the sorted linear implementation of a table, the proper position of a new item to be inserted is determined ______. a) by the data type of the item b) by the size of the item c) by the value of the item d) by the value of the search key of the item Answer: d.

  7. A(n) ______ implementation of a table is nonlinear. a) list b) linked list c) binary search tree d) array Answer: c.

  1. In an unsorted array-based implementation of a table, a new item is inserted at location ______. a) items[size] b) items[size-1] c) items[size+1] d) items[size+2] Answer: a.

  2. A priority queue orders its items by their ______. a) position b) value c) priority value d) size Answer: c

  3. The first item to be removed from a priority queue is the item ______. a) in the front of the priority queue b) in the end the priority queue c) with the highest value d) with the highest priority value Answer: d

  4. In an array-based implementation of the priority queue, the pqDelete operation returns the item in ______. a) items[size] b) items[0] c) items[size-1] d) items[size+1] Answer: c.

  5. In a linear implementation of the priority queue based on a linked list, the item with the highest priority value is located ______. a) at the beginning of the linked list b) at the end of the linked list c) in the middle of the linked list d) at a random location in the linked list Answer: a.

  6. In a binary search tree implementation of the ADT priority queue, the item with the highest priority value is always in the ______. a) root of the tree b) leftmost node of the tree c) rightmost node of the tree d) leftmost node at level 1 of the tree Answer: c.

  7. A heap in which the root contains the item with the largest search key is called a ______. a) minheap b) maxheap c) complete heap d) binary heap Answer: b.

  8. A heap in which the root contains the item with the smallest search key is called a ______. a) minheap b) maxheap c) complete heap d) binary heap

  1. In a maxheap, the root contains a search key greater than or equal to the search key in each of its children. Answer: True.

  2. In a heap, the search keys of the children of a particular node have no relationship. Answer: True.

  3. The mergesort is more efficient than the heapsort in the worst case. Answer: False.

Short Answer Questions:

  1. What is the effect of the assumption that all items in a table have distinct search keys, on the insertion operation of a table? Answer: Under this assumption, the insertion operation must reject an attempt to insert an item whose search key is the same as an item already in the table.

  2. What function is performed by the tableLength operation of the ADT table? Answer: The tableLength operation determines the number of items in a table.

  3. What are the two possible outcomes of the tableRetrieve operation of the ADT table? Answer: If the retrieval of the item with a given search key is successful, the method returns the table item with the matching search key. If the item does not exist in the table, the method returns a null reference.

  4. What is a linear implementation? Answer: A linear implementation is an implementation that uses either an array or a reference-based linked list.

  5. What are the four categories of linear implementations of tables? Answer: The four categories are:

  • unsorted, array based
  • unsorted, reference based
  • sorted (by search key), array based
  • sorted (by search key), reference based
  1. What kind of implementation of the ADT table is appropriate for retrieval-dominated applications if the maximum size of the table is known? Answer: If the table’s maximum size is known, a sorted array-based implementation is appropriate for retrieval- dominated applications.

  2. What kind of implementation of the ADT table is appropriate for retrieval-dominated applications if the maximum size of the table is NOT known? Answer: If the table’s maximum size is not known, a binary search tree implementation is appropriate for retrieval- dominated applications.

  3. What are the advantages of a linear implementation of the ADT table over a binary search tree implementation? Answer: The main advantages of a linear implementation of the ADT table are simplicity and clarity. This makes them appropriate for tables that will contain only a small number of items.

  4. For what kinds of situations is a linear implementation of the ADT table more efficient than a binary search tree implementation? Answer: A linear implementation of the ADT table is efficient for situations in which the predominant operations are insertion and traversal in no particular order.

  1. In an array-based implementation of the priority queue, where is the item with the highest priority value located? Answer: In an array-based implementation of the priority queue, the item with the highest priority value is located at the end of the array.

  2. How does the pqDelete operation work in a linear implementation of the priority queue based on a linked list? Answer: The pqDelete operation returns the item that pqHead references and then changes pqHead to reference the next item.

  3. What are the two main differences between a heap and a binary search tree? Answer: First, while a binary search tree can be viewed as being sorted, a heap is ordered in a much weaker sense. Second, while binary search trees come in many different shapes, heaps are always complete binary trees.

  4. What is a semiheap? Answer: A semiheap is a complete binary tree in which the root’s left and right subtrees are both heaps.

  5. What does the priority value in a priority queue correspond to in a heap? Answer: The priority value in a priority queue item corresponds to a heap item’s search key.

  6. What is the major advantage that a heap implementation of a priority queue has over a binary search tree implementation? Answer: The major advantage of the heap implementation is that a heap is always balanced. This is not the case with a binary search tree, which degrades the binary search tree’s efficiency.