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

TEST COMPONENTS: Stack , Queues & Trees [2.5 + 2.5 Marks] [2.5 + 2.5 Marks] [5 M

ID: 3623902 • Letter: T

Question

TEST COMPONENTS: Stack , Queues & Trees

[2.5 + 2.5 Marks]

[2.5 + 2.5 Marks]

                 

[5 Marks]

Q1:      42   30   41   31   14   20   25 14   10   11   12   15

Q2:      1    4    5   4   10   13

1       Q3 = createQueue()

2       count = 0

3       loop ( not empty Q1 and not empty Q2 )

1       count = count + 1

2       dequeue (Q1, x)

3       dequeue (Q2, y)

4       if ( y equal count )

1       enqueue (Q3, x)

Question 4 (Trees)

[2 + 4 Marks]

Pretorder: JCBADEFIGH

Inorder: ABCEDFJGIH

                                                                                                                  [8 Marks]

a ( b ( c ( e ( f g ) ) h )

                                                                                                            [4 Marks]

224562,     137456,           214562

140145,     214576,           162145

144467,     199645,           234534

                                                                                                            [10 Marks]



Explanation / Answer

{

x <- v;

while(left(x) < >NULL)

x<-left(x);

return x;