we must be resolved in C or C++; -
All programs must be developed in 3-file format (main.c,
example.c, example.h)
Problem 2:
Stacks 2.
The stack-like structure defines handling rules that cannot be
modified and these are commonly referred to as PUSH (push) and POP
(unstack) actions. Knowing this and using the development rules
already presented, do:
A) Write a function that takes any math
equation and returns two stacks. One containing the operands
stacked from left to right and the other containing the operators
following the same reading line.
B) Considering the function elaborated in part
(a), create a second function that presents the mathematical
operation in prefix and postfix notation. See some examples in the
table below:
C) Write a function that receives a stack P1
with 20 positions filled by random integers between 1 and 99. For
each number on the stack, use Euler's totient function to find the
co- primes for that number. Show them on the screen as a result of
your execution.
D) Create a function to perform the fibonacci
calculation for a value of N. However, use a stack to store
pre-results, using them for other calculations whenever possible.
To do so, consider keeping the calculation for the value of (n-1)
at the top of the stack. Create a way to identify which n-1 the
value was calculated for so as not to use incorrect values for long
calculations. Once this is done, answer: Can keeping calculations
in the stack help save computations? When would you be best
employed?
we must be resolved in C or C++; - All programs must be developed in 3-file format (main.c, example.c, example.h) Proble
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am