The code for implementing the String peek() operation is
A stack based on a linked list is based on the following code
```
class Node
{
String element;
Node next;
Node(String el, Node n)
{
element = el;
next = n;
}
}
Node top = null;
```
A)
String temp = top.element;
if (temp != null)
return temp;
else
throw new RuntimeException("Empty Stack");
B)
if (top != null)
return top.element;
else
return top.next;
C)
if (top != null)
return top.element
else
throw new RuntimeException("Empty Stack");
D)
if (top != null)
return top;
C)
if (top != null)
return top.element
else
throw new RuntimeException("Empty Stack");
You might also like to view...
Explain why reversing the order of the lines ‘R-deliver m’ and ‘if (q p ? ) then B-multicast(g, m); end if’ in Figure 11.10makes the algorithm no longer satisfy uniform agreement. Does the reliable multicast algorithm based on IP multicast satisfy uniform agreement?
What will be an ideal response?
What are the main categories of Intune policies?
What will be an ideal response?
Which of the following programming languages does NOT support true multiple inheritance? 1. Python
a. Python b. C++ c. PHP d. Smalltalk
The information offered through WAi-ARIA is developed by a part of the ____.
A. NSF B. W3C C. Internet2 Initiative D. Internet Accessibility Foundation