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

The stack pop operation Question 9 options: removes from the stack the number of

ID: 3838068 • Letter: T

Question

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

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;

Question 11 (1 point)

The operation for removing an item from a queue is called

Question 11 options:

disqueue

enqueue

dequeue

extract

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;

Question 13 (1 point)

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

Question 13 options:

precursor

progenitor

ancestor

parent

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

Question 15 (1 point)

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

Question 15 options:

neighbor

descendant

neighbor

child

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.

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

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

Question 19 (1 point)

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

Question 19 options:

log N

2N

N

N2

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

Explanation / Answer

Solution:

9)

POP operation extracts only one item from the stack and returns it's value to the calling function.

Third one is the correct option.

10)

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

The above statement will provide the tell us if the stack is empty.

11)

dequeue.

12)

First statement is right.

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

13)

Ancestor

14)

In a binary tree there must be exactly one node with no predecessor and that node is root node.

15)

child or descendant

16)

0

17)

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

18)

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

19)

log n

I hope this helps. Don't forget to give a thumbs up if you like this.

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