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 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 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started