Stack What are the three implementation methods of stack? .Evaluating postfix ex
ID: 3595195 • Letter: S
Question
Stack What are the three implementation methods of stack? .Evaluating postfix expressions, such as 2 34+56--* .Can we use stack to do base 10 to base 3 conversions? Which of the following characterizes a stack? a. FIFO b. LIFO c. FILO d. LILO Queue Which of the following characterizes a queue? a. FIFO b. LIFO c. FILO d. LILO Given the following queue operations on an empty existing queue called nameQueue nameQueue.enqueue(Sid) nameQueue.enqueue(Sal) nameQueue.enqueue(Sue) nameQueue.enqueue(Sam) nameQueue.dequeue( display (nameQueue.Front0) What name is displayed? a. Sid b. Sal c. Sue d. Sam Given the following queue operations on an empty existing queue called nameQueue nameQueue.enqueue(Bob) nameQueue.enqueue(Bill) nameQueue.enqueue(Bud) nameQueue.dequeue0 nameQueue.enqueue(Boo)Explanation / Answer
Stack
Three implementation methods of stack are push, pop and peep.
2 3 4 + 5 6 - - * is postfix… In infix equivalent expression is 2 * (3 + 4 - 5 - 6) So Ans is -8
Yes. We can use it to convert from base 10 to base 3 using following program: -
#include <iostream>
#include <stack>
using namespace std;
int main()
{
int n;
stack<int> Stack;
int tmp;
cout << "Put n:";
cin>> n;
cout << endl;
// Push to stack
while(n!=0)
{
Stack.push(n%3);
n = n/3;
}
// Get back and print out
while(Stack.size()!=0)
{
// get top element in the stack
tmp = Stack.top();
// pop it out from stack
Stack.pop();
cout << tmp ;
}
cout << endl;
system("pause");
return 0;
}
b) LIFO characterizes a stack
Queue
a)FIFO characterizes a queue.
Sal will be in front of the queue.
b)Bill,bud,boo
Scheduling, buffer and drill and practice problem all use queue except back-up key..
Stack is used for backspace key
Trees
Each node in binary tree has at most two children. Ans is d)
Maximum height of binary tree is n . So Ans is a)
Minimum height of binary tree is d) log2(n+1)
In a full complete binary tree of height 'h' there are 2(h+1) - 1 nodes.
Therefor 25 – 1 = 31 . So d) is the answer
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.