Question

In: Computer Science

Data Structure 17. Given: (e + f) / a – b * c Write out the...

Data Structure

17.

Given: (e + f) / a – b * c

Write out the postfix form

19. Make a prototype, including task, input and output, of compareLists that would take two lists of reference (ArrayList) and return a count of matching items (note, do NOT code the function)

20.Using the Stack operations, write a pseudocode routine, dupPos, that takes aStack for integers, checks to see if the top is positive. If positive, duplicate the top of the stack (i.e. pop a copy of that value onto the stack). If it is negative, pop it off.

21.Use the ListInterface operations only to create a makeEven routine in C++ that will take a list of integers (array or linked, your choice) as a reference. Use the list operations on the passed list to make all items that are odd into even values.

22.What is the main difference between an ADT List and the ADT Stack?

Solutions

Expert Solution

CONVERSION OF INFIX TO POSTFIX(reverse polish)

STEPS

STEP 1 : First Insert a opening parenthesis at the beginning and closing parenthesis
                at the end of the expression.

STEP 2 : Arrange the expression in the ARRAY.

STEP 3 : Scan every element from the array and if operand than store it in the
               POSTFIX and if operator than PUSH it into the STACK followed by
               STEP-4and STEP-5

STEP 4 : If the scanned operator having Less or Equal precedence than the existing operator than pop out the operators from the stack till a less precedence operator or opening parenthesis is found.

STEP 5 : If the scanned operator is a closing parenthesis than pop the operators from the STACK up to the Opening Parenthesis and omit them and poped operators will store in the POSTFIX.

STEP 6 : Repeat step-3, step-4, step-5 till all the elements are scanned from the array.

STEP 7 : Print the POSTFIX as the result.

    

Given the infix expression as : (e + f) / a – b * c

Array

Stack

Postfix

(

(

(

((

e

((

e

+

((+

e

f

((+

ef

)

(

ef+

/

(/

ef+

a

(/

ef+a

-

(-

ef+a/

b

(-

ef+a/b

*

(-*

ef+a/b

c

(-*

ef+a/bc

)

ef+a/bc*-

The Postfix expression will be : ef+a/bc*-


Related Solutions

#1 We are given the grammar rules A ➝ F B E B ➝ A C...
#1 We are given the grammar rules A ➝ F B E B ➝ A C These rules are only some of the rules of a larger grammar G, but we are not given the remaining rules of G. We are told that A is the start symbol of G and that the following holds: {ε, c, d} ⊆ FIRST(C) {ε, e} ⊆ FIRST(E) {ε, f, g} ⊆ FIRST(F) Recall that end of file is denoted EOF. The symbol ⊆...
Let A = {a, b, c, d} and B = {b, d, e}. Write out all...
Let A = {a, b, c, d} and B = {b, d, e}. Write out all of the elements of the following sets. (a) B ∩ ∅ (b) A ∪ B (c) (A ∩ B) × B (d) P(A\B) (e) {X ∈ P(A) | |X| ≤ 3}
Consider the cities B,C,D,E,F,G The costs of the possible roads between cities are given below: c(B,F)...
Consider the cities B,C,D,E,F,G The costs of the possible roads between cities are given below: c(B,F) = 11 c(B,G) = 10 c(C,G) = 8 c(D,E) = 12 c(D,F) = 13 c(E,F) = 9 c(E,G ) = 7 What is the minimum cost to build a road system that connects all the cities?
Given the following knowledge base: a <- b^c. b <- d^e. b <- g^e. c <-...
Given the following knowledge base: a <- b^c. b <- d^e. b <- g^e. c <- e. d. e. ƒ <- a^g. Which of the following would be the trace of resolved atoms assuming a bottoms-up proof procedure? Select one: a. {a,b,c,e,g} b. {a,b,c,e,d} c. {g,e,b,e,c,a} d. None of these options Constraint Satisfaction Problem (CSP) is consists of a set of _________________. Select one: a. Variables, heuristics, and solutions b. Variables, domains, and backtracking c. Variables, domains, and constraints d....
Given the following table of grades: Grades A B C D F Totals Males 17 8...
Given the following table of grades: Grades A B C D F Totals Males 17 8 14 11 3 53 Females 12 11 13 6 5 47 Totals 29 19 27 17 8 100 a. What is the probability that a randomly selected student got an A or B? b. What is the probability that if a student was female that they got a passing grade? c. What is the probability of a female student given that they got a...
Assume chromosome 1 has the following structure: A B centromere C D E F G What...
Assume chromosome 1 has the following structure: A B centromere C D E F G What could be the result of a pericentric inversion? Where should the chromosome break to obtain this aberration?
Given the operation times provided: JOB TIMES (minutes) A B C D E F Center 1...
Given the operation times provided: JOB TIMES (minutes) A B C D E F Center 1 20 16 43 60 35 42 Center 2 27 30 51 12 28 24 a. Develop a job sequence that minimizes idle time at the two work centers. The sequence is             (Click to select)  A-B-C-D-E-F  B-A-C-E-F-D  C-A-B-D-E-F  F-E-D-A-B-C  E-F-D-B-C-A  D-C-B-A-E-F  . b. Determine idle time of center 2, assuming no other activities are involved. Idle time             minutes
Seven people (A,B,C,D,E, F, and G) are seated in a row. Suppose A,B, and C are...
Seven people (A,B,C,D,E, F, and G) are seated in a row. Suppose A,B, and C are freshmen, D and E are sophomores and F and G are juniors. How many arrangements are possible if: (a) D and F must sit together? (b) A and C must not sit together? (c) All freshmen must sit together? (d) All freshmen must sit together, all sophomores must sit together, and all juniors must sit together? (e) Exactly two people sit between A and...
If there are 7 total notes C, D, E, F, G, A, and B and if...
If there are 7 total notes C, D, E, F, G, A, and B and if a five-note melody is selected at random (so that all melodies counted in part (a) are equally likely to be chosen), what is the probability that the melody will include exactly two “A” notes, but no other repeated notes? (A few allowable examples: AACEG, ACAEG, DFACA, EAABC, etc.)
Consider the following bivariate data. Point A B C D E F G H I J...
Consider the following bivariate data. Point A B C D E F G H I J x 0 1 1 2 3 4 5 6 6 7 y 5 5 6 5 4 3 2 0 1 1 (a) Construct a scatter diagram of the given bivariate data. (Do this on paper. Your instructor may ask you to turn in this work.) (b) Calculate the covariance. (Give your answer correct to two decimal places.) (c) Calculate sx and sy. (Give...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT