Question

In: Computer Science

1.Write a new expression similar to the following :     E1= a+b*c+(d*e+f)*g a)Convert your expression to...

1.Write a new expression similar to the following :

    E1= a+b*c+(d*e+f)*g

a)Convert your expression to postfix form.

b) Trace the algorithm Postfix on slide 38 using your expression.

2.Write a new expression similar to the following :

   E2= 6*((5+(2+3)*8)+3)

  1. Convert your expression to postfix form.
  2. Trace EvalPostfix algorithm on slide 53 using your expression.

    3.Write a program that receives some input values and

        a ) Displays these values by pointers, c)Displays their memory addresses.

Solutions

Expert Solution

1)  E1= a+b*c+(d*e+f)*g

a) Postfix form:

  abc*+de*f+g*+

b)

Symbol Postfix String Stack
a a
+ a +
b ab +
* ab +*
c abc +*
+ abc*+ +
( abc*+ +(
d abc*+d +(
* abc*+d +(*
e abc*+de +(*
+ abc*+de* +(+
f abc*+de*f +(+
) abc*+de*f+ +
* abc*+de*f+ +*
g abc*+de*f+g +*
abc*+de*f+g*+

2) E2= 6*((5+(2+3)*8)+3)

a) Postfix form:

6523+8*+3+*

b)

Symbol Postfix expression Stack
6 6
* 6 *
( 6 *(
( 6 *((
5 65 *((
+ 65 *((+
( 65 *((+(
2 652 *((+(
+ 652 *((+(+
3 6523 *((+(+
) 6523+ *((+
* 6523+ *((+*
8 6523+8 *((+*
) 6523+8*+ *(
+ 6523+8*+ *(+
3 6523+8*+3 *(+
) 6523+8*+3+ *
6523+8*+3+*

3)

//Program:

#include<stdio.h>
int main()
{
   int x, y; //declaring variables of integer type
   int *a, *b; //declaring pointers of integer type
   printf("Enter x: ");
   scanf("%d",&x); //Taking input from user
   printf("\nEnter y: ");
   scanf("%d",&y); //Taking input from user
   /*assigning pointers to variable*/
   a=&x;   
   b=&y;
   printf("\nValue of x: %d", *a); //printing value of x through pointer a
   printf("\nValue of y: %d", *b); //printing value of y through pointer b
   printf("\nMemory address of x: %p", a); //printing memory address of x
   printf("\nMemory address of y: %p", b); //printing memory address of y
   return 0;
}

//Output:


Related Solutions

(a) (f ∘ g)(3) (b) g(f(2)) (c) g(f(5)) (d) (f ∘ g)(−3) (e) (g ∘ f)(−1) (f) f(g(−1))
(a)    (f ∘ g)(3) (b)    g(f(2)) (c)    g(f(5)) (d)    (f ∘ g)(−3) (e)    (g ∘ f)(−1) (f)    f(g(−1))  
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 relational schema and set of functional dependencies. S(A,B,C,D,E,F,G) D → E E →...
Consider the following relational schema and set of functional dependencies. S(A,B,C,D,E,F,G) D → E E → B C → FG BE → AC Is the decomposition of S into S1(E,G,F) and S2(A,B,C,D,G) a lossless join decomposition? Choose one of the following queries as your answer: SELECT ’lossy’; SELECT ’lossless’;
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 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....
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...
For the following infix expression, build the corresponding expression tree. 1.1 a*b 1.2 a+b*c 1.3 a+b*c/d-e...
For the following infix expression, build the corresponding expression tree. 1.1 a*b 1.2 a+b*c 1.3 a+b*c/d-e Perform pre-order and post-order traversal of the above binary expression trees. What relationship exists among these scans and prefix and postfix notation for the expression?
A restaurant has dishes A, B, C, D, E, F and G The owners anticipate that...
A restaurant has dishes A, B, C, D, E, F and G The owners anticipate that dishes will be ordered in the following proportions: 30% (A), 15% (B), 20% (C), 5% (D), 8% (E), 12% (F) and 10% (G). The number of orders placed during the first two days of business was 75 (A), 60 (B), 50 (C), 14 (D), 20 (E), 40 (F), and 41 (G).    State and conduct the appropriate hypothesis test to determine whether there is...
Consider the relation R= {A, B, C, D, E, F, G, H} and the set of...
Consider the relation R= {A, B, C, D, E, F, G, H} and the set of functional dependencies: FD= {{B}—> {A}, {G}—> {D, H}, {C, H}—> {E}, {B, D}—> {F}, {D}—>{C}, {C}—> {G}} 1) Draw FD using the diagrammatic notation. 2) What are all candidate keys for R? 3) If delete {C}—>{G} and change {C, H}—> {E} to {C, H}—> {E, G}, what are all candidate keys for R
write a program that evaluates the following arithmetic expression: ((A+B)/C)*((D-A)+E). Assign test values to the variables...
write a program that evaluates the following arithmetic expression: ((A+B)/C)*((D-A)+E). Assign test values to the variables and display the resulting value.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT