Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm really stuck with this question, I don't understand what to do. I have to do it in C++ or Java! Please help me ASAP

I'm really stuck with this question, I don't understand what to do. I have to do it in C++ or Java!

Please help me ASAP

image text in transcribedimage text in transcribed
You are enrolled in the Computer Organization and Architecture course at your university. You decide to write a program to help check your work by computing the output value of a combinational digital circuit, given its inputs. ED D?) Figure 1: An example of a combinational digital circuit. See the text for an explanation. Consider the circuit shown in Figure 1, which we use for illustration. This circuit has four inputs (letters A through D on the left), each of which is either true or false. There are four 'gates' each of which is one of three types: AND, OR, or NOT. Each gate produces either a true or false value, depending on its inputs. The last gate (the OR on the right) produces the output of the entire circuit. We can write these three types of gates in text by their equivalent logical operators: 2|: for AND, + for OR, and - for NOT. In what follows, we'll use the operators rather than gates to describe circuits. Here is how these operators work. Given an assignment of true (T) or false (F) for each input, the operators produce the truth value indicated in the following tables: Notice that AND and OR take two inputs, whereas NOT operates on only one input. Also, we use postx notation to write expressions involving operators (like A B * ), where the operator comes after its input(s) (just as how in Figure 1, each gate in the circuit diagram comes after its inputs). When we describe a valid circuit in postfix notation, we use the following syntax. 0 An uppercase letter (A through 2) is a valid circuit. In other words, an input alone (without any gates) is a valid circuit (which produces as output its own input value). 0 [f 421: and are valid circuits, then ' *' is a valid circuit that produces the AND of the outputs of the two subcircuits. o [f and are valid circuits, then ' +' is a valid circuit that produces the OR of the outputs of the two subcircuits. o [f is a valid circuit, then ' ' is a valid circuit that produces the NOT of 's output. Thus, one of the ways the circuit in Figure 1 could be described using postfix notation is as the string: AB*CD++ Given a truth value (T or F) for each of the inputs (A, B, c, and D in this example), their values propagate through the gates of the circuit, and the truth value produced by the last gate is the output of the circuit. For example, when the above circuit is given inputs A=T, B=F, c=T, D=F, the output of the circuit is F. Given an assignment to variables and a circuit description, your software should print the output of the circuit. Input The first line of the input consists of a single integer n, satisfying 1 s: n s 26 , denoting the number of input variables. Then follows a line with n spaceseparated characters. Each character is either 1' or F , with the ith such character indicating the truth value of the input that is labeled with the ith letter of the alphabet. The last line of input contains a circuit description, which obeys the syntax described above. Each circuit is valid, uses only the first I: letters of the alphabet as input labels, and contains at least 1 and at most 250 total non-space characters. Note that while each variable is provided only one truth value, a variable may appear multiple times in the circuit description and serve as input to more than one gate. Output Print a single character, the output of the circuit (either T or F), when evaluated using the given input values. Sample Input 1 Sample Output 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

=+4 Who participates in the buying?

Answered: 1 week ago