Assignment

1. 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.)

a) 4 3 2 1 0 9 8 7 6 5

b) 2 5 6 7 4 8 9 3 1 0

c) 4 6 8 7 5 3 2 9 0 1

d) 4 3 2 1 0 5 6 7 8 9

e) 1 2 3 4 5 6 7 8 9 0

f) 0 4 6 5 3 8 1 7 2 9

2. Let A be a given array of n integers.Characterize, using the big-Oh notation, the worst-case running time of

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):

Input: array A storing n > 0 integers.

Output : The sum of the elements in A.

s <– A[0]

for i <– 1 to n-1 do

s <– s + A[i]

return s

4.2 Alg Ex2(A):

Input: array A storing n > 0 integers.

Output : The sum of the elements at even cells in A.

s <– A[0]

for i <– 2 to n-1 by increments of 2 do

s <– s + A[i]

return s

4.3Alg Ex3(A) :

Input: array A storing n > 0 integers.

Output : The sum of the prefix sums in A.

s <– 0

for i <– 0 to n-1 do

s <– s + A[0]

for j <– 1 to i do

s <– s + A[j]

return s

4.4AlgEx4(A) :

Input: array A storing n > 0 integers.

Output : The sum of the prefix sums in A.

s <– A[0]

t <– s

for i <– 1 to n-1 do

s <– s + A[i]

t <– t + s

return s

4.5AlgEx5(A,B) :

Input: Arrays A and B each storing n > 0 integers.

Output : The number of elements in B equal to the sum of prefix sums in A.

c <– 0

for i <– 0 to n-1 do

s <– 0

for j <– 0 to n-1 do

s <– s + A[0]

for k <– 1 to j do

s <– s + A[k]

if B[i] = s then

c <– c + 1

return c

**For a custom paper on the above topic, place your order now!**

**What We Offer:**

**• On-time delivery guarantee**

**• PhD-level writers**

**• Automatic plagiarism check**

**• 100% money-back guarantee**

**• 100% Privacy and Confidentiality**

**• High Quality custom-written papers **

## Is this question part of your Assignment?

### We can help

Our aim is to help you get A^{+} grades on your Coursework.

We handle assignments in a multiplicity of subject areas including **Admission Essays**, **General Essays**, **Case Studies**, **Coursework**, **Dissertations**, **Editing**, **Research Papers**, and **Research proposals**