Exam 16: Basic Data Structures

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

The linked list iterator described in the textbook maintains a reference to the last visited node, called position, and a reference to the last node before that, called previous. Which of the following statements is NOT correct regarding advancing this iterator?

Free
(Multiple Choice)
4.8/5
(37)
Correct Answer:
Verified

D

Reading or writing an array list element at an arbitrary index takes ____ time.

Free
(Multiple Choice)
4.7/5
(41)
Correct Answer:
Verified

D

Complete the following code, which is intended to add an element to a hash table. Assume that the computed and compressed hash code is stored in the variable h. Node newNode = new Node(); NewNode.data = x; _________________ _________________

Free
(Multiple Choice)
4.9/5
(36)
Correct Answer:
Verified

D

Which statement about handling collisions in a hash table using the open addressing technique is correct?

(Multiple Choice)
4.9/5
(37)

In the textbook implementation, the LinkedListIterator class is a private inner class of the LinkedList class. Which of the following statements regarding this implementation is NOT correct?

(Multiple Choice)
4.8/5
(46)

When the buffer for an array list must be grown, a single reallocation operation takes ____ time.

(Multiple Choice)
4.8/5
(37)

Given the HashSet class implementation discussed in section 16.4 (partially shown below), select the statement needed to complete the clear method, which is designed to remove all elements from the set. public class HashSet { Private Node[] buckets; Private int currentSize; Public HashSet(int bucketsLength) { Buckets = new Node[bucketsLength]; CurrentSize = 0; } Public void clear() { For (int j = 0; j < buckets.length; ++j) { ___________________________ } CurrentSize = 0; } ).. }

(Multiple Choice)
4.7/5
(27)

What is the time required to iterate over all elements in a hash table of size n?

(Multiple Choice)
4.8/5
(41)

Given the partial LinkedList class declaration below, select a statement to complete the printFirst method, which is designed to display the contents of the first list element. public class LinkedList { Class Node { Public Object data; Public Node next; } Private Node first; ) . . Public void printFirst() { _____________________________ } }

(Multiple Choice)
4.8/5
(40)

Which of the following operations is least efficient in a LinkedList?

(Multiple Choice)
4.8/5
(36)

Which of the following actions must be taken to add a node X into the middle of a doubly-linked list? I Update the next reference in the node before the position where X will be placed II Update the previous reference in the node after the position where X will be placed III Update the list's first reference

(Multiple Choice)
4.9/5
(37)

Using the textbook's implementation of a linked list, which of the following statements about managing nodes within a linked list using an iterator is correct?

(Multiple Choice)
4.8/5
(35)

Using the textbook's implementation of a linked list, why is the LinkedListIterator inner class NOT declared as an inner static class?

(Multiple Choice)
4.8/5
(32)

Suppose we maintain an array A of n int values as follows: A[0] < A[1] < . . . < A[i] > A[i + 1] > A[i + 2] > . . . > A[n - 1] The ith element is the maximum in the array. What would be the lowest big-Oh notation for finding that element? Consider a variation of the binary search.

(Multiple Choice)
4.8/5
(35)

When implementing a queue as a singly-linked list, which of these statements is correct?

(Multiple Choice)
4.8/5
(38)

A stack can be implemented as a sequence of nodes in a linked list or an array list. Which of the following statements about this is correct?

(Multiple Choice)
4.8/5
(36)

Given the partial LinkedList and LinkedListIterator class declarations below, select an expression to complete the LinkedList get(index) method, which returns the element at the position indicated by index. public class LinkedList { ) . . Public ListIterator listIterator() { Return new LinkedListIterator(); } Class LinkedListIterator implements ListIterator { Private Node position; Private Node previous; Private boolean isAfterNext; Public LinkedListIterator() { ) . . } Public Object next() { ) . . } Public boolean hasNext() { ) . . } } Public Object get(int index) { ListIterator it = listIterator(); For (int i = 0; i < index; ++i) { It)next(); } Return ________________________ ; } }

(Multiple Choice)
4.7/5
(40)

Which of the following statements about hash tables is correct?

(Multiple Choice)
4.9/5
(34)

Consider the following code snippet: LinkedList<String> words = new LinkedList<String>(); Words.addFirst("123"); Words.addLast("456"); Words.addFirst("789"); System.out.print(words.removeLast()); System.out.print(words.removeFirst()); System.out.print(words.removeLast()); What does this code print?

(Multiple Choice)
4.7/5
(33)

Elements in a hash table are said to ____ when they have the same hash code value.

(Multiple Choice)
4.7/5
(48)
Showing 1 - 20 of 104
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)