Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ 2. (A). Show the contents of stack and que after the following algorithm is

ID: 3737298 • Letter: C

Question

C++

2. (A). Show the contents of stack and que after the following algorithm is executed. Input sequence: 10, 10, 1, 2, 3, 10, 10, 10,5, 6, 10 loop ( not end of input allocate (data and store its address in dataPtr) read data using dataPtr if data not 10) stack.push ( dataPtr else loop (not stack.isEmpty)) stack.pop (dataPtr) que.enqueue ( dataPtr end loop end if end loop (B). Explain why the below algorithm has a memory leak (C). Give the postfix form of the following expression either using a stack OR an expression tree. 2*(A+(3-B)%(4+C))-D

Explanation / Answer

Hi, as per the chegg guideline, please post ONE question per post.

I have answered Q4.

Please repost others in separate post.

Please rate my answer if it helped you!!

We can see that getGuess method calling recursively.

It is increasing value of "res" if both child is NOT null. So it is counting node with TWO child