Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A Node class for a linked list that can hold elements of type Object can be decl

ID: 3838379 • Letter: A

Question

A Node class for a linked list that can hold elements of type Object can be declared to have fields

Question 2 options:

Object element; Node next;

Object element; next element;

Object element;

Object element; Node *next;

Save

Question 3 (1 point)

In a linked list, the predecessor of a node X

Question 3 options:

is the node that comes after X

is undefined if X is the first node, otherwise it is the node whose index is one less than the index of X

is the first node in the list

is the node that is just before X

Save

Question 4 (2 points)

A list method E remove(int index) designed to remove and return the element at the given index should throwIndexOutOfBoundsException when

Question 4 options:

the index is 0

the index is negative, or is greater than, or equal to, the size of the list

the index is negative, and greater than the size of the list

the index is negative, or is greater than the size of the list

Save

Question 5 (1 point)

A doubly linked list makes it easy to

Question 5 options:

to create a second copy of the linked list

skip two nodes at a time when moving backward through the list

skip two nodes at a time when moving forward through the list

move from any node to its successor, and from any node to its predecessor

Save

Question 6 (1 point)

The stack push operation

Question 6 options:

removes and returns an item from the stack

returns the item at the top of the stack, but does not remove it

adds a single item to the stack

is normally implemented through a hash set

Save

Question 7 (1 point)

The stack peek operation

Question 7 options:

checks a stack to see if there are any elements in it

returns the item at the top of the stack, but does not remove it

removes and returns an item from the stack

adds a single item to the stack

Save

Question 8 (1 point)

The stack empty operation

Question 8 options:

checks to see if there is at least one item on the stack

destroys the stack and creates a new empty one in its place

removes all elements from the stack

None of the above

Save

Question 9 (1 point)

The stack pop operation

Question 9 options:

removes from the stack the number of elements specified by its integer parameter

removes all items currently on the stack

extracts one element from the stack and returns it

does not exist: There is no such stack operation

Save

Question 10 (2 points)

Consider a class that uses the following variables to implement an array-based stack:
String [ ] s = new String[100];
int top = 0;
The boolean method to check for an empty stack can be written as:

Question 10 options:

if (s == null)
return true;
else
return false;

if (s.length == 0)
return true;
else
return false;

return top;

if (top == 0)
return true;
else
return false;

Save

Question 11 (1 point)

The operation for removing an item from a queue is called

Question 11 options:

disqueue

enqueue

dequeue

extract

Save

Question 12 (1 point)

A queue based on a linked list uses the following code

class Node{
String element;
Node next;
Node (String el, Node n)
{
element = el;
next = n;
}
}
Node front = null, rear = null;

What is the right code for String remove() operation? Such an operation removes and returns an element from the queue.

Question 12 options:

if (front == null)
throw new RuntimeException("Empty");
String temp = front.element;
front = front.next;
if (front == null)
front = rear;
return temp;

if (rear== null)
throw new RuntimeException("Empty");
String temp = rear.element;
rear = rear.next;
if (front == null)
rear = null;
return temp;

if (front == null)
throw new RuntimeException("Empty");
String temp = front.element;
front = front.next;
if (front == null)
rear = null;
return temp;

if (front == rear)
throw new RuntimeException("Empty");
String temp = front.element;
front = front.next;
if (front == null)
rear = null;
return temp;

Save

Question 13 (1 point)

The predecessor of a node in a binary tree is called its

Question 13 options:

precursor

progenitor

ancestor

parent

Save

Question 14 (1 point)

In a binary tree,

Question 14 options:

there must be exactly one node with no predecessor

there may be at most two nodes with no predecessor

there must be at most one node with no predecessor

there may be any number of nodes with no predecessor

Save

Question 15 (1 point)

The successor of a node in a binary tree is called its

Question 15 options:

neighbor

descendant

neighbor

child

Save

Question 16 (1 point)

An empty binary tree has height

Question 16 options:

-1

1

0

None of the above: the height of an empty binary tree is not defined.

Save

Question 17 (2 points)

An AVL tree is

Question 17 options:

a priority queue with a balance condition

a binary search tree in which the heights of the subtrees at each node differ by at most one

a binary tree in which the left and right subtree have heights that differ by at most one

a binary tree in which each child is greater than its parent

Save

Question 18 (2 points)

A priority queue is

Question 18 options:

a binary search tree in which the heights of the subtrees at each node differ by at most one

is an AVL tree in which the root is the minimum element

is a collection that allows elements to be added, but only allows the minimum element to be removed

is a binary search tree that stores elements according to their natural order

Save

Question 19 (1 point)

A complete binary tree with N nodes has depth approximately equal to

Question 19 options:

log N

2N

N

N2

Save

Question 20 (2 points)

The concrete classes that implement the List interface are

Question 20 options:

AbstractList, AbstractSequentialList, and List

LinkedList, ArrayList, and Vector

LinkedList, ArrayList, and AbstractList

None of the above

Save

Question 21 (1 point)

Comparator

Question 21 options:

specifies two methods, compare and equals

specifies two methods, compare and compareTo

specifies a single method, compareTo

specifies three methods, compareTo, compare, and equals

Save

Question 22 (1 point)

A TreeSet

Question 22 options:

is like a Set that allows elements to be retrieved according to their natural order, or according to an order specified by aComparator

is a Set that allows elements to be retrieved in the order added

is like a Set, only it is faster

is a Set that organizes its elements in a tree according to the inheritance hierarchy of the elements

Save

Question 23 (1 point)

A HashMap

Question 23 options:

uses hash codes to store keys

is a subclass of HashSet that implements the Map interface

is a subclass of Map that implements the HashCode interface

None of the above

Save

Question 24 (1 point)

A LinkedHashMap

Question 24 options:

provides an iterator that can be used to retrieve its elements

is an unordered collection that provides no control over the order of retrieval of stored elements

can be set up to maintain its keys in insert or access order

None of the above

Save

Question 25 (1 point)

Collections

Question 25 options:

is a class that contains static methods for working with collections

is the interface from which all collection interfaces are derived

is the superclass of all abstract and concrete collection classes

None of the above

Save

Object element; Node next;

Object element; next element;

Object element;

Object element; Node *next;

Explanation / Answer

Question 2:

A Node class for a linked list that can hold elements of type Object can be declared to have fields

Object element; Node *next;

Question 3:

In a linked list, the predecessor of a node X

is the first node in the list

Question 4:

A list method E remove(int index) designed to remove and return the element at the given index should throwIndexOutOfBoundsException when

the index is negative, or is greater than the size of the list

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote