Question 1
Infix Expression: a+b*(c/d-e/f)/(g^h)-i
Question 2
Question 3
Question 4
What does the below function do in general?
void fun(Queue *Q)
{
Stack S; // Say it creates an empty stack S
// Run while Q is not empty
while (!isEmpty(Q))
{
// deQueue an item from Q and
// push the dequeued item to S
push(&S, deQueue(Q));
}
// Run while Stack S is not empty
while (!isEmpty(&S))
{
// Pop an item from S and enqueue
// the popped item to Q
enQueue(Q, pop(&S));
}
}
Question 5
Question 6
4, 6, 8, 9, _, 12, 14, 15, _, 18. . . .
Question 7
int main()
{
fork();
fork();
fork();
printf(\"Hello World\");
}
Question 8
Question 9
class Gfg
{
public:
int main(int s)
{
cout << s << \", \";
return 0;
}
int main(char *s)
{
cout << s << “, ”;
return 0;
}
int main(int s ,int m)
{
cout << s << \" \" << m;
return 0;
}
};
int main()
{
Gfg obj;
obj.main(3);
obj.main("Hello World!");
obj.main(9, 6);
return 0;
}
Question 10
// C++ function to evaluate a given postfix expression
int evaluatePostfix(char* exp)
{
// Create a stack of capacity equal to expression size
stack<int> st;
int i;
// Scan all characters one by one
for (i = 0; exp[i]; ++i)
{
// If the scanned character is an operand (number here),
// push it to the stack.
// The isdigit() function is used to check if a particular
// character in the given input string is a digit or not.
if (isdigit(exp[i]))
st.push(exp[i]); // Statement 1
// If the scanned character is an operator, pop two
// elements from stack apply the operator
else
{
int val1 = st.top(); // Statement 2
st.pop();
int val2 = st.top();
st.pop();
switch (exp[i]) // Statement 3
{
case \'+\': st.push(val2 + val1); break;
case \'-\': st.push(val2 - val1); break;
case \'*\': st.push(val2 * val1); break;
case \'/\': st.push(val2/val1); break;
}
}
}
return st.top();
}
There are 10 questions to complete.