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

. Suppose that a client performs an intermixed sequence of (stack) push and pop

ID: 3872969 • Letter: #

Question

. Suppose that a client performs an intermixed sequence of (stack) push and pop operations. The push operations put the integers 0 through 9 in order onto the stack; the pop operations print out the return value. Which of the following sequence(s) could not occur?   ( May be more than one sequence.)

4 3 2 1 0 9 8 7 6 5

2 5 6 7 4 8 9 3 1 0

4 6 8 7 5 3 2 9 0 1

4 3 2 1 0 5 6 7 8 9

1 2 3 4 5 6 7 8 9 0

0 4 6 5 3 8 1 7 2 9

The  Best characterization is :

3. For a binary tree (not necessary a BST), we are given the following information

       preorder traversal sequence :    D F I G T A L M X

        postorder traversal sequence :    I T G F L X M A D

Can you construct and draw the tree from the given ? If so, draw the tree. Is the tree unique? If the tree is not unique, how many possible binary tree with the given pair of traversal sequences?

4. Characterize, using the big-Oh notation, the worst-case running time of

4. 1.          Alg Ex1(A):

4.2     Alg Ex2(A):

4.3     Alg Ex3(A) :

for i

Explanation / Answer

1)

4 3 2 1 0 9 8 7 6 5 => Push from 0 to 4, then pop all, then again push from 5 to 9, pop al
2 5 6 7 4 8 9 3 1 0 => Push 0, 1, 2, pop, push 3, 4, 5, pop, push 6, pop, push 7, pop, pop, push 8, pop, push 9, pop, pop, pop, pop

4 6 8 7 5 3 2 9 0 1 => push 0, 1, 2, 3, 4, pop, push 5, 6, pop, push 7, 8, pop, pop, pop, pop, pop, push 9, pop,
On popping 1 occur before 0, so not possible

4 3 2 1 0 5 6 7 8 9 => push 0, 1, 2, 3, 4, pop, pop, pop, pop, pop, push 5,pop, push 6, pop, push 7, pop, push 8, pop, push 9, pop

1 2 3 4 5 6 7 8 9 0 => push 0, 1, pop,push 2, pop,push 3, pop,push 4, pop,push 5, pop,push 6, pop, push 7, pop, push 8, pop,push 9, pop, pop

0 4 6 5 3 8 1 7 2 9 => push 0, pop, push 1,2,3,4, pop, push 5, push 6, pop, pop, pop, push 7, push 8, pop,
Now the content of stack will be 1, 2, 7.. So 1 can not be printed before 7


2) Multiply nlogn and (n^2-1), the major term will be n^3logn, Option C

Answering your first 2 questions, as the questions are completely unrelated and from different topics. I request you to please post single question in a thread, so that it helps us in explaining the things better to you. Hope you understand! Thank-you.