Q.
Given below is the Node class to perform basic list operations and a Stack class with a no arg constructor. Select from the options the appropriate push() operation that can be included in the Stack class. Also ‘first’ is the top-of-the-stack.
class Node
{
protected Node next;
protected Object ele;
Node()
{
this(null,null);
}
Node(Object e,Node n)
{
ele=e;
next=n;
}
public void setNext(Node n)
{
next=n;
}
public void setEle(Object e)
{
ele=e;
}
public Node getNext()
{
return next;
}
public Object getEle()
{
return ele;
}
}
class Stack
{
Node first;
int size=0;
Stack()
{
first=null;
}
} Similar Questions
1. In a Stack the command to access nth element from the top of the stacks will be
2. Consider the usual algorithm for determining whether a sequence of parentheses is
balanced. What is the maximum number of parentheses that will appear on the stack
AT ANY ONE TIME when the algorithm analyzes: (()(())(()))
3. ………… is very useful in situation when data have to stored and then retrieved in reverse order.
4. Stack is used for
5. push() and pop() functions are found in
6. If locality is a concern, you can use _______ to traverse the graph.
7. Aposterior analysis are more accurate than apriori analysis because −
8. Prefix notation is also known as
9. In conversion from prefix to postfix using stack data-structure, if operators and operands are pushed and popped exactly once, then the run-time complexity is
10. In C programming, when we remove an item from bottom of the stack, then −
DATA STRUCTURE TOPICS