TCP/IP IT 5012 Sample Question

TCP/IP
IT 5012
Sample Question
for
Second semester
1. Discuss how to make routing efficient and keep routing table small using the network
portion of a destination address.
(20 marks)
2. Describe the IP algorithm used to forward datagram.
(10 marks)
3. How to make routes using IP address between source and destination when you want to sent
a datagram.
(20 marks)
4. When a datagram arrive at a best, how to handle it.
(20 marks)
5. When encounter an error how to report the error to the original source and how to correct it.
(20 marks)
6. Describe about Testing destination reach ability and status.
(10 marks)
7. When the routers make routing changes. Explain about it completely.
(20 marks)
8. Explain the discovering router before it can send datagrams to destinations an other
networks.
(20 marks)
9. Describe the protocol which provides ports used to distinguish among multiple programs
executing on a single machine, completely.
10. Describe the format of UPD messages.
(10 marks)
(10 marks)
11. How a UPD datagram encapsulate in an IP datagram for transmission across an internet.
And also describe the conceptual layering of UDP.
12. Discuss about UDP Multiplexing , Demultiplexing , and Ports.
(20 marks)
(10 marks)
13. How many features that can characterize the interface between application programs and
the TCP/IP reliable delivery service . And also explain those features .
(20 marks)
14. Show how the simplest positive acknowledgement protocol transfers data and also show
Timeout and retransmission that occurs when a packet is lost.
(10 marks)
15. Describe the format of a TCP segment . Explain it completely.
(10 marks)
16. Discuss the Acknowledgements and Retransmission.
(10 marks)
17. How to establishing a TCP Connection. Explain it.
(10 marks)
18. How to closing a TCP Connection. Explain it briefly.
(10 marks)
19. Draw the diagram of the TCP finite State Machine and explain about it.
(20 marks)
Introduction to Computer System
IT 5012
Sample Answer and Question
for
Second semester
1. Discuss how to make routing efficient and keep routing table small using the network
portion of a destination address.
(20 Marks)
Solution:
Using the network portion of a destination address instead of the complete host address
makes routing efficient and keeps routing table small. More important, it helps hide
information, keeping the details of specific hosts confined to the local environment in
which those hosts operate. Typically, a routing table contains pairs (N,R), where N is the
IP address of the destination network, and R is the IP address of the “next” router along the
path to the network N. Router R is called next hop, and the idea of using a routing table to
store a next hop for each destination is called next-hop routing. Thus, the routing table in a
router R only specifies one step along the path from R to a destination network- the router
does not know the complete path to a destination.
It is important to understand that each entry in a routing table points to a router that can be
reached across a single network. That is, all router listed in machine M’s routing table
must lie on networks to which M connects directly. When a datagram is ready to leave M,
IP software locates the destination IP address and extracts the network portion. M then
uses the network portion to make a routing decision, selecting a router that can be reached
directly.
The example internet consists of four networks connected by three routers. In the figure,
the routing table gives the routes that router R uses. Because R connects directly to
networks 20.0.0.0 and 30.0.0.0, it can use direct delivery to send a host on either of those
networks. Given a datagram destined for a host on the network 40.0.0.0, R routes it to the
address of router S, 30.0.0.7. S will then deliver the datagram directly. R can reach
address 30.0.0.7 because both R and S attach directly to network 30.0.0.0.
To hide information, keep routing tables small, and make routing decisions efficient, IP
routing software only keeps information about destination network addresses, not about
individual host addresses.
TO REACH HOSTS
ON NETWORK
ROUTE TO THIS
ADDRESS
20.0.0.0
DELIVER DIRECTLY
30.0.0.0
DELIVER DIRECTLY
10.0.0.0
20.0.0.5
40.0.0.0
30.0.0.7
(b)
Figure (a) An example internet with 4 networks and 3 routers and (b) the routing table in R
2. Describe the IP algorithm used to forward datagram.
Solution:
The IP algorithm used to forward datagram becomes:
(10 marks)
3. How to make routes using IP address between source and destination when you want to sent
a datagram.
(20 marks)
Solution:
It is important to understand that except for decrementing the time to live and re-computing
the checksum, IP routing does not alter the original datagram. In particular, the datagram
source and destination addresses remain unaltered; they always specify the IP address of
the original source and the IP address of the ultimate destination. When IP executes the
routing algorithm, it selects a new IP address, the IP address of the machine to which the
datagram should be sent next. The new address is most likely the address of a router.
However, if the datagram can be delivered directly, the new address is the same as the
address of the ultimate destination.
The IP address selected by the IP routing algorithms is known as the next-hop address
because it tells where the datagram must be sent next.
After executing the routing
algorithm, IP passes the datagram and the next hop address to the network interface
software responsible for the physical network over which the datagram must be sent. The
network interface software binds the next hop address to a physical address, forms a frame
using that physical address, places the datagram in the data portion of the frame, and send
the results. After using the next hop address to find a physical address, the network
interface software discards the next hop address.
IP dutifully extracts the destination address in each datagram and uses the routing table to
produce a next hop address. It then passes the datagram and next hop address to the
network interface, which re-computes the binding to a physical address. Figure shows that
there are two important reasons.
First, the routing table provides an especially clean interface between IP software that
routes datagram and high level software that manipulates routes.
To debug routing
problems, network manager often needs to examine the routing tables. Second, the whole
point of the Internet Protocol is to build an abstraction that hides the details of underlying
networks. Figure shows the address boundary. We will see that observing the boundary
also helps keep the implementation of remaining TCP/IP protocols easy to understand, test
and modify.
Figure IP software and the routing tables it uses resides above the address boundary.
4. When a datagram arrive at a best, how to handle it.
(20 marks)
Solution:
When an IP datagram arrives at a host, the network interface software delivers it to the IP
module for processing. If the datagram’s destination address matches the host’s IP address,
IP software on the host accepts the datagram and passes it to the appropriate higher-level
protocol software for further processing. If the destination IP address does not match, a
host is required to discard the datagram.
Unlike hosts, routers perform forwarding. When an IP datagram arrives at a router, it is
delivered to the IP software. Again, two cases arrive: the datagram could have reached its
final destination, or it may need to travel further. As with the host, if the datagram
destination IP address matches the router’s own IP address, the IP software passes the
datagram to higher level protocol software for processing. If the datagram has not reached
its final destination, IP routes the datagram using the standard algorithm and the
information in the local routing algorithm.
Even a host may have multiple physical connections, each with its own IP address. When
an IP datagram arrives, the machine must compare the destination internet address to the IP
address for each of its network connections. If any match, it keeps the datagram and
processes it. A machine must also accept datagrams that were broadcast on the physical
network. If the address does not match any of the local machine’s addresses, IP decrement
the Time-To-Live field in the datagram header, discarding the datagram if the count
reaches zero, or computing a new checksum and routing the datagram if the count remains
positive.
While using a host as a router is not usually a good idea, if one chooses to use that
arrangement, the host must be configured to route datagrams just as a router does.
There are four reasons why a host not designated to serve as a router should refrain from
performing any router functions. First, when such a host receives a datagram intended for
some other machine, something has gone wrong with internet addressing, routing, or
delivery. The problem may not be revealed if the host takes corrective action by routing
the datagram. Second, routing will cause unnecessary network traffic (and may steal CPU
time from legitimate uses of the host). Third, simple errors can cause chaos. Routers do
more than merely route traffic. Routers use a special protocol to report errors, while hosts
do not (again, to avoid having multiple error reports bombard a source). Routers also
propagate routing information to ensure that their routing tables are consistent. If hosts
route datagrams without participating fully in all router functions, unexpected anomalies
can arise.
5. When encounter an error how to report the error to the original source and how to correct
it.
(20 marks)
Solution:
Technically, ICMP is an error reporting mechanism. It provides a way for routers that
encounter an error to report to the original source.
When a datagram causes an error, ICMP can only report the error condition back to the
original source of the datagram; the source must relate the error to an individual application
program or take other action to correct the problem.
6. Describe about Testing destination reachability and status.
(10 marks)
Solution:
TCP/IP protocol provides facilities to help network managers or users identify network
problems. One of the most frequently used debugging tools invokes the ICMP echo
request and echo reply messages. A host or router sends an ICMP echo request message to
a specified destination. Any machine that receives an echo request formulates an echo
reply and returns it to an original sender. The request contains an operational data area; the
reply contains a copy of the data sent in the request. The echo request and associated can
be used to test whether the destination is reachable and responding.
The command users invoke to send ICMP echo requests is named ping. Sophisticated
versions of ping send a series of ICMP echo request, capture responses, and provide
statistics about datagram loss. They allow the user to specify the length of the data being
sent and the interval between requests. Less sophisticated versions merely send one ICMP
echo request and await a reply.
7. When the routers make routing changes. Explain about it completely. (20marks)
Solution:
Internet routing tables usually remain static over long periods of time. If the networks
topology changes, routing tables in a router or host may become incorrect. A change can
be temporary (e.g., when hardware needs to be repaired) or permanent (e.g., when a new
network is added to the internet). Routers are assumed to know correct routes; hosts begin
with minimal routing information and learn new routes from routers.
When a router detects a host using a non-optimal route, it sends the host an ICMP
message, called a redirect, requesting that the host change its route. The router also
forwards the original datagram onto its destination.
The advantage of the ICMP redirect scheme is simplicity: it allows a host to boot knowing
the address of only one router on the local network. The initial router returns ICMP
redirect messages whenever a host sends a datagram for which there is a better route. The
host routing table remains small but still contains optimal routes for all destinations in use.
In the figure, assume source S sends a datagram to destination D. Assume that router R1
incorrectly routes the datagram through router R2 instead of through router R4 (i.e., R1
incorrectly chooses a longer path than necessary). When router R5 receives the datagram, it
cannot send an ICMP redirect message to R1 because it does not know R1’s address.
In addition to the requisite TYPE, CODE, and CHECKSUM fields, each redirect message
contains a 32-bits ROUTER INTERNET ADDRESS field and an INTERNET HEADER
field.
The ROUTER INTERNET ADDRESS field contains the address of a router.
The
INTERNET HEADER field contains the IP header plus the next 64 bits of the datagram
that triggered the message. The CODE field of an ICMP redirect message further specifies
how to interpret the destination address, based on values assigned as follows:
Code Value
Meaning
0
Redirect datagrams for the Net (now obsolete)
1
Redirect datagrams for the Host
2
Redirect datagrams for the Type of Service and Net
3
Redirect datagrams for the Type of Service and Host
Figure: ICMP redirect messages do not provide routing changes among routers. In this
example, router R5 cannot redirect R1 to use the shorter path for datagrams from S to D
Figure: ICMP redirect message format
8. Explain the discovering router before it can send datagrams to destinations an other
networks.
(20 marks)
Solution:
After a host boots, it must learn the address of at least one router on the local network
before it can send datagrams to destinations on other networks. ICMP supports a router
discovery scheme that allows a host to discover a router address.
ICMP router discovery is not the only mechanism a host can use to find a router address.
The ICMP router discovery scheme helps in two ways. First, instead of providing a
statically configured router address via a bootstrap protocol, the scheme allows a host to
obtain information directly from the router itself. Second, the mechanism uses a soft state
technique with timers to prevent hosts from retaining a route after a router crashes – router
advertise their information periodically, and host discard a route if the timer for a route
expires.
Besides the TYPE, CODE, and CHECKSUM fields, the message contains a field labeled
NUM ADDRS that specifies the number of address entries which follow (often 1), an
ADDR SIZE field that specifies the size of an address in 32-bit units (1 for IPv4
addresses), and a LIFETIME field that specifies the time in seconds a host may use the
advertised address(es).
The remainder of the message consists of NUM ADDRS pairs of fields, where each pair
contains a ROUTER ADDRESS and an integer PRECEDENCE LEVEL for the route. Of
course, a host must never send a router advertisement message.
Fig ICMP router advertisement message format used with IPv4
9. Describe the protocol which provides ports used to distinguish among multiple
programs executing on a single machine, completely.
(10 marks)
Solution:
UDP provides protocol ports used to distinguish among multiple programs executing on a
single machine. That is, in addition to the data sent, each UDP message contains both a
destination port number and a source port number, making it possible for the UDP software
at the destination to deliver the message to the correct recipient and for the recipient to send
a reply.
The User Datagram Protocol (UDP) provides an unreliable connectionless delivery service
using IP to transport messages between machines. It uses IP to carry messages, but adds
the ability to distinguish among multiple destinations within a given host computer.
10. Describe the format of UPD messages.
(10 marks)
Solution:
Each UDP message is called a user datagram. A user datagram consists of two parts: a
UDP header and a UDP data area. The header is divided into four 16-bit fields that specify
the port from which the message was sent, the port to which the message is destined, the
message length, and a UDP checksum.
The SOURCE PORT and DESTINATION PORT fields contain the 16-bit UDP protocol
port numbers. The LENGTH field contains a count of octets in the UDP header and the
user data. Thus, the minimum value for LENGTH is eight, the length of the header alone.
The UDP checksums is optional and need not be used at all; a value of zero in the
CHECKSUM field means that the checksum has not been computed. Thus, the UDP
checksum provides the only way to guarantee that data has arrived intact and should be
used. When the computed checksum is zero, UDP uses the representation with all bits set
to one.
Figure: The format of fields in a UDP datagram
11. How a UPD datagram encapsulate in an IP datagram for transmission across an
internet. And also describe the conceptual layering of UDP.
(20 marks)
Solution:
Layering UDP above IP means that a complete UDP message, including the UDP header
and data, is encapsulated in an IP datagram as it travels across an internet.
The IP layer prepends a header to what it receives from UDP. Finally, the network
interface layer embeds the datagram in a frame before sending it from one machine to
another.
A packet arrives at the lowest layer of network software and begins its ascent through
successively higher layers. Each layer removes one header before passing the message on,
so that by the time the highest level passes data to the receiving process, all headers have
been removed.
The IP layer is responsible only for transferring data between a pair of hosts on an internet,
while the UDP layer is responsible only for differentiating among multiple sources or
destination within one host.
Figure: The Conceptual Layering of UDP between application programs and IP
Figure: A UDP datagram is encapsulated in an IP datagram for transmission across an
internet. The datagram is further encapsulated in a frame each time it travels across a
single network
.12. Discuss about UDP Multiplexing , Demultiplexing , and Ports. (10 marks)
Solution:
Conceptually, all multiplexing and demultiplexing between UDP software and application
programs occur through the port mechanism.
While processing input, UDP accepts
incoming datagrams from the IP software and demultiplexes based on the UDP destination
port.
A UDP port is as a queue. When UDP receives a datagram, it checks to see that the
destination port number matches one of the ports currently in use. If not, it sends an ICMP
port unreachable error message and discards the datagram. If a match is found, UDP
enqueues the new datagram at the port where an application program can access it. Of
course, an error occurs if the port is full, and UDP discards the incoming datagram.
Figure Example of demultiplexing one layer above IP
13. How many features that can characterize the interface between application programs
and the TCP/IP reliable delivery service . And also explain those features .
(20 marks)
Solution:
The interface between the application programs and TCP/IP reliable delivery service can be
characterized by 5 features:
Stream Orientation.
When two application programs (user processes) transfer large
volumes of data, we think of data as a stream of bits, divided into 8-bit octets, which are
informally called bytes. The stream delivery service on the destination machine passes to
the receiver exactly the same sequence of octets that the sender passes to it on the source
machine.
Virtual Circuit Connection.
One application places a “call” which must be accepted by
the other. Protocol software module in the two operating systems communicate by sending
messages across an internet, verifying that the transfer is authorized, and that both sides are
ready. Once all details have been settled, the protocol modules inform the application
programs that a connection has been established and that transfer can begin.
Buffered Transfer.
Application programs send a data stream across the virtual circuit
by repeatedly passing data octets to the protocol software. When transferring data, each
application uses whatever size pieces it find convenient, which can be as small as a single
octet. At the receiving end, the protocol software delivers octets from the data stream in
exactly the same order they were sent, making them available to the receiving application
program as soon as they have been received and verified.
For those application where data should be delivered even though it does not fill a buffer,
the stream service provides a push mechanism that application use to force a transfer. At
the sending side, a push forces protocol software to transfer all data that has been generated
without waiting to fill a buffer. The push function only guarantees that all data will be
transferred; it does not provides record boundaries.
Unstructured Stream.
It is important to understand that the TCP/IP stream service does
not honor structure data streams. Applications programs using the stream service must
understand stream content and agree on stream format before they initiate a connection.
Full Duplex Connection.
Connections provided by the TCP/IP stream service allow
concurrent transfer in both directions. Such connections are called full duplex. From the
point of view of an application process, a full duplex connection consists of two
independents streams flowing in opposite directions, with no apparent interaction. The
advantage of a full duplex connection is that the underlying protocol software can send
control information for one stream back to the source in datagrams carrying data in the
opposite direction. Such piggybacking reduces network traffic.
14 . Show how the simplest positive acknowledgement protocol transfers data and also
show Timeout and retransmission that occurs when a packet is lost.
Solution:
(10 marks)
A protocol using positive acknowledgement with retransmission in which the sender awaits
an acknowledgement for each packet sent. Vertical distance down the figure represents
increasing time and diagonal lines across the middle represent network packet
transmission.
Timeout and retransmission occurs when a packet is lost. The dotted lines show the time
that would be taken by the transmission of a packet and its acknowledgement, if the packet
was not lost.
15. Describe the format of a TCP segment . Explain it completely.
Solution:
(10 marks)
The unit of transfer between the TCP software on two machines id called a segment.
Segments are exchanged to establish connections, transfer data, send acknowledgements,
advertise window sizes, and close connections.
Each segment is divided into two parts, a header followed by data. The header, known as
TCP header, carries the expected identification and control information. Fields SOURCE
PORT and DESTINATION PORT contain the TCP port numbers that identify the
application programs at the ends of the connection. The SEQUENCE NUMBER field
identifies the position in the sender’s byte stream of the data in the segment.
The
ACKNOWLEDGE NUMBER field identifies the number of the octets that the source
expects to receive next.
The HLEN field contains an integer that specifies the length of the segment header
measured in 32-bit multiples. The OPTIONS field varies in length, depending on which
options have been included. The 6-bit field marked RESERVED is reserved for future use.
TCP software uses the 6-bit field labeled CODE BITS to determine the purpose and
contents of the segment.
The WINDOW field contains a 16-bit unsigned integer in
network-standard byte order.
Figure The format of TCP segment with a TCP header followed by data.
16. Discuss the Acknowledgements and Retransmission.
(10 marks)
Solution:
A TCP acknowledgement specifies the sequence number of the next octet that the receiver
excepts to receive. The TCP acknowledgement scheme is called cumulative because it
reports how much of the stream has accumulated. Cumulative acknowledgements have
both advantages and disadvantages. One advantage is that acknowledgements are both
easy to generate and unambiguous. Another advantage is that lost acknowledgements do
not necessarily force retransmission. A major disadvantage is that the sender does not
receive information about all successful transmissions, but only about a single position in
the stream that ahs been received.
17. How to establishing a TCP Connection . Explain it .
(10 marks)
Solution:
The first segment of a handshake can be identified because it has the SYN nit set in the
code field. The second message has both the SYN bit and ACK bits set, indicating that it
acknowledges the first SYN segment as well as continuing the handshake. The final
handshake message is only an acknowledgement and is merely used to inform the
destination that both sides agree that a connection has been established.
The handshake is carefully designed to work even if both machines attempt to initiate a
connection simultaneously. Thus, a connection can be established from either end or from
both ends simultaneously. Once the connection has been established, data can flow in both
directions equally well. There is no master or slave.
The three-way handshake is both necessary and sufficient for correct synchronization
between the two ends of the connection. TCP builds on an unreliable packet deliver
service, so message can be lost, delayed, duplicated, or delivered out of order. Thus, the
protocol must use a timeout mechanism and retransmit lost requests. Trouble arises if
retransmitted and original requests arrive while the connection is being established. A
three-way handshake solves these problems.
Figure The sequence of messages in a three-way handshake.
18. How to closing a TCP Connection . Explain it briefly.
(10 marks)
Solution:
Two programs that use TCP to communicate can terminate the conversation gracefully
using the close operation. TCP uses a modified three-way handshake to close connections.
When an application program tells TCP that it has no more data to send, TCP will close the
connection in one direction. To close its half of a connection, the sending TCP finishes
transmitting the remaining data, waits for the receiver to acknowledge it, and then sends a
segment with the FIN bit set. The receiving TCP acknowledges the FIN segment and
informs the application program on its end that no more data is available (e.g., using the
operating system’s end-of-file mechanism).
Once a connection has been closed in a given direction, TCP refuses to accept more data
for that direction. Meanwhile, data can continue to flow in the opposite direction until the
sender closes it.
The difference between three-way handshakes used to establish and break connections
occurs after a machine receives the initial FIN segment. Instead of generating a second
FIN segment immediately, TCP sends an acknowledgement and then informs the
application of the request to shut down. Informing the application program of the request
and obtaining the response may take considerable time. Finally, when the application
program instructs TCP to shut down the connection completely, TCP sends the second FIN
segment and the original site replies with the third message, an ACK.
Figure The modified three-way handshake used to close connection.
19. Draw the diagram of the TCP finite State Machine and explain about it. (20 marks)
Solution:
The operation of TCP can best be explained with a theoretical model called a
finite state machine. Figure shows the TCP finite state machine , with circles representing
state and arrows representing transitions between them. An active open command forces a
transition from the CLOSED state to the SYN SENT state . When TCP follows the
transition, it emits a SYN segment. When the other end returns a segment that contains a
SYN plus ACK, TCP moves to the ESTABLISHED state and begins data transfer .
The TIME WAIT state reveals how TCP handles some of the problem incurred
with unreliable delivery . Because the timer allows TCP to distinguish old connections
from new ones , it prevents TCP from responding with a RST (reset) if the other end
retransmits a FIN request.
B.E and M.E ( Second Semester)
Sample Question
IT-5013 Digital Signal Processing
Chapter – 3
1. Determine the Z-transform and sketch the ROC of the signals
(a) x (n) = (1/2)n u(n)
(b) x (n) = -3u(-n-1)
(10-Marks)
2. State and prove ANY THREE properties of the Z-transform.
(20-Marks)
3. Determine the Z-transform and sketch the ROC of the signal
x(n)=[3(2)n -4(3)n ]u(n).
(10-Marks)
4. Determine the system function and the unit sample response of the system describe by
the difference equation.
y(n)=1/2 y(n-1)+2x(n)
(10-Marks)
5. Determine the inverse Z-transform of
X(Z)=
1
1 − 1.5Z + 0.5Z − 2
−1
When
(a) ROC: |Z| > 1
(b) ROC: | Z| < 0.5
(c) ROC: 0.5 < |Z| < 1
(20-Marks)
6. Determine the causal signal x(n) having the Z-transform.
1
X(Z)=
( 1 + Z -1 ) ( 1 - Z -1 )2
(20-Marks)
7. The well-known Fibonacci sequence of integer numbers is obtained by computing each
term as the sum of the two previous ones. The first few terms of the sequence are
1,1,2,3,4,5,8.
Determine a closed-form expression for the nth term of the Fibonacci sequence.
(20-Marks)
8. Determine the step response of the system
y(n)=α y(n-1) + x(n)
-1 < α < 1
when the initial condition is y(-1)=1
(20-Marks)
9. Determine the unit step response of the system describe by the difference equation
y(n) = 0.9y(n-1)- 0.81y(n-2) + x(n)
under the following initial condition:
y(-1)=y(-2)=1
(20-Marks)
10. Determine the transient and steady-state response of the system characterized by the
Difference equation
y(n) = 0.5y(n-1) + x(n)
when the input signal is x(n)=10 cos(π n/4)u(n).
The system initially at rest (i.e, it is relaxed)
(20-Marks)
11. Determine the inverse Z-transform of
3 − 4 Z −1
H(Z)=
1 − 3.5Z −1 + 1.5Z − 2
Specify the ROC of H(Z) and determine h(n) for the following conditions:
(a) The system is stable.
(b) The system is causal.
(c) The system is purely anticausal.
(20-Marks)
12. Compute the convolution of the following signals by means of Z-transform
⎧⎪(1 / 3) n n ≥ 0
x1(n)= ⎨
⎪⎩(1 / 2) − n n < 0
x2(n)=(1/2)n u(n)
(20-Marks)
13. Use the one side Z-transform to determine the zero input response, yzi (n), n ≥ 0 in the
following case.
y(n) - 1.5y(n -1) + 0.5y( n-2 ) = 0, y(-1) = 1, y(-2) = 0
(10-Marks)
14. Compute the zero state response for the following pair of system and input signal.
h(n) = (2/5)n u(n), x(n) = u(n) - u(n-7)
(10-Marks)
15. Determine the response of the system described by the difference equation
y(n)=5/6 y(n-1) - 1/6 y(n-2) + x(n)
to the input signal x(n)= δ (n) - 1/3 δ (n-1).
Take the initial condition y(-1) = 1 and y(-2) = 0
16. Determine the unit step response of the causal system described by the difference
equation
y(n) = y(n-1) + x(n)
(20-Marks)
(10-Marks)
17. By using schur-cohn stability test ,determine if the system having the function
H(Z) =
1
1 − 7 / 4Z
−1
− 1 / 2Z −2
is stable.
(10Marks)
18. We want to design a causal discrete time LTI system with the property that if the input is
x(n) = (1/2)n u(n) - 1/4(1/2)n-1 u(n-1)
then the output is y(n) = (1/3)n u(n).
(a) Determine the system function H(Z) and the impulse response of a system that
satisfies the forgoing conditions.
(b) Find the difference equation that characterizes this system.
(c) Determine a realization of the system that requires a minimum number possible amount of money.
(20-Marks)
(d) Determine if the system is stable.
19. Determine the interconnection of the systems shown in
Fig: where h(n) = an u(n), -1< a < 1.
h(n)
δ (n-1)
x(n)
y(n)
+
δ (n -2)
h(n)
(a) Determine the impulse response of the overall system and determine if it is causal and
stable.
(b) Determine a realization of the system using the minimum numbers of adders, multipliers
and delay elements.
(20-Marks)
20. Consider the system
Z −1 + 1 / 2 Z −2
3
2 −2
1 − Z −1 +
Z
5
25
(a) Determine impulse response.
(b) The zero state step response.
H(Z)=
(20-Marks)
21. Consider the system
H(Z)=
Z −1 + 1 / 2 Z −2
3
2 −2
Z
1 − Z −1 +
5
25
Determine the step response if y(-1)=1 and y(-2)=2
(20-Marks)
Chapter ( 4 )
Frequency Analysis of Signals
22. Determine the Fourier and series and the power density spectrum of the rectangular
pulse signal illustrated in fig.
x(t)
(20-Marks)
A
-Tp
-τ/2
0
τ/2
Tp
t
23. Determine the Fourier transform and the energy density spectrum of the signal defined as
A
| t | ≤ τ/2
0
| t | > τ/2
x(t)=
(20-Marks)
24. Determine the spectrum of the signal.
x(n) = cos ω0n
when (a) ω0 = 2π
(b) ω0 =
π
3
25. Determine the Fourier series coefficients and the power density spectrum of the signal
show in fig:
x(t)
(20-Marks)
(20-Marks)
A
-N
0
L
N
n
26. Determine the signal x(n) corresponding to the spectrum
1
| ω | ≤ ωc
0
otherwise
X(ω)=
(20-Marks)
27. Determine the Fourier transform and the energy density spectrum of the sequence
A
0 ≤n ≤L-1
0
otherwise
x(n)=
which is illustrated in fig.
(20-Marks)
28. Determine the Fourier transform of the signal
n
x(n)=a
-1 < a < 1
(20-Marks)
29. Consider the full-wave rectified sinusoid in fig
(a)
(b)
(c)
(d)
Determine its spectrum Xa(F).
Compute the power of the signal.
plot the power spectrum density.
Check the validity of Parseval’s relation for this signals.
30. Compute the Fourier transform of the following signals.
(a) x(n) = u(n) - u(n-6)
(b) x(n) = 2n u(n-6)
(c) x(n) = cos( π/3)n [u(n) - u(n-6)]
(20-Marks)
(20-Marks)
BE. IT <IT. 05103>
Digital Signal Processing
Sample Questions and Answers
CHAPTER -3
1. Determine the Z-transform and sketch the ROC of the signal. (10 marks )
(a) x(n)= (1/2)n u(n)
(b) x(n)= -3u(-n-1)
Solution:
(a) x(n) = (1/2)n u(n)
∞
∑
X(Z) =
=
=
x(n) Z-n
n = −∞
∞
∑
(1/2)n Z-n
∑
(1/2 Z-1)n
n =0
∞
n =0
=
1
1 −1
1− z
2
1
ROC: | Z −1 |< 1
2
ROC: |Z | > ½
Im
1/2
(b) x(n) = -3u(-n-1)
X(Z) =
∞
∑
x(n) Z-n
n = −∞
−1
=
∑
-3u (-n-1) Z-n
n = −∞
∞
= -3 ∑ (Z)l
(where l = -n)
l =1
Z
1− Z
3
=
1 − Z −1
= -3
ROC: |Z| <1
Re
2. State and prove ANY THREE properties of the Z-transform.
“Scaling in the z-Domain”
(20-Marks)
Z
IF
x(n) ←⎯→ X(Z)
ROC: r1 < |Z| < r2
n
-1
Z
Then a x(n) ←⎯→ X(a Z)
ROC: |a| r1 < |Z| < r2
For any constant a, real or complex.
Proof: By definition,
∞
Z{ an x(n) } =
∑
an x(n)Z-n
∑
x(n) (a-1Z)-n
n = −∞
∞
=
n = −∞
= X (a-1Z)
Since the ROC of X(Z) is r1 < |Z| < r2, the ROC of X(a-1Z) is r1 < |a-1Z| < r2 (or)
|a| r1 < |Z| < |a| r2
“Time Reversal”
IF
x(n)
Z
←⎯→
X(Z)
X(Z-1)
Z
Then x(-n) ←⎯→
ROC: r1 < |Z| < r2
1
1
ROC:
< |Z| <
r2
r1
Proof: By definition,
Z {x(-n) } =
=
∞
∑
x(-n) Z-n
∑
x(l) (Z-1)-l
n = −∞
∞
l = −∞
= X(Z-1)
where l = -n
The ROC of X(Z-1) is
r1 < |Z-1| < r2
or equivalently
1
1
< |Z| <
r2
r1
“Differentiation in the Z-Domain”
Z
x(n) ←⎯→
X(Z)
dX ( Z )
Z
-Z
Then nx(n) ←⎯→
dZ
IF
Proof: By differentiating both sides of Z transform equation
dX ( Z )
=
dZ
∞
∑
x(n) (-n) Zn-1
n = −∞
= - Z-1
∞
∑
{n x(n)} Z-n
n = −∞
= - Z-1 Z {n x(n)}
− ZdX ( Z )
= Z {n x(n) }
dZ
Both transforms have the same ROC:
3. Determine the Z-transform and sketch the ROC of the signal x(n)=[3(2)n – 4(3)n]
u(n).
(10 marks)
Solution:
x(n) = [3(2)n – 4(3)n] u(n).
X(Z) = Z {x(n)}
= Z [ 3(2)n – 4(3)n ] u(n)]
= Z { 3(2)n u(n) } – Z { 4(3)n u(n) }
3
4
=
−1
1 − 2Z
1 − 3Z −1
ROC: |Z| > 2 ; ROC: |Z| > 3
X(Z) =
3
4
;
−1
1 − 2Z
1 − 3Z −1
ROC: |Z| > 3
Fig: ROC of X(Z)
4. Determine the system function and the unit sample response of the system described by
the difference equation.
1
(10 marks)
y(n) = y (n - 1) + 2x(n)
2
Solution:
1
y(n) = y (n - 1) + 2x(n)
2
1
Y(Z) = Z-1 Y(Z) + 2 X(Z)
2
1 -1
Z ) = 2 X(Z)
2
Y (Z )
2
=
1
X (Z )
1 − Z −1
2
2
H(Z) =
1
1 − Z −1
2
1 n
∴ h(n) = 2 ( ) u(n)
2
This is the unit sample response of the system.
Y(Z) (1-
5. Determine the inverse Z-transform of
1
X(Z) =
−1
1 − 1.5Z + 0.5Z − 2
when
(a) ROC: |Z| > 1
(b) ROC: |Z| < 0.5
(c) ROC: 0.5 < |Z| < 1
Solution:
1
X(Z) =
−1
1 − 1.5Z + 0.5Z − 2
Z2
X(Z) = 2
Z − 1.5Z + 0.5
Z2
X(Z) =
( Z − 1)( Z − 0.5)
A1
A2
X (Z )
Z
=
=
+
Z
( Z − 1)( Z − 0.5)
Z − 1 Z − 0 .5
X (Z )
A1 = (Z-1)
Z =1
Z
Z
A1 =
Z − 0.5 Z =1
=
1
1 − 0.5
2
A1
=
A2
= (Z-0.5)
A2
=
=
∴ A2 =
X (Z )
=
Z
X(Z) =
∴ X(Z) =
X (Z )
Z
Z = 0. 5
Z
Z = 0.5
Z −1
0.5
0.5 − 1
-1
2
1
−
Z − 1 Z − 0.5
27
Z
−
Z − 1 Z − 0.5
2
1
−
−1
1− Z
1 − 0.5Z −1
(20 marks)
(a) When the ROC is |Z| > 1 , the signal x(n) is causal arc terms are causal terms.
∴ x(n) = 2(1)n u(n) –(0.5)n u(n)
= (2 - 0.5n) u(n)
(b) When the ROC is |Z| < 0.5 , the signal x(n) is anticausal.
Thus both terms result in anticausal components.
∴ x(n) = [-2 + (0.5)n ] u(-n-1)
(c) When the ROC is 0.5 < |Z| < 1 , the signal x(n) is two sided.Thus one of term is a causal
part and the other is anticausal part. Thus,
∴ x(n) = - 2 (1)n u(-n-1) – (0.5)n u(n).
6. Determine the causal signal x(n) having the Z-transform
1
X(Z) =
−1
(1 + Z )(1 − Z −1 ) 2
Solution:
1
X(Z) =
−1
(1 + Z )(1 − Z −1 ) 2
(20 marks)
Z3
( Z + 1)( Z − 1) 2
X(Z) has simple pole at p1 = -1 and a double pole at p2 = p3 = 1.Thus partial fraction
exp
A3
A1
A
Z2
X (Z ) =
=
+ 2 +
2
Z + 1 Z − 1 ( Z − 1) 2
( Z + 1)( Z − 1)
Z
X (Z )
A1 = (Z+1)
Z Z = −1
X(Z) =
A1 =
Z2
( Z − 1) 2
Z = −1
(−1) 2
(−1 − 1) 2
1
A1 =
4
Z2
A3 =
Z =1
Z +1
12
A3 =
1+1
1
A3 =
2
d ⎡
X (Z ) ⎤
( Z − 1) 2
A2 =
Z=1
⎢
Z ⎥⎦
dZ ⎣
d Z2
A2 =
Z =1
dZ Z + 1
( Z + 1)27 − Z 2 (1)
A2 =
Z =1
( Z + 1) 2
(1 + 1)2 − 1 4 − 1 3
A2 =
=
=
4
4
(1 + 1) 2
3
1
1
X (Z )
2
= 4 + 4 +
Z
Z + 1 Z − 1 ( Z − 1) 2
A1 =
1 Z 3 Z
1 Z
4
4
2
X(Z) =
+
+
Z + 1 Z − 1 ( Z − 1) 2
Z −1
1
1
3
1
1
+
+
4 (1 + Z −1 ) 4 (1 − Z −1 ) 2 (1 − Z −1 )2
1
3
1
x(n) = (−1) n u (n) + u (n) + u (n)
4
4
2
3 n⎤
⎡1
x(n) = ⎢ (−1) n + + ⎥u (n)
4 2⎦
⎣4
=
7. The well-known Fibonancci sequence of integer numbers is obtained by computing each
term as the sum of the two previous one. The first few terms of the sequence are
1,1,2,3,5,8,13,21,34,….Determine a closed –form expression for the nth term of the
Fibonancci sequence.
(20 marks)
Solution:
⎯→( A)
y(n) = y(n-1) + y(n-2) ⎯
initial condition
⎯→(1)
n=0 ⇒ y (0) = y (−1) + y (−2) = 1 ⎯
y (1) = y (0) + y (−1) = 1 ⎯
⎯→(2)
∴ y (−1) = 0
y (− 2 ) = 1
K
⎡
⎤
Z + {y (n − K )} = Z − K ⎢Y + (Z ) + ∑ y (− n )Z n ⎥; K > 0
n =1
⎣
⎦
n:
+
−1
+
1
eq (A) Y (Z ) = Z {Y (Z ) + y (− 1)Z } + Z −2 {Y + (Z ) + y (− 1)Z + y (− 2 )Z 2 }
[
[
= Z − 1Y
+
] [
(Z ) + y (− 1 )] + [Z − 2 Y + (Z ) + y (− 1 )Z − 1 + y (− 2 )]
= Z −1Y + (Z ) + Z −2Y + (Z ) + 1
Y + (Z ) 1 − Z −1 − Z −2 = 1
1
=
−1
1 − Z − Z −2
Z2
= 2
Z − Z −1
+
A1
A2
Y (Z )
Z
= 2
=
+
Z
Z − Z −1 ⎛
1+ 5 ⎞ ⎛
1− 5 ⎞
⎜Z −
⎟ ⎜Z −
⎟
⎜
⎟
⎜
⎟
2
2
⎝
⎠ ⎝
⎠
1+ 5
1− 5
P1 =
, P2 =
2
2
Y (Z )
A1 = (Z − P1 )
Z = P1
Z
Z
=
Z = P1
Z − P2
P1
=
P1 − P 2
[
]
]
1+ 5
1+ 5
2
=
=
2 5
1+ 5 ⎛1+ 5 ⎞
⎟
− ⎜⎜
⎟
2
⎝ 2 ⎠
A2 = (Z − P2 )
Z
Z − P1
P2
=
P2 − P1
=
Y (Z )
Z
Z = P2
Z = P2
1− 5
1− 5
2
=
=
⎛1− 5 ⎞ ⎛1+ 5 ⎞ − 2 5
⎟
⎟ ⎜
⎜
⎜ 2 ⎟−⎜ 2 ⎟
⎠
⎠ ⎝
⎝
1+ 5
1− 5
+
Y (Z )
2 5
2 5
−
=
Z
⎞
⎛
⎛
1+ 5
1− 5 ⎞
⎟
⎟ ⎜Z −
⎜Z −
⎟
⎟ ⎜
⎜
2
2
⎠
⎠ ⎝
⎝
1+ 5
1− 5
Y + (Z ) =
=
⎛
⎜Z
⎜
⎝
2 5
2 5
×Z
×Z −
⎛
1+ 5 ⎞
1− 5 ⎞
⎟
⎟
⎜Z −
−
⎜
2 ⎟⎠
2 5 ⎟⎠
⎝
1+ 5
1− 5
2 5
2 5
−
⎛ 1 + 5 −1 ⎞ ⎛ 1 − 5 −1 ⎞
⎜1 −
Z ⎟⎟ ⎜⎜1 −
Z ⎟⎟
⎜
2
2
⎝
⎠ ⎝
⎠
⎡1 + 5 ⎛ 1 + 5 ⎞ n 1 − 5 ⎛ 1 − 5 ⎞ n ⎤
⎟ ⎥u (n )
⎜
⎟ −
⎜
y (n ) = ⎢
2 ⎜⎝ 2 ⎟⎠ ⎥
⎢ 2 5 ⎜⎝ 2 ⎟⎠
⎣
⎦
1 ⎛ 1 ⎞n + 1⎡
n +1
n + 1⎤
=
1+ 5
− 1− 5
⎜ ⎟
⎢
⎥⎦u (n )
5 ⎝2⎠
⎣
(
)
(
)
8 . Determine the step response of the system y (n ) = αy (n − 1) + x , − 1 < α < 1 ,when the
initial condition is y(-1)=1.
(20-marks)
Soln: y (n ) = αy (n − 1) + x(n )
x(n ) = u (n )
; −1 < α < 1
y (− 1) = 1
K
Z
⎡
⎤
x(n − K ) ↔ Z − K ⎢α + (Z ) + ∑ x(− n )Z n ⎥
n =1
⎣
⎦
+
−1
+
+
Y (Z ) = α Z Y (Z ) + y (− 1)Z + X (Z )
+
Y
+
[ {
(Z ) = α [Z Y
x(n ) = u (n )
−1
}]
+
(Z ) + y(− 1)] + X + (Z )
;K > 0
1
1 − Z −1
Y + (Z ) = αZ −1Y + (Z ) + α + X + (Z )
1
Y + (Z ) − αZ −1Y + (Z ) = α +
1 − Z −1
1
α
Y + (Z ) =
+
−1
−1
1 − αZ
(1 − αZ )(1 − Z −1 )
A1
A2
1
Y + (Z ) =
=
+
−1
−1
−1
(1 − αZ )(1 − Z ) (1 − αZ ) (1 − Z −1 )
X + (Z ) =
(
)
A1 = 1 − αZ −1 Y (Z ) Z −1 = 1
α
1
1
=
=
−1
1− Z
1− 1
=
α
(
A2 = 1 − Z
=
−1
)Y (Z )
1
−α
=
α −1 1− α
α
Z −1 =1
1
1
=
−1
1−α
1 − αZ
Y + (Z ) =
(− α )
α
1
+
+
−1
−1
(1 − α )(1 − αZ ) (1 − α )(1 − Z −1 )
1 − αZ
[
]
y (n ) = Z 1 Y + (Z )
= α (α )n u (n ) −
α
1
α n u (n ) +
u (n )
(1 − α )
(1 − α )
= α n + 1u (n ) −
α n +1
1
+
u (n )
1−α 1−α
1−α n +1
u (n )
1−α
⎡ (1 − α )α n + 1 + (1 − α )n + 1 ⎤
⎥u (n )
=⎢
1−α
⎢⎣
⎥⎦
1 ⎛ n +1
=
+ 1 − α n + 1 ⎞⎟u (n )
⎜α
⎠
1−α ⎝
1 ⎛
n + 2 ⎞u (n )
=
⎜1 − α
⎟
⎠
1−α ⎝
= α n + 1u (n ) +
9 . Determine the unit step response of the system described b difference equation.
y (n ) = 0.9 y (n − 1) − 0.81 y (n − 2 ) + x(n )
under the following initial conditions:
y (− 1) = y (− 2 ) = 1
(20 marks)
Solution:
y (n ) = 0.9 y (n − 1) − 0.81 y (n − 2 ) + x(n )
y (− 1) = y (− 2 ) = 1
N (Z )
y Zi ( Z ) = 0
, A( Z ) = 1 − 0.9Z −1 + 0.81Z −2
A( Z )
N
k
k =1
n =1
N 0 ( Z ) = − ∑ a k Z − k ∑ y ( − n) Z n
[
}]
{
= − a1 Z −1 y (−1) Z 1 + a 2 Z −2 ( y (−1) Z 1 + y (−2) Z 2 )
[
= − a1 Z + a 2 Z −1 + a 2
]
[
= − − 0.9 + (0.81) Z −1 + (0.81)
= 0.09 − 0.81Z −1
N
y Zi ( Z + ) =
]
k
∑ a k Z − k ∑ y ( − n) Z n
N 0 (Z )
=
A( Z )
k =1
n =1
N
1 + ∑ ak Z −k
k =1
y Zi ( Z ) =
=
N 0 (Z )
0.09 − 0.81Z −1
=
A( Z ) 1 − 0.9 Z −1 + 0.81Z − 2
0.09 − 0.81Z −1
j
π
−j
π
(1 − 0.9e 2 Z −1 )(1 − 0.9e 2 Z −1 )
A
B
=
+
π
π
j
(1 − 0.9e 2 Z −1 )
=
−j
A(1 − 0.9e
π
2
j
(1 − 0.9e
0.09 − 0.81Z −1
(1 − 0.9e
A=
−j
π
2
−1
1 − 0 .9 e
−j
π
2
=
Z −1 )
j
π
−j
π
2
Z −1 )
1
0.9e
0.09 − 0.81 / 0.9e
Z −1 )
j
π
Z
2
Z −1 ) + B (1 − 0.9e 2 Z −1 )
(1 − 0.9e 2 Z −1 )(1 − 0.9e
A=
−j
j
π
3
π
3
1
j
π
0 .9 e 3
− 0.36 + j 0.779
=
1.5 + j 0.866
B = A*
0.026 + j 0.4936 0.026 − j 0.4936
y Zi ( Z ) =
+
π
π
j
1 − 0.9e 3 Z −1
(1 − 0.9e
−j
2
Z −1 )
π
y Zi (n) = 0.988(0.9) n cos( n + 87 . )u (n)
3
10. Determine the transient and steady state response of the system characterized by the
difference equation.
πn
) u(n)
y(n)=0.5 y(n-1) + x(n) when the input signal x(n) = 10 cos (
4
The system is initially at rest (i.e it is relaxed).
(20 marks)
Solution:
y(n) = 0.5 y(n-1) + x(n)
Y(Z) = 0.5 y(Z)Z-1 + X(Z)
Y(Z) (1-0.5Z-1) = X(Z)
Y (Z )
1
=
X ( Z ) 1 − 0.5Z −1
One pole at Z=0.5
πn
x(n) =10 cos ( ) u(n)
4
10(1 − Z −1 cos π ) ⎡
⎤
1 − Z −1 cos ω 0
4
=
X (Z ) =
cos(
n
)
u
(
n
)
Q
ω
⎢
0
−1
−2 ⎥
−1
−
2
1 − 2 Z cos ω 0 + Z ⎦
1 − 2 Z cos π + Z ⎣
4
10(1 − 1 Z −1 )
2
=
−1
1 − 2Z + Z −2
Y(Z) = H(Z) X (Z)
10(1 − 1 Z −1 )
2
=
−1
(1 − 0.5Z )(1 − 2 Z −1 + Z − 2 )
10(1 − 1 Z −1 )
2
Y(Z) =
jπ
− jπ
−1
4 −1
(1 − 0.5Z )(1 − e Z )(1 − e 4 Z −1 )
A
B
C
=
+
+
−1
jπ
−
(1 − 0.5Z ) (1 − e 4 Z −1 ) (1 − e jπ 4 Z −1 )
H(Z) =
1 −1 ⎞
⎛
10⎜1 −
Z ⎟
2
⎝
⎠
A=
−1
−2
1 − 2Z + Z
(
)
Z −1 = 2
1
⎞
⎛
10⎜1 −
× 2⎟
2
⎠
= ⎝
1 − 2 .2 + 4
10 1 − 2 10(1 − 1.414 ) − 4.142
=
=
=
= −1.91
5 − 2.828
2.172
5−2 2
(
)
10⎛⎜1 − 1 Z −1 ⎞⎟
2
⎝
⎠
B=
jπ
−1 ⎛
1 − 0.5Z ⎜1 − e 4 Z −1 ⎞⎟
⎝
⎠
(
=
)
1
Z −1 =
e
jπ
4
10⎛⎜1 − 1 * − 45. ) ⎞⎟
2
⎝
⎠
1
(1 − 0.5 − 45 )(1 − 1 − 45. *
e
10(1 −
jπ
)
4
1
(0.7071 − j 0.7071))
2
=
(1 − 0.5(0.7071 − j 0.7071))(1 − 1∠ − 90)
10(1 − 0.5 + j 0.5)
1 − 0.354 + j 0.354)(1 − (0 − j ))
5 + j5
=
(0.646 + j 0.354)(1 + j )
7.071∠ + 45
=
= 6.79 − 28.7
(0.737∠28.7)(10414∠45)
=
C = B* = 6.79 ∠28.7
Y(Z) =
y(n)
− 1 .9
6.79∠ − 28.7 6.79∠28.7
+
+
−1
− jπ
jπ
1 − 0 .5 Z
1 − e 4 Z −1
1 − e 4 Z −1
= -1.9(0.5)n u(n) +2*6.79(1)n cos (
πn
4
- 28.7) u(n)
The natural or transient rep: is
ynr (n) = -1.9(0.5)n u(n)
The forced or steady state rep: is
yfr(n) = 13.58 cos (
πn
4
- 28.7) u(n)
11 . Determine the inverse Z-transform of
3 − 4 Z −1
.
H (Z ) =
1 − 3.5Z −1 + 1.5Z − 2
Specify the ROC of H(Z) and determine h(n) for the following condition
(a)The system is stable
(b)The system is causal
(c)The system is purely anticausal.
(20 marks)
Solution:
3 − 4 Z −1
1 − 3.5Z −1 + 1.5Z − 2
3 − 4 Z −1
H (Z ) =
1 − 1 Z −1 1 − 3 Z − 1
2
A
B
+
H (Z ) =
−
1
1 − 3Z −1
1− 1 Z
2
3 − 4 Z −1
A=
−1
1 − 3 Z −1 Z = 2
A =1
3 − 4 Z −1
B=
Z −1 = 1
3
1 − 1 Z −1
2
B=2
1
2
H (Z ) =
+
−
1
1 − 3Z −1
1− 1 Z
2
1
∴ The system has poles at Z = and Z = 3.
2
(a) The system is stable ROC : 1 < Z < 3.
2
H (Z ) =
(
)(
)
n
⎛1⎞
n
∴ h(n ) = ⎜ ⎟ u (n ) − 2(3) u (− n − 1)
⎝2⎠
(b) The system is causal ROC : 1 < Z < 3.
2
n
n
∴ h(n ) = 1
+ 2(3) u (n )
2
{( )
}
(c) The system is anticausal ROC : 1 < Z < 3.
2
n
⎫
⎧⎪ ⎛ 1 ⎞
n⎪
∴ h(n ) = ⎨− ⎜ ⎟ − 2(3) ⎬u (− n − 1) , system is unstable.
⎪⎭
⎪⎩ ⎝ 2 ⎠
12. Compute the convolution of the following signals by means of Z-transform.
(20-Marks)
1
n
⎧⎪ ( ) n≥0
x1 (n) = ⎨ 31
⎪⎩ ( 2 )− n n<0
1
x 2 ( n) = ( ) n u ( n)
2
Solution
⎧⎪ ( 1 )n n≥0
x1 (n) = ⎨ 31
⎪⎩ ( 2 )− n n<0
X 1 (Z ) =
∞
∑ x ( n) Z
−n
n = −∞
∞
−1
1
1
X 1 ( Z ) = ∑ ( ) n Z −n + ∑ ( ) −n Z −n
n =0 3
n = −∞ 2
∞
∞
1
1
X 1 ( Z ) = ∑ ( Z −1 ) n + ∑ ( Z ) n ( where, l = −n)
n =1 3
l =1 2
1
1
1
=
+ 2 Z ; ROC : < Z < 2
1
1
3
1 − Z −1 1 − Z
2
3
=
Z
Z−
1
3
+
Z
2+Z
=
Z
3Z
+
3Z − 1 2 − Z
=
6 Z − 3Z 2 + 3Z 2 − Z
6 Z − 3Z 2 − 2 + Z
=
5Z
7 Z − 3Z 2 − 2
1
x 2 ( n) = ( ) n
2
X 2 ( Z ) = Z {x 2 (n)}
X2 =
1
1
1 − ( ) Z −1
2
Z
=
Z−
1
2
; ROC : Z >
1
2
Z {x1 (n) ∗ x 2 (n)} = X 1 ( Z ) ⋅ X 2 ( z )
Z
5Z
×
2−
7 Z − 3Z 2 Z − 1
2
2
5Z
X (Z ) =
1
1
( Z − )( Z − 2)( Z − )
3
2
X (Z )
5Z
=
1
1
Z
( Z − )( Z − 2)( Z − )
3
2
X (Z )
A
B
C
=
+
+
1
1
Z
( Z − 2)
(Z − )
(Z − )
3
2
Q X (Z ) =
5Z
A=
1
( Z − 2)( Z − )
2
A=6
5Z
1
1
( Z − )( Z − )
3
2
B=4
Z=
1
3
B=
C=
5Z
1
( Z − )( Z − 2)
3
Z=
Z=
1
2
1
2
C = −10
4
(−10)
+
1 Z −2
1
Z−
Z−
3
3
1
6
4
(−10)
+
+
X (Z ) =
, ROC :
1 −1 1 − 2 Z −1
1 −1
2< Z <2
1− Z
1− Z
3
3
1
1
∴ x(n) = ( ) n u (n) + 4(2) n u (− n − 1) − 10( ) n u (n)
3
2
X (Z )
=
Z
6
+
13. Use the one-side Z-transform to determine the zero input response ,y y 2 (n), n ≥ 0 in the
following case.
y (n) − 1.5 y (n − 1) + 0.5 y (n − 2) = 0 ; y(-1)=1,y(-2)=0
(10-Marks)
k
⎡
⎤
Z+
x(n − k ) ←⎯→
Z − k ⎢ X |+ ( Z ) + ∑ x ( n ) Z n ⎥
n =1
⎣
⎦
+
−1
+
−2
Y ( z ) − 1.5Z Y ( Z ) + y (−1) Z + 0.5Z Y + ( Z ) + y (−1) + y (−2) Z 2
+
[
Y ( Z ) 1 − 1 .5 Z
[
−1
]
+ 0 .5 Z
−2
] − 1 .5 + 0 .0 Z
]
=0
−1
(1.5 − 0.5Z )
1 − 1.5Z −1 + 0.5Z − 2
1.5 − 0.5Z −1
Yzi ( Z ) =
(1 − 0.5Z −1 )(1 − Z −1 )
A
B
=
+
−1
1 − 0.5Z
1 − Z −1
1
A=−
2
B=2
1
−
2
2
Yzi ( Z ) =
+
−1
1 − 0.5Z
1 − Z −1
Y + (Z ) =
[
−1
(where no input signal)
⎡ 1
⎤
∴ y zi (n) = ⎢− (0.5) n + 2(1) n ⎥u (n)
⎣ 2
⎦
1 n +1 ⎤
⎡
= ⎢ 2 − ( ) ⎥ u ( n)
2
⎣
⎦
14. Compute the zero state response for the following pair of system and input signal.
(10-Marks)
2
h(n) = ( ) n u (n), x(n) = u (n) − u (n − 7)
5
2
h(n) = ( ) n u (n), x(n) = u (n) − u (n − 7)
5
Yzs ( Z ) = H ( Z ) × ( Z )
H ( Z ) = Z {h(n)}
⎧ 2
⎫
= Z ⎨( ) n u (n)⎬
⎩ 5
⎭
1
=
2 −1
1− Z
5
X ( Z ) = Z {u (n) − u (n − 7)}
1
Z −7
−
1 − Z −1 1 − Z −1
1 − Z −7
=
1 − Z −1
Yzs( Z ) = H ( Z ) × ( Z )
=
1
1 − Z −7
⋅
1
1 − 2 Z −1 1 − Z
5
1
1 + Z −1 + Z − 2 + Z −3 + Z − 4 + Z −5 + Z −6
=
−1
2
1−
Z
5
1
let Yzs′ ( Z ) =
1 − 2 Z −1
5
=
[
]
∴ Yzs( Z ) = Yzs′ ( Z ) + Yzs′ ( Z ) Z −1 ... + Yzs′ ( Z ) Z −6
2
Yzs′ (n) = ( ) n u (n)
5
∴ y zs (n) = y ′zs (n) + y ′zs (n − 1) + ... + y ′zs (n − 6)
2
2
2
= ( ) n u (n) + ( ) n −1 u (n − 1) + ... + ( ) n −6 u (n − 6)
5
5
5
15 . Determine the response of the system described by the difference equation .
1
5
y (n ) = y (n − 1) − y (n − 2 ) + x(n )
6
6
to the input signal
1
x(n ) = δ (n ) − δ (n − 1) .
3
(20-marks)
Take the initial condition: y (− 1) = 1 and y (− 2 ) = 0 .
Solution:
y (− 1) = 1
,
y (− 2 ) = 0
1
5
y (n ) = y (n − 1) − y (n − 2 ) + x(n )
6
6
5
1
Y (Z ) = Y (Z )Z −1 − Y (Z )Z − 2 + X (Z )
6
6
1
⎤
⎡ 5
Y (Z ) = ⎢1 − Z −1 + Z − 2 ⎥ = X (Z )
6
⎦
⎣ 6
Y (Z )
1
∴ H (Z ) =
=
5
1
X (z)
1 − Z −1 + Z
6
6
1
x(n ) = δ (n ) − δ (n − 1)
3
1
⎤
⎡
X (Z ) = Z ⎢δ (n ) − δ (n − 1)⎥
3
⎦
⎣
1
= 1 − Z −1
3
YZS (Z ) = H (Z )X (Z )
⎛
⎜
1
=⎜
5 −1 1 − 2
⎜
⎜1− Z + Z
6
6
⎝
−2
⎞
⎟
⎟⎛⎜1 − 1 Z −1 ⎞⎟
⎟⎝ 3
⎠
⎟
⎠
1
1 − Z −1
3
=
5 −1 1 − 2
1− Z + Z
6
6
1
1 − Z −1
3
=
⎛ 1 −1 ⎞⎛ 1 −1 ⎞
⎜1 − Z ⎟⎜1 − Z ⎟
⎝ 3
⎠⎝ 2
⎠
1
=
1
1 − Z −1
2
n
⎛1⎞
∴ y ZS (n ) = ⎜ ⎟ u (n )
⎝2⎠
N
K
K =1
2
n =1
K
N 0 (Z ) = −∑ a K Z − K ∑ y (− n )Z n
= −∑ a K Z − K ∑ y (− n )Z n
K =1
[
n =1
]
= − a1 Z y (− 1)Z + a 2 Z −2 {y (− 1)Z + y (− 2 )Z 2 }
= −a1 − a 2 Z −1
5 1
1⎞
5
⎛
∴ N 0 (Z ) = − Z −1
⎜Q a1 = − , a 2 = ⎟
6 6
6⎠
6
⎝
5
1
A(Z ) = 1 − Z −1 + Z − 2
6
6
N 0 (Z )
∴ Yzi (Z ) =
A(Z )
5 − 1 Z −1
6
6
=
1 − 5 Z −1 + 1 Z − 2
6
6
5 − 1 Z −1
6
6
=
−1
1
1−
Z 1 − 1 Z −1
3
2
A
B
=
+
−
1
1− 1 Z
1 − 1 Z −1
3
2
5 − 1 Z −1
6
A= 6
Z −1 = 3
1
Z −1
1−
2
5 − 1 (3)
6
= 6
1
1 − (3)
2
= −2
3
−1
(
5 − 1 Z −1
6
B= 6
1
1−
Z −1
3
5 − 1 (2 )
6
= 6
1 − 1 (2 )
3
)(
)
Z −1 = 2
=3
∴ Yzi (Z ) =
2
3
2
1 − 1 Z −1
2
−
2
3
1
1−
Z −1
3
n
n
3⎛1⎞
2⎛1⎞
⎜ ⎟ u (n ) − ⎜ ⎟ u (n )
2⎝2⎠
3 ⎝ 3⎠
∴ y (n ) = y ZS (n ) + y zi (n )
1
3
2
= ( ) n u ( n) + ( 1 ) n u ( n) − ( 1 ) n u ( n)
2
2
2
3 3
2
5
= ( 1 ) n u ( n) − ( 1 ) n u ( n)
2
3 3
2
2
⎡5
⎤
= ⎢ ( 1 ) n − ( 1 ) n ⎥ u ( n)
2
3
2
3
⎣
⎦
y zi (n ) =
16. Determine the unit step response of the causal system described by the difference
Equation.
y (n) = y (n − 1) + x( z )
Y (n) = Y ( z ) Z −1 + X ( z )
Y ( z )(1 − Z −1 ) = X ( z )
1
Y ( z)
=
∴ H ( z) =
X ( z ) 1 − Z −1
1
x(n)=u(n) X(z)=
1 − z −1
Y ( z) = H ( z) × ( z)
1
1
=
×
−1
1− Z
1 − Z −1
1
=
(1 − Z −1 ) 2
Double pole at Z=1
The inverse Z transform of Y(z) is
y(n)=(n+1)u(n)
17. By using schur Cohn stability test, determine if the system having the system function.
1
H(z)=
(10 marks)
1 −2
−1
7
Z − Z
1−
4
2
is stable.
1
H(z)=
1
1 − 7 Z −1 − Z − 2
4
2
−1
7
A2(Z)= 1 −
Z − 1 Z −2 ; k 2 = − 1 , k 2 = 1 < 1
4
2
2
2
A2(Z-1)= 1 − 7 Z − 1 Z 2
4
2
A2 ( Z ) − k 2 B2 ( Z )
A1(Z) =
2
1 − k2
B2 (Z ) = Z −2 A2 (Z −1 )
= Z − 2 10 − 7 Z − 1 Z 2
4
2
−2
−
1
=Z −7 Z − 1
4
2
−1
7
1
Z −
Z −1 + 1 Z −2 − 7 Z −1 − 1
1−
4
2
2
4
2
A1 (Z ) =
2
1
1−
2
−
1
−
2
1 − 7 Z − 1 Z + 1 Z −2 − 7 Z −1 − 1
4
2
2
8
4
=
1
1−
4
3 − 21 Z −1
8
= 4
3
4
7
∴ A1 (Z ) = 1 −
Z −1
2
∴ K1 = − 7
, K2 < 1
but
K1 > 1
2
∴ The system is unstable.
[
]
[
( )
]
18 . We want to design a causal discrete time LIT system with the property that if input is
n
n −1
x(n ) = 1 u (n ) − 1 1
u (n − 1)
2
4 2
then the output is
n
y (n ) = 1 u (n )
3
(a)Determine the system function H (Z ) and the impulse response of a system that
satisfies the forgoing conditions.
(b)Find the difference equation that characteristics this system.
(c)Determine a realization of the system that requires a minimum number possible
amount of memory.
(d)Determine if that system is stable.
(20 marks)
( )
( )
( )
Solution:
(a)
( 2 ) u(n) − 1 4 (1 2 )
U (Z ) = Z {(1 ) u (n )}
2
x(n ) = 1
n −1
n
u (n − 1)
n
1
1
ROC: Z > 1
1
1−
Z −1
2
n −1
U 2 (Z ) = Z 1
u (n − 1)
2
= Z −1U 2 (Z )
=
{( )
}
−1
Z
=
1 − 1 Z −1
2
X (Z ) = Z {x(n )}
ROC: Z > 1
{( 2) u(n)}− 14 Z {(12)
=Z 1
n −1
n
2
}
u (n − 1)
Z −1
1
1
−
4 1 − 1 Z −1
1 − 1 Z −1
2
2
−1
1
Z
1−
4
∴ X (Z ) =
1 − 1 Z −1
2
n
y (n ) = 1 u (n )
3
1
Y (Z ) =
;
ROC:
1 − 1 Z −1
3
Y (Z ) = H (Z )X (Z )
Y (Z )
H (Z ) =
X (Z )
1 − 1 Z −1
1
2
=
×
−1
1
1
1−
1−
Z
Z −1
3
4
1 − 1 Z −1
2
∴ H (Z ) =
−1
1
Z 1 − 1 Z −1
1−
3
4
A
B
=
+
−1
1
1
1−
1−
Z
Z −1
3
4
1 − 1 Z −1
2
A=
Z −1 =3
1
1−
Z −1
4
1 − 1 (3)
2
=
1
1 − (3)
4
= −2
1 − 1 Z −1
2
B=
Z −1 = 4
1
1−
Z −1
3
1 − 1 (4 )
2
=
1
1 − (4)
3
=
( )
(
)(
(
) (
)
)
Z >1
3
=3
2
3
−
1 − 1 Z −1 1 − 1 Z −1
3
4
n
n
∴ h(n ) = ⎡3 1
− 2 1 ⎤u (n )
3 ⎥⎦
⎢⎣ 4
∴ H (Z ) =
( ) ( )
1 − 1 Z −1
2
(b) H (Z ) =
−1
1
1−
Z 1 − 1 Z −1
3
4
−1
1
Z
1−
2
=
1 − 7 Z −1 + 1 Z − 2
12
12
∴ y (n ) = 7 y (n − 1) − 1 y (n − 2 ) + x(n ) − 1 x(n − 1)
12
2
2
(
)(
)
(c)
(d) The system is stable
19. Determine the interconnection of the systems shown in fig:where h(n)=an u(n) , -1< a <1.
(a) Determine the impulse response of the overall system and determine if it is causal
and stable.
(b) Draw a realization of the system using the minimum numbers of adders, multiplier
and delay elements.
(20 marks)
h(n) = an u(n)
h1(n) = h(n) * δ (n − 1)
=
∞
∑ h(k )δ (n − k − 1)
k = −∞
-1 < a < 1
n −1
∑ a δ (n − k − 1)
=
k
k = −∞
= an-1 u(n-1)
h2(n) = h(n) * δ (n-2)
,
n≥ 1
,
n≥ 2
∞
=
∑ h(k )δ (n − k − 2)
k = −∞
n−2
=
∑ a δ (n − k − 2)
k
k = −∞
= an-2 u(n-2)
∴ The impulse response of the overall system;
h’(n) = h1(n) + h2(n)
,
= an-1 + an-2
-1 < a < 1
and
-1 < a n −1 < 1
∞
∑
n≥ 2
-1 < a n − 2 < 1
h’(n) < ∞
k = −∞
∴ The system is stable .
∴ The system is causal since h’(n) = 0 for
(b) h(n) = an-1 u(n-1) + an-2 u(n-2)
H1(z) = z {an-1u(n-1)}
z −1
=
;
ROC z > a
1 − az −1
H2(z) = z { an-2 u(n-2) }
z −2
=
;
ROC z > a
1 − az −1
z −1 + z −2
1 − az −1
∴ y(n) – ay(n-1) = x(n-1) + x(n-2)
∴ y(n) = ay(n-1) + x(n-1) + x(n-2)
∴ H(z) =
20. Consider the system
n<0.
z −1 + 12 z −2
H(z) =
3
2 −2
1 − z −1 +
z
5
25
Determine
(a) The impulse response
(b) The zero-state step response
(a) h(n) = ?
z −1 + 12 z −2
3
2 −2
z
1 − z −1 +
5
25
z+ 1
2
= 2
z −3 z+2
5
25
H(z) =
=
z+ 1
2
( z − 2 )( z − 1 )
5
5
A
B
+
(z − 2 ) (z − 1 )
5
5
z+ 1
2
A=
z=2
5
z− 1
5
2 +1
2=9
= 5
2
2 −1
5
5
(z + 1 )
2
B =
z= 1
2
5
(z − )
5
1 +1
2 = −7
= 5
2
1 −2
5
5
9
7
2 −
2
∴ H(z) =
2
z−
z− 1
5
5
−1
z
z −1
7
9
−
= *
*
2 1 − 2 z −1 2 1 − 2 z −1
5
5
∴ h(n) = 9 (2/5)n-1 u(n-1) – 7/2 (1/5)n-1 u(n-1)
=
(c) yzs(n) = ?
x(n) = u(n)
1
X(z) =
1 − z −1
where Yzs(z) = H(z) X(z)
z −1 + 1 z −2
1
2
=
*
−
1
−
2
1 − z −1
1− 3 z + 2 7
5
25
(20 marks)
z+ 1
z
2
*
3
z −1
z −
z+2
5
25
z+ 1
Yzs ( z )
2
=
2
1
z
( z − )( z − )( z − 1)
5
5
A
B
C
+
+
=
2
1
( z − ) ( z − ) ( z − 1)
5
5
1
z+
2
A =
z=2
1
5
( z − )( z − 1)
5
=
2
2 +1
5
2
2
1
2
( − )( − 1)
5
5 5
− 15
=
2
z+ 1
2
B =
2
( z − )( z − 1) z = 15
5
=
1 +1
5
2
=
( z − 2 )( z − 1 )
5
5 z =1
1+ 1
2
(1 − 2 )( z − 1 )
5
5
25
=
8
35
25
15
Y ( z) − 2
8 + 8
∴ zs
=
+
z
z −1
z−2
z− 1
5
5
=
Yzs ( z ) =
∴ y zs (n) =
=
− 15
35
25
5z +
8z +
8
−1
2
1
1− z −1
z−
z−
z
5
5
− 15 2 n
35
25
( ) u ( n) + ( 1 ) n u ( n) + u ( n)
5
2 5
8
8
⎡ − 15 2 n 35 1 n 25 ⎤
⎢⎣ 2 ( 5 ) + 8 ( 5 ) + 8 ⎥⎦u (n)
21. Consider the system
z −1 + 1 z −2
2
H ( z) =
−
1
1 − 3 z + 2 z −2
5
25
Determine the step response if y(-1) =1 and y(-2)=2.
(20-Marks)
solution:
z −1 + 1 z −2
2
H ( z) =
−1
3
z + 2 z −2
1−
5
25
y (−1) = 1, y (−2) = 2
Assume x(n)=0
N ( z)
Yzi ( z ) = 0
A( z )
3 −1 2 − 2
Z
A(z)=1- Z +
5
25
3
2
N = 2, a1 = − , a 2 =
5
25
N
k
N 0 ( Z ) = − ∑ a k Z − k ∑ y ( − n) Z n
k =1
n =1
2
k
k =1
n =1
= −∑ a k Z − k ∑ y ( −n) Z n
[
= − a1 Z −1 y (−1) Z + a 2 Z −2 ( y (−1) Z + y (−2) Z 2
[
= − a1 Z −1 Z + a 2 Z −2 Z + a 2 Z −2 2Z 2
[
]
= − a1 + a 2 Z −1 + 2a 2
3 2
4
= − Z −1 −
5 25
25
11 2 −1
=
− Z
25 25
N (Z )
YZi(Z) = 0
A( Z )
11 − 2 Z −1
25
25
=
−1
3
Z + 2 Z −2
1−
5
25
11
Z2 − 2
Z
25
25
= 2
Z − 3 Z + 2
5
25
Z−2 )
25
25
2
3
2
Z −
Z+
5
25
11 Z − 2
Yzi ( Z )
25
25
=
2
Z
( Z − )( Z − 1 )
5
5
A
B
=
+
(Z − 2 ) (Z − 1 )
5
5
11 Z − 2
25
A = 25
Z =2
1
5
Z−
5
=
Z (11
]
]
11
(2 ) − 2
25
5
25 = 12
=
2
1
25
( )−
5
5
11 Z − 2
25
B = 25
Z=1
2
5
Z−
5
11 ( 1 ) − 2
25 = − 1
= 25 5
25
1
2
( )−
5
5
12
1
Yzi ( Z )
25 −
25
=
2
Z
Z−
Z−1
5
5
12 Z
1 Z
Yzi ( Z )
= 25 − 25
Z
Z−2
Z−1
5
5
12
1
25
25
−
=
−
1
1− 2 Z
1 − 1 Z −1
5
5
12 2 n
1 1 n
y zi (n) =
( ) u ( n) − ( ) u ( n)
25 5
25 5
Chapter (4)
Frequency Analysis of Signals
1. Determine the fourier series and the power density spectrum of the rectangular pulse
signal illustrated in fig.
x(t)
-Tp
-τ/2
0
Solution:
τ = width
Tp = fundamental period
1
Ck =
x(t )e − 2πkF0t dt
∫
T
p
Tp
=
=
=
1
Tp
∫
Tp
τ
x(t )e −
2
−T p
1
Tp
∫
A
Tp
∫τ
2
Ae −
2
−e
τ
−
2πkFt0
2πkF0t
dt
2
2
2
e−
2πkF0t
dt
dt
τ/2
Tp
t
A
Tp
For k=0, Ck =
τ
∫τ
−
2
1dt
2
A τ2
[t ] τ
Tp − 2
=
A ⎡τ τ ⎤
+
T p ⎢⎣ 2 2 ⎥⎦
2 Aτ Aτ
=
=
2T p
Tp
=
A
For k # 0, C k =
Tp
τ
∫τ
2
−
e − j 2πkF0t dt
2
τ
A
=
Tp
⎡ e − j 2πkF0t ⎤ 2
⎢
⎥
⎣ − j 2πkF0 ⎦ τ
2
τ
j 2πkF0 ⎤
⎡ − j 2πkF0 τ2
A
2
−e
⎢e
⎥
− T p j 2πkF0 ⎣
⎦
A
=
e − jπkF0τ − e jπkF0τ
− T p j 2πkF0
=
[
=
]
⎡ e − jπkF0τ − e jπkF0τ ⎤
⎢
⎥
− T p πkF0 ⎣
2j
⎦
A
=
⎡ e jπkF0τ − e − jπkF0τ
⎢− (
− T p πkF0 ⎢⎣
2j
A
=
A
T p πkF0
=
Aτ
Tp
⎤
)⎥
⎥⎦
sin πkF0τ
sin πkF0τ
πkF0τ
⎧ Aτ
⎪T ,k = 0
⎪⎪ p
Ck = ⎨
⎪ Aτ
sin πkF0τ
⎪
πkF0τ
⎪⎩ T p
, k #0
∴ The power density spectrum for the rectangular pulse train is
Ck
2
⎧ Aτ 2
⎪ (T ) , k = 0
⎪ p
=⎨
Aτ
⎪ ( )2
⎪ Tp
⎩
(
sin πkF
0τ ) 2 , k #0
πkF τ
0
2. Determine the fourier transform and the energy density spectrum of a rectangular pulse
signal defined as.
τ
⎧
⎪ At ≤ 2
x(t)= ⎨
(20-marks)
τ
⎪0t >
2
⎩
x(t)
solution
A
∞
τ
τ
2
X(F)= ∫ x(t )e
2
− j 2πFt
−∞
dt
τ
= ∫−2τ Ae − j 2πFt dt
2
τ
⎡ e − j 2πFt ⎤ 2
for F#0, X(F) = A ⎢
⎥
⎣ − j 2πF ⎦
=
A
πF
τ
j 2πF ⎤
⎡ − j 2 F τ2
2
e
−e
⎥
⎢
=A
⎥
⎢
− j 2πF
⎥⎦
⎢⎣
jπFτ
A ⎡ − (e
− e − jπFτ ⎤
=
⎢
⎥
− πF ⎣
j2
⎦
sin πFτ
sin πFτ = Aτ
πFτ
τ
For F=0,X(F)= ∫ 2τ Ae − j 2πFt dt
−
2
τ
=A ∫ 2τ 1dt
−
2
t
τ
=At
]−2τ
2
⎡τ
τ ⎤ 2 Aτ
= Aτ
=A ⎢ + ⎥ =
2
⎣2 2⎦
τ,F = 0
X(F)= ⎧⎨ A
A
τ
⎩ , F #0
To Find zero-crossing pts,
x(F)=0
sin πFτ
Aτ
=0
πFτ
sin πFτ = sin π
F τ = ±1,±2,....
1 2
F = ± ,± ,....
τ
F =±
τ
m
τ
(m = 1,2,....)
S xx (F ) = X (F ) is called the energy density spectrum of x(t).
2
⎧
⎪ ( Aτ ) 2
X (F ) = ⎨
sin πFτ 2
⎪ ( Aτ ) 2 (
) , k #0
πFτ
⎩
2
3. Determine the spectrum of the signal
x(n) = cos ω 0 n
when(a )ω 0 = 2π (b)ω 0 =
Solution:
π
3
(20 marks)
1 N −1
−
x ( n )e
∑
N n=0
(a) ω 0 = 2πf
2πkπ n
Ck =
2πf =
N
2π
2
2
∴ f is not a rational number, the signal is not perodic. This signal cannot
be expressed in Fourier Series. The spectrum consist of the signal frequency
component at ω 0 = 2π .
f =
(b) ω 0 = 2πf
π
3
= 2πf
1
cycle / samples
6
1
N = = 6 samples / cycle
f
f =
Ck =
1 5
− j 2πk n
6
x ( n )e
∑
6 n =0
=
1 5
− j 2πk n
6
cos ω 0 ne
∑
6 n =0
=
1 5
π
− j 2πk n
6
cos( n)e
∑
6 n =0
3
π
1 5 e
= ∑(
6 n =0
j n
3
π
−e
2
−j n
3
)e
− j 2πk n
π
=
6
π
j n
−j n
n
n
1 5 1
[ e 3 e − j 2πk 6 + e 3 e − j 2πk 6
∑
6 n =0 2
Ck =
1
[
12
5
∑e
n=0
j 2 n (1− k )
6
5
+ ∑e
]
j 2 n ( −1− k )
6
n =0
Consider the first summation,
π
5 j 2n (1 − k )
N
= ⎧⎨ N L1 − k = 0,± N ,±2 N ,...
∑e
⎩ 0 L otherwise
n=0
⎧ 6 L1 − k = 0
⎪⎪ .......k = 1
5 j 2nπ (1 − k )
6
e
=
∑
⎨ 0 L otherwise
⎪
n=0
⎪⎩
Consider the second summation,
⎧ 6 L − 1 − k = −6
(
1
)
k
−
⎪
5 j 2 nπ
6 = ⎪ .......k = 5
∑e
⎨ 0 L otherwise
⎪
n=0
⎪⎩
⎧ 1
C = ⎨ 2 .........., k = 1,5
k ⎩ 0..............otherwise
1
1
, C5 =
2
2
Ck = Ck + N
C1 =
C1 = C 7 = C13 =
C5 = C11 =
1
2
1
2
4. Determine the Furier Series coefficients and the power density spectrum of the signal
show in fig.
(20 marks)
Solution:
Ck =
1
N
N −1
∑ x ( n)e
N
n =0
A L−1
∑1
1
N n =0
Ck = ∑
N n =0
AL
A=
N
L −1
− j 2π k
A
N n
Ck = ∑ (e
)
N n =0
A=
L −1
for k=0,
− j 2πk n
− j 2πk L
N
A 1− e
=
k
N 1 − e − j 2π N
− j 2πk L
j 2πk L
− j 2πk L
N
N
N
−e
(e
)
A e
=
k
k
k
N e − j 2π N (1 − e j 2π N − 1 − e − j 2π N )
L
A − j 2πk ( L −1) N 2 j sin πk N
= e
N
2 j sin π k
N
L
A − j 2πk ( L −1) N sin πk N
= e
N
2 j sin π k
N
C
C
⎧
⎪
⎪ A L ..............k = 0,± N ,±2 N
⎪
N
=⎨
( L − 1) sin πk L
⎪ A − jπk
N ..........Otherwise
N
⎪ e
k
N
sin π
⎪⎩
N
⎧
⎪
⎪⎪ A L ..............k = 0,± N ,±2 N
N
=⎨
L
⎪ A sin πk N
..........Otherwise
⎪N
sin π k
⎪⎩
N
k
k
The power density spectrum of this periodic signal
⎧
⎪
2 ⎪⎪ ( A L N .) 2 ..............., k = 0
=⎨
P =C
x
k
L
⎪ A 2 sin πk N 2
(
)
(
) ,k ≠ 0
⎪ N
sin π k
⎪⎩
N
5. Determine the signal x(n) corresponding to the spectrum.
⎪⎧1......................... w ≤ wc
X ( w) = ⎨
⎪⎩ 0........................Otherwise
(20 marks)
Solution:
x ( n) =
1
2π
∫π X (w)
2
e jwn d w
wc
=
∫1 e
jwn
dw
− wc
for n=0 , x(n) =
1
2π
wc
∫1 d
w
− wc
1
[w]−wwc c
2π
1
[wc + wc ]−wwc c = 2wc = wc
=
2π
2π
π
1 wc jwn
for n ≠ 0, x(n) =
e dw
2π ∫− wc
=
wc
1 ⎡ e jwn ⎤
=
⎢
⎥
2π ⎣ jn ⎦ − w
c
=
x ( n) =
=
1 ⎡ e jwc n − e − jwc n ⎤
⎢
⎥
2π ⎣
2j
⎦
1
sin wc n
πn
wc sin wc n
π wc n
⎧
⎪w
⎪ c ,n = 0
x ( n) = ⎨ π
sin w n
⎪ wc
c ,n ≠ 0
⎪ π w n
c
⎩
6. Determine the Fourier transform and the energy density spectrum of the sequence.
x(n) = ⎧⎨ A,0 ≤ n ≤ L − 1
⎩ 0, Otherwise
which is illustrated in fig.
Solution:
X (ϖ ) =
∞
∑ x ( n)e
− jϖ n
n = −∞
L −1
= ∑ Ae − jϖn
n =0
L −1
For ω = 0 , X (ϖ ) = A∑1 = AL
n =0
L −1
for ω ≠ 0 , X (ϖ ) = ∑ Ae − jϖn
n =0
L −1
= A∑ (e − jϖ ) n
n=0
X (ϖ ) = A *
= A.
1 − e − jϖ L
1 − e − jϖ
e
− jϖ L
e
= A.e
= A.e
2
− jϖ
(e
2
− jω ( L −1)
jϖ L
(e
2
− jϖ ( L −1)
2
jϖ
2
2
−e
−e
− jϖ L
− jω
2 j sin ϖ L
2 j sin ϖ
sin ϖ L
sin ϖ
2
2
)
)
2
2
2
2
⎧
⎪
⎪⎪
X (ϖ ) = ⎨ AL,ϖ = 0
( L − 1) sin ϖl
⎪ − jϖ
2 ,ϖ #0
2
⎪ Ae
ϖ
sin
⎪⎩
2
⎧
⎪
⎪⎪
X (ϖ ) = ⎨ AL,ϖ = 0
ϖl
⎪ sin 2
⎪ A ϖ ,ϖ #0
⎪⎩ sin 2
The energy density spectrum is simply the square of the expression.
⎧
⎪
⎪⎪
X (ϖ ) 2 = ⎨ AL,ϖ = 0
ϖl
⎪ 2 sin 2 2
⎪ A ( ϖ ) ,ϖ #0
sin
⎪⎩
2
7. Determine the Fourier transform of the sigal
x(n)= a
Solution
Let x(n)= x1 (n)+ x 2 (n)
Where
⎧a n
x1 (n)= ⎨
⎩0
nn ≥ 0
n<0
⎧a − n
x 2 (n)= ⎨
⎩0
X 1 ( ω )=
n<0
n≥0
&
&
n =−&
n =0
∑ x1 (n)e − jωn = ∑ a n e − jωn
&
1
= ∑ (ae − jω ) n =
1 − ae − jω
n =0
X 2 ( ω )=
−1
&
∑ x 2 ( n ) e − jω n =
n =−&
&
n
∑a
−n
e − jω n
n= −&
&
= ∑ a e jωn = ∑ (ae jω ) n
n =1
= ae
jω
= ae jω
n =1
(
) + (ae ) + ...
(1 + ae + (ae ) + ...)
+ ae
jω 2
jω 3
jω
jω 2
&
= ae jω ∑ (ae jω ) n =
n =0
ae jω
1 − ae jω
X( ω )= X 1 ( w) + X 2 ( w)
=
=
1
ae jω
+
1 − ae − jω 1 − ae jω
(
)
1 − ae jω + 1 − ae − jω ae jω
1 − ae jω − ae − jω + a 2
n
-1<a<1
(20-marks)
1 − ae jω + ae jω − a 2
⎛ ae jω + ae − jω ⎞
⎟⎟ + a 2
1 − 2⎜⎜
2
⎠
⎝
2
1− a
=
1 − 2a cos ω + a 2
=
8. Consider the full-wave rectified sinusoid in Fig .
(a)Determine its spectrum X a (F ) .
(b)Compute the power of the signal.
(c)Plot the power spectral density
(d) Check the volidity of parseval’s relation for this signal.
Solution:
T p = 2 , F0 =
1 1
Tp = 2
x a (t ) = A sin 2πFt
At t= τ , x(t ) = 0 → A sin 2πFτ = 0
2 πFτ = π
1
F=
2τ
⎛ 1 ⎞
(a) x(t ) = A sin 2π ⎜ ⎟t
⎝ 2τ ⎠
=A sin
π
t
τ
For k#0,
Ck =
1
Tp
Tp
1
τ
∫ x(t )e
=
τ∫
=
A
0
τ
τ
A sin
π
− j 2πkF0t
π − 2πkF t
te
dt
τ
∫ sin τ te
0
0
− j 2πkF0t
dt
π
−j t ⎞
⎛ j πτ t
⎜ e − e τ ⎟ − j 2πk τ1 t
dt
= ∫ ⎜
⎟e
τ 0⎜
2j
⎟
⎝
⎠
π
π
− j (1+ 2 k ) t ⎞ ⎤
A τ ⎡⎛⎜ j τ (1− 2 k )t
τ
⎟⎥ dt
e
e
=
−
⎢
⎟
2 jτ ∫0 ⎢⎣⎜⎝
⎠⎥⎦
A
τ
(20- marks)
τ
τ⎤
⎡
π
π
1
2
1
2
j
(
−
k
)
t
−
j
(
+
k
)
t
⎢
⎥
A ⎢ e τ
e τ
⎥
=
−
π
⎥
2 jτ ⎢ π
⎢ j τ (1 − 2k ) 0 − j τ (1 + 2k ) ⎥
0⎦
⎣
π
⎡ j π (1− 2 k )−1
⎤
− j (1+ 2 k )−1
⎥
A ⎢ e τ
e τ
=
−
⎢
⎥
π
2 jτ ⎢ π
j (1 − 2k ) − j (1 + 2k ) ⎥
⎢⎣ τ
⎥⎦
τ
⎡
⎤
A ⎢ e jπ (1− 2 k )−1
e − jπ (1+ 2 k )−1 ⎥
=
−
⎢
⎥
π
2 jτ ⎢ π
j (1 − 2k ) − j (1 + 2k ) ⎥
⎢⎣ τ
⎥⎦
τ
A
τ ⎡ − 1 − 1 − 1 − 1⎤
=
×
+
2 jτ jπ ⎢⎣1 − 2k 1 + 2k ⎥⎦
− A ⎡ − 2 − 4k − 2 + 4k ⎤
=
2π ⎢⎣1 + 2k − 2k − 4k 2 ⎥⎦
− A⎡ −4 ⎤
=
2π ⎢⎣1 − 4k 2 ⎥⎦
2A
=
π 1 − 4k 2
(
)
Ck =
For k=0 ,
1
τ
1
Tp
∫ X (t )dt
Tp
⎛π ⎞
A sin ⎜ t ⎟dt
τ∫
⎝τ ⎠
=
0
π
A⎡
⎤
− cos τ + cos 0⎥
⎢
π⎣
τ
⎦
=
2A
=
(b)
Px =
=
Px =
1
TP
1
τ
∫
π
X (t ) dt
2
TP
2
∫
A sin
∞
∑C
k = −∞
2
k
π
t dt
τ
⎧⎛ 2 A ⎞ 2
⎟ ,k = 0
⎪⎜
⎪⎝ π ⎠
=⎨
2
⎞
2A
⎪⎛
⎟
⎜
⎪⎜ π 1 − 4k 2 ⎟ , k ≠ 0
⎠
⎩⎝
(
)
(c)
Px =
(d)
1
TP
∫
∞
X (t ) dt =
2
∑C
k = −∞
TP
2
k
9.Compute the Fourier transform of the following signals.
(a) x1 (n) = u (n) − u (n − 6)
(b) x 2 (n) = 2 n u (n − 6)
(c) x3 (n) = cos(π ) n [u (n) − u (n − 6)]
3
solution:
(a) x1 (n) = u (n) − u (n − 6)
α
∑
n = −α
5
x ( n) = ∑ 1 = 6
n =0
for ω=0,
l −1
5
n =0
n=0
X (0) = 0, ∑ A = ∑1 = 6
for ω # 0,
(20-Marks)
l −1
X ( w) = ∑ Ae − jwn
n=0
1 − e − jwl
1 − e − jw
− j ( w )(l − 1) sin( wl 2 )
2
= Ae
sin w
2
=A
⎧
⎪
⎪⎪
X ( w) = ⎨ Al , w = 0
sin wl
⎪
2 , w#0
⎪ Al
w
sin
⎪⎩
2
⎧
⎪
⎪
= ⎨ 6, w = 0
sin w
⎪
, w#0
⎪ sin w
2
⎩
(b). x 2 (n) = 2 n u (n − 6)
X 2 (Z ) =
α
∑α x
n=−
2
(n)e − jewn
α
= ∑ 2 n e − jwn
n =6
For w#0,
α
5
n −0
n=0
X 2 ( w) = ∑ (2e − jw ) n − ∑ (2e − jw ) n
1
1 − (2e − jw ) 6
−
1 − 2e − jw
1 − 2e − jw
64e − j 6 w
=
1 − 2e − jw
=
for w=0,
α
α
n =6
n =0
5
X 2 (0) = ∑ 2 n = ∑ 2 n − ∑ 2 n
n=0
1
1− 2
−
1− 2 1− 2
= 1 − 1 + 2 6 = −64
6
=
⎧
⎪
⎪
⎪
∴ X ( w) = ⎨ − 64, w = 0
⎪ 64e − j 6 w
⎪
, w#0
⎪⎩ 1 − 2e − jw
(c).
x3( n ) = cos(πn )[u (n) − u (n − 6)]
3
x1 (n) = u (n) − u (n − 6)
x3 (n) = cos(πn ) X 1 (n)
3
by modulation property,
1
1
π
π
X ( w) = X ( w + ) + X ( w − )
2
3
2
3
Programming Languages and Compiling
Techniques
IT 5015
for
Second Semester
Sample Question
1. (a) Define the following terms.
(10 Marks)
(a) class, instance variables, constructors, methods.
(b) parent class or super class
(c) abstract
(d) interface
(e) polymorphic
(b) Using expression Abstract Syntax of Jay and meaning of an expression,
write the variable class.
(6 Marks)
2.(a) Using expression Abstract Syntax of Jay and meaning of an expression,
write the value class, intvalue subclass and Undefvalue subclass of the value
class.
(10 Marks)
(b) Using expression Abstract Syntax of Jay and meaning of an expression,
write the Binary class.
( 6 Marks)
3.(a) Evaluate the following lambda expression.
( 6 Marks)
(a) ((λ x. x * x ) 2 )
(b) ( ( λy . ( ( λx . xyz ) a ) ) b )
(c) ( ( λx . x * x ) 5 )
(d ) ( ( λy . ( ( λx . x + y + z ) 3 ) ) 2 )
(e) ( ( λv . ( λω . ω) ( ( λx . x) y ( λz . z ) ) )
(f)(( λx . ( ( λy . ( ( λz. xyz ) a ) )b ))c)
4. Evaluate the following expression wing your. Scheme interpreter.(10 Marks)
(a) ( null? ( ) )
(b) ( null? ̀( a b c d e ) )
(c) ( car ̀ ( a ( b c ) d e ) )
(d) ( cdr ̀ ( a ( b c ) d e ) )
(e) ( cardr ̀ ( a ( b c ) d e ) )
(f)(equal? 5 5)
(g)(equal? '(1 2) '(2 1))
(h)(append '(1 2) '(3 4))
(i)(list '(1 2) '(3 4) 5)
(j)(cons 10 evens)
5. Evaluate the scheme expression ( sum 1 2 3 4 5 ) showing all the steps in
the expression of the sum function.
(6 Marks)
6. Write a scheme function for get and onion with the following application.
(a)an application of get function =(get 'z '((x 5) (y 3) (z 1)))
(b) an application of onion function =(onion 'z 1 '((x 5) (y 3) (z 1)))
( 10 Marks)
7. Use extended symbolic differentiation program to differentiate the following.
2.X+1
(6 Marks)
8. Write a Scheme function named elements which counts the number of
elements in a list: for example: ( elements ̀( 1 ( 2 ( 3 ) 4) 5 6 ) ) is 6, while
the length of the same list is 4.
( 6 Marks)
9. Draw the table of Properties of Predicode Logic Expressions. ( 6 Marks)
10. Transform the following predicate to conjunctive normal form.( 10 Marks)
∀x(¬literate( x) ⊃ (¬writes ( x) ∧ ¬∃y (reads( x, y ) ∧ book ( y ))))
11. Draw a small family tree for the following.
parent ( A, B ) :
father ( A, B )
parent ( A, B ) :
mother ( A, B )
grandparent ( C, D ) :
mother ( mary, sue ).
mother ( mary, bill ).
mother ( sue, mary ).
mother ( sue, jeff).
mother ( jane, ron ).
father ( john, sue ).
father ( john, bill ).
( 6 Marks)
parent ( C, E ) . parent ( E .D )
father ( bob, nanoy ).
father ( bob, jeff ).
father ( bill, ron ).
12. Draw search tree for the Query d ( x, 2 * x + 1, Ans ).
(6 Marks)
13. Consider the family tree. Draw a search tree, in the style for the query
grandparent ( Who, ron ).
( 3 Marks)
14.Define a new relation “ cousin” that defines the relationship between any
two people whose parents are siblings. Write a query for this expanded program
that will identify all people who are cousins of Ron.
(3 Marks)
15. By forming the passing table verify that the grammar with the following
productions is YACC grammar.
accept
: expr
expr
: expr + expr
(16 Marks)
│expr * expr
│ ( expr )
│ NUM
16.(a) Explain why bottom-up passing is more generally applicable than topdown passing.
(4 Marks)
(b) Explain what is meant by shift- reduce and reduce- reduce conflicts in
bottom-up passing.
(4 Marks)
(c) By forming the passing table verify that the grammar with the following
productions is LR (1).
( 8 Marks)
1.
S
axF
2.
F
,JF
3.
│ε
4.
J
5.
│x
ax
1. E
E + T
2. E
T
3. T
T *F
4. T
F
5. F
(E)
6. F
x
In which E is the sentence symbol. The grammar may be used a basis for
bottom-up passing as is shown by passing the following sentence.( 16 Marks)
x + x + x * x.
17. Explain about symbol tables with example.
(10 Marks)
18. Explain about Type tables with example.
(10 Marks)
19. What are the main characteristics of object oriented programming
languages?
(6 Marks)
20. Write down the roles of Ada.
(6 Marks)
21. What are the properties of the address of the value x?
(8 Marks)
22. Explain about three types of storage.
(8 Marks)
23. Draw the run time stack for the following program.
(8 Marks)
Program demo (output);
var x,y:real;
procedure first;
var c, d: integer;
procedure second;
var p, q: integer;
begin
.
.
end;
procedure third;
var m, n: integer;
begin
.
.
end;
begin
second;
Third
Begin
first
end
25. Explain two phase when garbage collection.
( 4 Marks)
26. In many language implementations, characters occupy as much storage
space as integers. Give argument for and against this situation.
( 2 Marks)
27. What are good reasons for compliers to produce intermediate code?
Describe three well- known examples.
( 10 Marks)
28. Produce three-address code, P-code and Byte code for the following
statements.
(a) if ( expression ) statements else statements
(16 Marks)
(b) while ( expression ) statement.
29. Produce three-address code for each of the following expressions.( 3 Marks)
(a) a +b + c
(b) ( a + b ) * ( c + d ) * ( e + f )
(c) x * y * Z + -p * q
30. Considers the piece of C code:
n=0;
sum 2 = 0;
while ( n < 10 )
( 3 Marks)
{ n = n + 1;
M=2*n;
Sum2= sum2 + m ;
}
******************************
Programming Languages and Compiling Techniques
IT 5015
for
Second Semester
Sample Question
1. (a) Define the following terms.
(10 Marks)
(a) class, instance variables, constructors, methods.
(b) parent class or super class
(c) abstract
(d) interface
(e) polymorphic
Soln
Sol:
(a) In an object-oriented language the data type is bound together with the initialization and other
operations on that type. The type is referred to as a class, local variables are called instance variables,
their initializingas are accomplished by special methods called constructors, and other operations are
implemented by methods.
(b)A class can be declared as a subclass of another class, which is called the parent class or super class.
(c)Java allows a class to be declared abstract, in which case one or more of its methods are declared to be
abstract.
(d)An interface declares a collection of features identified by abstract methods.
(e)The term polymorphic means "having many forms."In object-oriented languages polymorphism refers
to the late binding of a call to a specific method in an object.
(b) Using expression Abstract Syntax of Jay and meaning of an expression, write the
variable class. (6 Marks)
sol:
class Variable Extends Expression{
String id;
public Variable(String id) {this.id=id;}
public boolean equals(Object obj){
String s=((Variable)obj).id;
Return id.equalsIgnorCase(s);
}
public int hashcode(){ return id.hashcode;}
public Value M(State sigma) {
return (Value)(sigma.get(this));
}
}
2.(a) Using expression Abstract Syntax of Jay and meaning of an expression, write the
value class, intvalue subclass and Undefvalue subclass of the value class.(10 Marks)
sol:
class Value Extends Expression{
public Value(int i) {return new IntValue(i);}
public Value(Boolean b) {return new BooleanValue(b);}
public Value() {return new UndefValue();}
public boolean isUndef(){return false;}
public int intVal(){ return -1;}
public boolean boolanVal(){ return false;}
public Value M(State sigma){return this;}
}
}
class IntValue extends Value{
int intVal;
public intValue(int i){intValue=i;}
public intVal(){return intVal;}
class undefValue extends Value{
public UndefValue extends Value{returns true;}
}
(b) Using expression Abstract Syntax of Jay and meaning of an expression, write the
Binary class.
Sol:
class Binary Extends Expression{
Operator op;
Expression term1,term2;
Public Binary(Operator o, Expression t1, Expression t2){
op=p; term1=t1; term2=t2;
}
public Value M(State sigma) {
( 6 Marks)
return op.apply(term1.M(sigma), term2.M(sigma));
}
}
3.(a) Evaluate the following lambda expression.
( 6 Marks)
(a) ((λ x. x * x ) 2 )
(b) ( ( λy . ( ( λx . xyz ) a ) ) b )
(c) ( ( λx . x * x ) 5 )
(d ) ( ( λy . ( ( λx . x + y + z ) 3 ) ) 2 )
(e) ( ( λv . ( λω . ω) ( ( λx . x) y ( λz . z ) ) )
(f)(( λx . ( ( λy . ( ( λz. xyz ) a ) )b ))c)
Soln
(a) ((λ x. x * x ) 2 )=2*2=4
(b) ( ( λy . ( ( λx . xyz ) a ) ) b )= ( ( λy . ayz ) b )=abz
(c) ( ( λx . x * x ) 5 )=5*5=10
(d) ( ( λy . ( ( λx . x + y + z ) 3 ) ) 2 )= ( ( λy . 3+y+z ) 2 )=3+2+z=5+z
(e) ( ( λv . ( λω . ω) ( ( λx . x) y ( λz . z ) ) )= ( ( λv . ( λω . ω) ( y ( λz . z ) ) )
(f) (( λx . ( ( λy . ( ( λz. xyz ) a ) )b ))c)= (( λx . ( ( λy . xya)b ))c)= (( λx .xba)c)=cba
4. Evaluate the following expression wing your. Scheme interpreter.
(a) ( null? ( ) )
(b) ( null? ̀( a b c d e ) )
(c) ( car ̀ ( a ( b c ) d e ) )
(d) ( cdr ̀ ( a ( b c ) d e ) )
(e) ( cardr ̀ ( a ( b c ) d e ) )
(f)(equal? 5 5)
(g)(equal? '(1 2) '(2 1))
(h)(append '(1 2) '(3 4))
(i)(list '(1 2) '(3 4) 5)
(j)(cons 10 evens)
Sol;
( 10 Marks)
(a) #t
(b) #f
(c) a
(d) (( b c ) d e )
(e) ( b c )
(f) #t
(g) #f
(h) (1 2 3 4 )
(i) ((1 2) (3 4) 5)
(j) (10 0 2 4 6 8)
5. Evaluate the scheme expression ( sum 1 2 3 4 5 ) showing all the steps in the
expression of the sum function.
( 6 Marks)
sol:
( sum 1 2 3 4 5 )
=(+ 1( sum 2 3 4 5 ))
=(+ 1(+ 2( sum 3 4 5 )))
=(+ 1(+ 2( +3(sum 4 5 ))))
=(+ 1(+ 2( +3(+ 4(sum 5 )))))
=(+ 1(+ 2( +3(+ 4(+5(sum ))))))
=(+ 1(+ 2( +3(+ 4(+5 0)))))
=(+ 1(+ 2( +3(+ 4 5))))
=(+ 1(+ 2( +3 9)))
=(+ 1(+ 2 12))
=(+ 1 14)
=15
6. Write a scheme function for get and onion with the following application.
(a)an application of get function =(get 'z '((x 5) (y 3) (z 1)))
(b) an application of onion function =(onion 'z 1 '((x 5) (y 3) (z 1)))
Sol:
A scheme function for get function
(define (get id sigma)
(if (equal? id (caar sigma))) (cadar sigma)
(get id (cdr sigma))
))
(a)an application of get function =(get 'z '((x 5) (y 3) (z 1)))
( 10 Marks)
=(get 'z '((y 3) (z 1)))
=(get 'z '(z 1))
=1
A scheme function for onion function
(define (onion id val sigma)
(if (equal ? id (caar sigma))
(cons (list id val)(cdr sigma))
(cons (car sigma)(onion id val(cdr sigma)))
))
(b) an application of onion function =(onion 'z 2 '((x 5) (y 3) (z 1)))
=(cons '(x 5) (onion 'z 2 '( (y 3) (z 1))))
=(cons '(x 5) (cons '(y 3)(onion 'z 2 '(z 1))))
=(cons '(x 5) (cons '(y 3)(cons '(z 2) '())))
='((x 5) (y 3) (z 2))
7. Use extended symbolic differentiation program to differentiate the following. (6 Marks)
2.x+1
Sol:
(diff 'x "(+(* 2 x) 1))
=(list '+ (diff 'x '(* 2 x)) (diff 'x 1))
=(list '+(list '+ ( list '* 2 (diff 'x 'x)) ( list '* x (diff 'x 2))) (diff 'x 1))
=(list '+(list '+ ( list '* 2 1) ( list '* x (diff 'x 2))) (diff 'x 1))
=(list '+(list '+ '(* 2 1) ( list '* x (diff 'x 2))) (diff 'x 1))
=(list '+(list '+ '(* 2 1) ( list '* x 0)) (diff 'x 1))
=(list '+'( + '(* 2 1) '(* x 0)) (diff 'x 1))
=(list '+(list '+ '(* 2 1) '(* x 0)) (diff 'x 1))
=(list '+( + '(* 2 1) '(* x 0)) 0)
=(list '+(+ 2 0))0)
='(+ 2 0)
=2
8. Write a Scheme function named elements which counts the number of elements in a
list: for example: ( elements ̀( 1 ( 2 ( 3 ) 4) 5 6 ) ) is 6, while the length of the same
list is 4.
sol:
(define (elements 1st)
(if (null? 1st) 0
( 6 Marks)
(if (list? (car 1st))
(+(elements (car 1st)) (elements (cdr 1st)))
(+1 (elements (cdr 1st)))
)))
9. Draw the table of Properties of Predicode Logic Expressions.
( 6 Marks)
Sol:
Properties of Predicate Logic Expressions
Property
Meaning
Commutativity
p∨q≡q∨p
p∧q≡q∧p
Associativity
(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)
Distributivity
p ∨ q ∧ r ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
Idempotence
p∨p ≡p
p∧p ≡p
Identity
p ∨ ¬p ≡ true
p ∧ ¬p ≡ false
deMorgan
¬( p ∨ q) ≡ ¬p ∧ ¬q
¬( p ∧ q) ≡ ¬p ∨ ¬q
Implication
p ⊃ q ≡ ¬p ∨ q
Quantification
¬∀xP( x) ≡ ∃x¬P( x)
¬∃xP( x) ≡ ∀x¬P( x)
10. Transform the following predicate to conjunctive normal form.
∀x(¬literate( x) ⊃ (¬writes( x) ∧ ¬∃y (reads( x, y ) ∧ book ( y ))))
Soln:
∀x(¬literate( x) ⊃ (¬writes ( x) ∧ ¬∃y (reads( x, y ) ∧ book ( y ))))
Applying step 1 removes the implication,
∀x(literate( x) ∨ (¬writes ( x) ∧ ¬∃y (reads( x, y ) ∧ book ( y ))))
Step 2 moves negations
∀x(literate( x) ∨ (¬writes ( x) ∧ ¬∀y (¬(reads( x, y ) ∧ book ( y )))))
= ∀x(literate( x) ∨ (¬writes ( x) ∧ ∀y (¬(reads( x, y ) ∨ ¬book ( y ))))
Step 4 moves all quantifiers to the left and then drops them,
∀x∀y (literature( x) ∨ (¬wirtes ( x) ∧ (¬(reads( x, y ) ∧ book ( y )))))
= literature( x) ∨ (¬wirtes ( x) ∧ (¬(reads( x, y ) ∨ ¬book ( y )))
Converting this to conjunctive normal form as follows;
literature( x) ∨ (¬writes ( x) ∧ (¬reads( x, y ) ∨ ¬book ( y )))
= (literature( x) ∨ (¬writes ( x)) ∧ (literature( x) ∨ ¬reads( x, y ) ∨ ¬book ( y ))
= (¬writes ( x) ∨ literature( x)) ∧ (¬reads( x, y ) ∨ ¬book ( y ) ∨ literature( x))
These two conjuncts now convert to implications
( 10 Marks)
(¬writes( x) ∨ literature( x)) ∧ (¬reads( x, y ) ∨ ¬book ( y ) ∨ literature( x))
= ( writes ( x) ⊃ literature( x)) ∧ (¬(¬reads( x, y ) ∨ ¬book ( y )) ⊃ literature( x))
= ( writes ( x) ⊃ literature( x)) ∧ ((reads( x, y ) ∨ ¬book ( y )) ⊃ literature( x))
Finally the following Horn clauses:
literature( x) ← writes( x)
literature( x) ← reads( x, y ), book ( y )
11. Draw a small family tree for the following.
parent ( A, B ) :
father ( A, B )
parent ( A, B ) :
mother ( A, B )
( 6 Marks)
grandparent ( C, D ) : parent ( C, E ) . parent ( E .D )
mother ( mary, sue ).
mother ( mary, bill ).
mother ( sue, mary ).
mother ( sue, jeff).
mother ( jane, ron ).
father ( john, sue ).
father ( john, bill ).
father ( bob, nanoy ).
father ( bob, jeff ).
father ( bill, ron ).
Soln:
John
bob
mary
Sue
nancy
bill
jeff
jane
ron
12. Draw search tree for the Query d ( x, 2 * x + 1, Ans ).
Soln:
"Father"link=
"Mother" link=
(6 Marks)
d(x,2*x+1,Ans)
Ans=281+x*0+0
10
1
d(x,2*x,_G268)
_G268=2+1+x*0
2
d(x,2,_G278)
4
d(x,x,_G275)
5
_G278=0
3
d(x,2,0)
7
d(x,1,_G269)
8
9 _G269=0
d(x,1,0)
6
_G275=1
d(x,2*x+1,Ans)
13. Consider the family tree. Draw a search tree, in the style for the query grandparent ( Who, ron ).
( 3 Marks)
Sol:
Grandparent(who,ron)
1
parent(who,E)
Who=John
E=sue
2
father(who,E)
3
parent(E,ron)
4
fail
14.Define a new relation “ cousin” that defines the relationship between any two people whose parents
are siblings. Write a query for this expanded program that will identify all people who are cousins of
Ron.
(3 Marks)
Soln:
Cousin(X,Y): -parent(U,X), parent(V,Y),sibling(U,V), X\=Y,
Sibling(U,V):-parent(P,U), parent(P,V), U\=V
This is a query to identify all the cousins of Ron:
?-cousin(Who, ron);
15. By forming the passing table verify that the grammar with the following productions is
YACC grammar.
(16 Marks)
accept
: expr
expr
: expr + expr
│expr * expr
│ ( expr )
│ NUM
Soln:
accept
: 0expr1
expr
: 0,2,4,5expr1,6,7,8 +4 expr7
│0,2,4,5expr1,6,7,8 *5 expr8
│0,2,4,5 ( 2expr 6)9
│0,2,4,5 NUM3
Parsing table
Expr
0
+
*
S1
(
)
S2
1
S4
Num
S3
S5
R0
2
S6
S2
3
R4
4
S7
S2
S3
5
S8
S2
S3
R4
6
R4
S4
S5
⊥
R4
S3
R4
R4
R4
S9
7
R1
R1
R1
R1
R1
R1
R1
8
R2
R2
R2
R2
R2
R2
R2
9
R3
R3
R3
R3
R3
R3
R3
16.(a) Explain why bottom-up passing is more generally applicable than top-down passing.
(4 Marks)
(b) Explain what is meant by shift- reduce and reduce- reduce conflicts in bottom-up
passing.
(4 Marks)
(c) By forming the passing table verify that the grammar with the following productions
is LR (1).
Soln:
( 8 Marks)
1.
S
axF
2.
F
,JF
3.
│ε
4.
J
5.
│x
ax
16.(a) Basically because each production does not require to be recognized until it has been fully formed
on the stack, rather than from a single terminal symbol alone.
(b)Shift-reduce conflict- both a shift and a reduce action appear possible at a particular point in a parse.
Reduce-reduce conflict- reduction by more than one production seems possible at a particular point in a
parse.
(c)
1.
S
2.
F
1
3,6
3.
4.
J
5
E + T
2. E
T
3. T
T *F
4. T
F
6. F
a 8x9
│5 x 10
1. E
5. F
, 5 J 6 F7
│3,6 ε 3,6
5.
17.
a 2 x 3 F4
(E)
x
In which E is the sentence symbol. The grammar may be used a basis for bottom-up
passing as is shown by passing the following sentence.
( 16 Marks)
x + x + x * x.
sol:
Input String
Stack
Production
x+x+x*x
Sentential form
(S/R)
X+x+x*x
x+x+x*x
X
X+x+x*x
(S)
x+x+x*x
F
F
x
F+x+x*x
(R)
x+x+x*x
T
T
F
T+x+x*x
(R)
x+x+x*x
E
E
T
E+x+x*x
(R)
x+x+x*x
E+
E+x+x*x
(S)
x+x+x*x
E+x
E+x+x*x
(S)
x+x+x*x
E+F
F
x
E+F+x*x
(R)
x+x+x*x
E+T
T
F
E+T+x*x
(R)
(S)x+x+x*x
E
E
E+T
E+ x*x
(R)
x+x+x*x
E+
E+ x*x
(S)
x+x+x*x
E+x
E+ x*x
(S)
x+x+x*x
E+F
F
x
E+ F*x
(R)
x+x+x*x
E+T
T
F
E+ T*x
(R)
x+x+x*x
E+T*
E+ T*x
(S)
x+x+x*x
E+T*x
E+ T*x
(S)
x+x+x*x
E+T*F
F
x
E+ T*x
(R)
x+x+x*x
E+T
T
+F
E+ T
(R)
x+x+x*x
E
E
E+T
E
(R)
18. Explain about symbol tables with example.
(10 Marks)
Sol:
Symbol Table
The principal function o fa symbol table is to provide a mapping between a variable and its type.
The two basic operations associated with the symbol table are:
1. corresponding to the defining occurrence of variable, e.g.
Int x
The name of the variable, along with its type is inserted in the symbol table
2.corresponding to an applied occurrence of a variable, e.g.
X=5;
The symbol table is searched to find the type of the variable.
The complexity of the symbol table and the routines which operate on it depend on :
•
The language being implemented
•
The important attached to the efficiency of the compiler
void scopes()
{int a,b,c; /*level 0*/
..
{int a,b; /*level 1a*/
}
}
{ float c,d; /*level 1b*/
{int m; /*level 2*/
..
}
}
}
19. Explain about Type tables with example.
Sol:
Type Table
(10 Marks)
Within the compiler there has to be a unique way of representing each of the types in a particular
program. If the source language allowed only a finite number of types, then a distinct integer could be
uded to represent each of the allowable types. Some early languages such as FORTRAN could be dealt
with in this way , though more recent languages, on the whole , cannot. In considering a suitable
representation for types in a program , the following factors usually need to be taken into account:
•
The highly structured and recursive nature of many types
•
The common operations which the compiler will have to perform on types
Common operations on types in C include:
•
Finding the type of a field of a struct or a union
•
Finding the type of a element of an array
•
Finding the type of the result of a function
For example
Typedef{
Int day;
Int mth;
Int year;
}dob;
Struct
int
day
int
mth
int
year
Figure 6.1
Typedef long int [9][19] matrix;
arr
9
arr
19
long
int
20. What are the main characteristics of object oriented programming languages?(6Marks)
Sol:
the main characteristics of object oriented programming languages are
•
Data abstraction and encapsulation
•
Polymorphism
•
Inheritance
21. Write down the roles of Ada.
(6 Marks)
Soln;
The roles of Ada are
•
An identifier may be made directly visible by a use clause only if it would not be directly visible
if the clause were not present;
•
An identifier made directly visible by a use clause must be declared in one and only one package
named in the use clause.
22. What are the properties of the address of the value x?
(8 Marks)
Soln:
The variable x is an object that , at a given time, may have a value associated with it , and it is the storage
space for this value with which we will be concerned. The storage allocated for the value of x will have
an associated address referred to , as the address of x. This address should have the following properties.
•
It should be sufficiently large to hold any of the range of values that may be taken by x
•
It should be available throughout the lifetime of x
•
It should be expressible in a form that the code generator can use to generate code to access the
value of x at run time.
23. Explain about three types of storage.
(8 Marks)
Allocating storage space for the lifetime of a variable, there are three possibilities:
1. The lifetime of the variable is the lifetime of the program and the space for its value, once
allocated, cannot later be released. Such storage is referred to as static storage.
2. The lifetime of the variable is a particular block, function or procedure in which it is declared,
so that the storage allocated may be released when the block, function or procedure in which it it declared
is left. Such storage is referred to as dynamic storage.
3. Storage may be allocated for values, not necessarily associated with variables, at a particular
point in the execution of a program not necessarily corresponding to the start of a block or the entry to a
procedure. The storage is then required form that point on until it is released either by a language
mechanism or through simply geing no longer reachable from the program. However, the moment of this
release may, in general, not be detectable at compile time and is only known at run time. Such storage is
referred to as global storage.
24. Draw the run time stack for the following program.
Program demo (output);
var x,y:real;
procedure first;
(8 Marks)
var c, d: integer;
procedure second;
var p, q: integer;
begin
.
.
end;
procedure third;
var m, n: integer;
begin
.
.
end;
begin
second;
Third
Begin
first
end
sol:
25. Explain two phase when garbage collection.
( 4 Marks)
Garbage collection is required, it proceeds in two phases:
1. A marking phase in which heap storage that is accessible via program variables is marked by
inserting values in a bit map.
2. A compaction phase in which all the accessible space is moved to one end of the heap, leaving
the reusable space in one contiguous block at the other end. Care, of course, must be taken to ensure all
pointer values are changed appropriately.
26. In many language implementations, characters occupy as much storage space as
integers. Give argument for and against this situation.
( 2 Marks)
sol:
for-makes addressing simpler
against-requires more space
27. What are good reasons for compliers to produce intermediate code? Describe three well- known
examples.
( 10 Marks)
There are good reasons for compilers to produce intermediate code, as a first step towards the
production of code for an actual machine. Reasons include:
•
Providing a clear distinction between the machine independent parts og the compiler and
the dependent parts;
•
Minimizing the effort required to port the compiler to a new environment;
•
Minimizing the effort involved in implementing m languages on n machine;
•
Ease of optimization.
Three well-known examples:
1. Three-address code.
2. P-code, a language-specific intermediate code upon which the majority of implementations of
Pascal are based.
3. Bytecode used by the Java Virtual Machine.
28. Produce three-address code, P-code and Byte code for the following statements.
(a) if ( expression ) statements else statements
(b) while ( expression ) statement.
Sol:
(a) if ( expression ) statements else statements
Three-address code
Code to evaluate expression
T1=not expression
If t1 goto L1
Code for statement1
Goto L2
L1:
code for statement2
L2:
Pcode
Code to put the value of expression on top of the stack
FJP
L1
Code to implement statement1
(16 Marks)
UJP
L2
L1
Code to implement statement2
L2
Byte code
Bytecode to put the value of expression on top of the stack
Ifeq L1
Bytecode to implement statement1
Goto L2
L1
Bytecode to implement statement2
L2
(b) while ( expression ) statement.
Three-address code
L1:
Code to evaluate expression
T1=not expression
If T1 goto L1
Code for statement
Goto L1
L2:
Pcode
L1
Code to put the value of expression on top of the stack
FJP
L2
Code to implement statement1
UJP
L1
L2
Byte code
L1
Bytecode to put the value of expression on top of the stack
Ifeq L2
Bytecode to implement statement1
Goto L1
L2
29. Produce three-address code for each of the following expressions.
( 3 Marks)
(a) a +b + c
(b) ( a + b ) * ( c + d ) * ( e + f )
(c) x * y * Z + -p * q
(a)
t1 = a + b
t2 = t1 + c
(b)
t1 = a + b
t2 = c + d
t3 = t1 * t2
t4 = e + f
t5 = t3 * t4
(c)
t1 = x * y
t2 = t1 * z
`
t3 = -p
t4 = t3 * q
t5 = t2 + t4
30. Considers the piece of C code:
n=0;
sum 2 = 0;
while ( n < 10 )
{ n = n + 1;
M=2*n;
Sum2= sum2 + m ;
}
Replace the code with:
m = 0;
sum2 = 0;
while(m<20)
{
m = m + 2;
sum2 = sum2 + m;
}
******************************
( 3 Marks)
Computer Graphics and Applications
IT 5016
for
Second Semester
Sample Question
1. Let the variable r represent the gray levels in the image to be enhanced. The
assumption is that pixel values are continuous quantities in the interval [1, 0], r=0
representing black and r=1 representing white. Explain briefly the advantage of
histogram equalization.
(10 marks)
2. Discuss about to satisfy particular histogram shapes capable of highlight certain
gray level images in an image is desirable.
(10 marks)
3. An image has the gray level PDF Pr (r) shown in the following diagram. It is
desired to transform the gray level of this image and to show that the resulting
density Ps(s). Assume continuous quantities and find the transformation.
Pr (r)
2
1
1
2
r
Figure. Probability Density Function
(10 marks)
4. Discuss the Homomorphic filtering for enhancement in the frequency domain.
(10 marks)
5. What is the purpose of color model? Explain briefly.
(10 marks)
6. What are the intensity slicing?
(10 marks)
7. Discuss about Image Subtraction and Averaging and their application.
(20 marks)
8. Discuss the degradation process and degradation model for continuous functions.
(20 marks)
9. (a) Derive and construct a circulant matrix for H.
(b) Suppose that A = 4 and B = 3. Construct the matrix for H and describe its all
elements.
(10 marks)
10. The objective of image restoration is to estimate an original image f from a
degraded image g and some knowledge or assumptions about H and η . Seeking an
estimate of f using equation g = Hf + n; Consider an unconstrained approach to the
least square restoration.
(10 marks)
11. Write down the constrained least squares restoration procedure.
(10 marks)
12. Discuss about one of geometric transformation which define the rearrangement
of pixels on the image plane.
(10 marks)
13. Discuss about one of geometric transformation which deal with the assignment
of gray levels to pixels in the spatially transformed image.
(10 marks)
14. What is data compression and how many data redundancies in digital image
compression.
(10 marks)
15. Explain an image compression system model briefly.
(10 marks)
16. An 8-level image has the gray level distribution shown in following Table.
Determine the exact level of redundancy and illustrate data compression with
graph.
Pr(rk)
0.19
0.25
0.21
0.16
0.08
0.06
0.03
0.02
rk
r0=0
r1=1/7
r2=2/7
r3=3/7
r4=4/7
r5=5/7
r6=5/7
r5=5/7
Code 1
000
001
010
011
100
101
110
111
l1(rk)
3
3
3
3
3
3
3
3
Code 2
11
01
10
001
0001
00001
000001
000000
L2(rk)
2
2
2
3
4
5
6
6
(10 marks)
17. Discuss about the Channel Encoder and Decoders.
(10 marks)
18. By using Huffman’s Coding, compute these facts;
(a) Lavg (b) Huffman source reduction and (c) code assignment procedure from the
following facts.
Symbol
a2
a6
a1
a4
a3
a5
Original Source
Probability
0.4
0.3
0.1
0.1
0.06
0.04
(10 marks)
Computer Graphics and Applications
IT 5016
for
Second Semester
Sample Answer & Question
1. Let the variable r represent the gray levels in the image to be enhanced. The
assumption is that pixel values are continuous quantities in the interval [1, 0],
r=0 representing black and r=1 representing white. Explain briefly the
advantage of histogram equalization.
(10 marks)
-r represent the gray levels in the image to be enhanced
-pixel values are continuous quantities between interval [1, 0]
-r=0 black, r=1 white.
-pixel values to be in the interval [0, L-1]
For any r in the interval [0, 1],
s = T (r)
eq.(1)
produce a level s for every pixel value r
eq.(1) satisfies the conditions:
(a) T(r) is single valued and monotonically increasing in the interval 0 ≤ r ≤ 1;
(b) 0 ≤ T(r) ≤ 1 for 0 ≤ r ≤ 1
The inverse transformation is
r = T-1 (s),
0≤s≤1
eq.(2)
eq.(2) also satisfies conditions (a) and (b)
-Pr (r) is probability density functions of original gray level.
-Ps(s) is probability density functions of transformation gray level.
From elementary probability Theory,
s = ⎡⎢ p (r ) dr ⎤⎥
Ps(s)
eq.(3)
r
ds ⎦
⎣
1
T(rk)
sk = T(rk)
0
rk
1
r
Fig. Gray Level Transformation Function
r
s = T( rk ) =
∫0 pr (w) dw
,
0≤r≤1
eq.(4)
where w is dummy variable, s is cumulative distribution function (CDF) of r
ds
= pr (r )
dr
eq.(5)
substituting into eq.(3);
⎡
ps (s) = ⎢ pr (r ).
⎣⎢
= [1]
1 ⎤
⎥
pr (r ) ⎦⎥ r =T −1 ( s )
r =T −1 ( s )
=1
,
0≤s≤1
which is a uniform density in the interval of definition of the transformed
variable s. This result is independent of the inverse transformation function.
----------------------------------- -------------------------------------- ----------------------------2. Discuss about to satisfy particular histogram shapes capable of highlight
certain gray level images in an image is desirable.
(10 marks)
Histogram Specification:
Although the histogram equalization method is quite useful, it does not lend
itself to interactive image enhancement applications. The reason is that this method is
capable of generating only one result; an approximation to a uniform histogram.
Let Pr (r) and Pz (z) be the original and desired probability density function
r
s = T(r) =
∫ P (w) dw
r
0
The transformation function
z
∫ P (w) dw
v = G(z) =
z
0
The inverse process, z = G-1 (v)
Instead of using v in the inverse process, the uniform levels s obtained from
the original image, the resulting levels z = G-1 (s).
The procedure can be summarized as follows.
(1) Equalize the levels of the original image using
r
s = T(r) =
∫ P (w) dw
0 ≤ r ≤1
r
0
(2) Specify the desired density function and obtain the transformation function G(z)
z
using
v = G(z) =
∫ P (w) dw
z
0
(3) Apply the inverse transformation function, z = G-1(s) , to the levels obtained in
step (1).
----------------------------------------------------------------------------------------3. An image has the gray level PDF Pr (r) shown in the following diagram. It is
desired to transform the gray level of this image and to show that the resulting
density Ps(s). Assume continuous quantities and find the transformation.
Pr (r)
2
1
1
2
r
Figure. Probability Density Function
(10 marks)
From figure,
-2r + 2
0
, 0≤ r ≤1
, else where
Pr (r) =
The transformation function,
r
s = T(r) =
∫ P (w) dw
r
0 ≤ r ≤1
0
r
s = ∫ (−2w + 2) dw
0
s = r2 + 2r
Solving this, - r2 + 2r = 0
r = T-1(s) = 1 ± 1 − s
Since r lies in [0,1],
r = T-1(s) = 1 − 1 − s
The probability density function,
dr ⎤
⎡
Ps (s) = ⎢ Pr (r ) ⎥
ds ⎦ r = T − 1 ( s )
⎣
dr ⎤
⎡
= ⎢(−2r + 2) ⎥
ds ⎦ r =1 −
⎣
1− s
d
⎤
⎡
= ⎢(2 1 − s ) (1 − 1 − s )⎥
ds
⎦
⎣
=1
, 0 ≤ s ≤1
Which is a uniform density in the desired range.
------------------------------------------------------------------------ ---------------------4. Discuss the Homomorphic filtering for enhancement in the frequency domain.
(10 marks)
Homomorphic Filtering:
The illumination-reflection model can be used as the basic for a frequency
domain procedure that is useful for improving the appearance of the an image by
simultaneous brightness range compression and contrast enhancement.
f (x, y) = i (x, y) r (x, y)
z (x, y) = ln f (x, y)
= ln i (x, y) + ln r (x, y)
Then,
F {z (x, y)}
= F {ln f (x, y)}
= F{ ln i (x, y)} + F {ln r (x, y)}
Or,
Z (u, v) = I (u, v) + R (u, v)
Where I (u, v) and R (u, v) are the Fourier transforms of ln i(x, y) and ln r(x, y),
respectively.
f(x, y)
ln
FFT
H(u, v)
FFT-1
exp
Figure. Homomorphic filtering approach for image enhancement
g(x, y)
H(u, v)
γH
γL
D(u, v)
Figure. Cross section of a circularly symmetric filter function for use in homomorphic
filtering. D(u, v) is the distance from the origin.
--------------------------------- -----------------------------------------------------------5. What is the purpose of color model? Explain briefly.
(10 marks)
The purpose of a color model is to facilitate the specification of colors in some
standard. A color model is a specification of a 3-D coordinate system and a subspace
within that system where each color is represented by a single point. Most color
models in use today are oriented either toward hardware or toward application where
color manipulation is a goal.
RGB (red, green, blue) model for color monitors and video cameras;
CMY (cyan, magenta, yellow) model for color printers;
YIQ (luminance, inphase, quadrature) model for color TV broadcast;
HSI (hue, saturation, intensity) model for image manipulation;
HSV (hue, saturation, values) model for image manipulation;
(Fig.4.44.)
(page. 226)
RGB color model is based on Cartesian coordinate system. The color subspace
of interest is the cube. RGB values are at three corners; CMY are at three corners;
Black is at the origin; and White is at the corner farthest from the origin.
The gray scale extends from black to white along the line joining these two
points. Colors are points on or inside the cube. Images in the RGB color model
consist of three independent image planes, one for each primary color. These three
images combine on the phosphor screen to produce a composite color image. The
problem is one of enhancing a color image of a human face, part of which is hidden in
a shadow.
CMY color models are the secondary colors of light (the primary colors of
pigments). Cyan subtracts red light from reflected white light, which itself is
composed of equal amounts of red, green and blue light. Most devices that deposit
colored pigments on paper, require CMY data input or perform an RGB to CMY
conversion internally.
⎡C ⎤ ⎡1⎤ ⎡ R ⎤
⎢ M ⎥ = ⎢1⎥ − ⎢G ⎥
⎢ ⎥ ⎢⎥ ⎢ ⎥
⎢⎣Y ⎥⎦ ⎢⎣1⎥⎦ ⎢⎣ B ⎥⎦
HSI color model owes its usefulness to two principal facts. First, the intensity
component, I, is decoupled from the color information in the image. Second, the hue
and saturation components are intimately related to the way in which human beings
perceive color.
----------------------------------- ------------------------------------------ ------------------------6. What are the intensity slicing?
(10 marks)
Assigning color to monochrome images based on various properties of their
gray level content. The technique of intensity (sometimes called density) slicing and
color coding is one of the simplest examples of pseudo-color image processing. If an
image is viewed as a 2-D intensity function, one of placing planes parallel to the
coordinate plane of the image; each plane then ‘slices’ the function in the area of
intersection.
In figure (a); f (x,y) = L, to slice a function into two levels. Any pixel whose gray
level is above the plane will be coded with one color, and any pixel below the plane
will be coded with the other.
M planes are defined at levels l1, l2, …….., lM.
Let l0 represents black [ f(x,y) = 0 ]
lL represents white [ f(x,y) = L ]
Assuming that 0 < M < L, the M planes partition the gray scale into M + 1
regions and color assignment are made according to the relation,
f (x,y) = Ck if f(x,y) ∈ Rk .
Ck is the color associated with the kth region Rk.
Figure (b) shows an alternative representation that defines the same mapping as figure
(a). Any input gray level is assigned one of two colors, it is above or below the value
of li .
(Fig 4.48.)
(Fig 4.49.)
(page 238)
(page 239)
----------------------- --------------------------------------------------------------------7. Discuss about Image Subtraction and Averaging and their application.
(20 marks)
Image Subtraction:
The difference between two images f(x, y) and h(x, y), expressed as
g(x, y) = f(x, y) – h (x, y)
is obtained by computing the difference between all pairs of corresponding pixels
from f and h.
A classic application of equation for enhancement is an area of medical
imaging called mask mode radiography. In this case h(x, y), the mask is an x-ray
image of a region of a patient’s body captured by an intensifier and TV camera
located opposite an x-ray source.
Image Averaging:
Consider a noisy image g(x, y) formed by the addition of noise η ( x, y ) to an
original image f(x, y). That is
g(x, y) = f(x, y) + η ( x, y )
at every pair of coordinates (x, y) the noise is uncorrelated and has zero average
value. The objectives of the following procedure is to reduce the noise effects by
adding a set of noisy images, gi{(x, y) }.
If the noise satisfies the constraints just stated, it is a simple problem to show
−
that if an image g (x, y) is formed by averaging M different noisy images.
1 M
g ( x, y ) =
∑ g i ( x, y )
M i =1
Then it follows that
E {g ( x, y )} = f (x, y)
1
σ g2 ( x , y ) = σ η2( x , y )
M
Where E {g ( x, y )} is the excepted values of g , σ g2 ( x , y ) and σ η2( x , y ) are the variances of
g and η all at coordinates (x, y). The standard derivation at any paint in the average
image is
1
σ g ( x, y ) =
σ η ( x, y )
M
------------------------- ------------------------------------------ ---------------------------8. Discuss the degradation process and degradation model for continuous
functions.
(20 marks)
(Fig. 5.1.)
(page 254)
H = an operator (or system)
η (x,y) = noise term
f (x,y) = input (original image)
g (x,y) = output (degraded image)
g(x,y) = H [ f(x,y)] + η (x,y)
g(x,y) = H [ f(x,y)]
let assume η (x,y) = 0,
----------------- (1)
H is linear if,
H [ k1 f1(x,y) + k2 f2 (x,y) ] = k1 H [ f1(x,y) ] + k2 H [ f2 (x,y) ] ------------- (2)
where k1, k2 are constants. If k1 = k2 = 1,
H [ f1(x,y) + f2 (x,y) ] = H [ f1(x,y) ] + H [ f2 (x,y) ]
which is called additivity property.
when f2 (x,y) = 0,
H [ k1 f1(x,y) ] = k1 H [ f1 (x,y) ]
which is called the property of homogeneity. x − α
--------------- (3)
----------------- (4)
g (x,y) = H [ f (x,y) ] is said to be position ( or space ) invariant if
----------------------------------- (5)
H [ f ( x − α , y − β )] = g ( x − α , y − β )
for any f (x,y) and any α and β .
For the continuous function: (slightly change in notation)
∞
f(x,y)= ∫ ∫ f (α , β ) δ ( x − α , y − β ) dα d β
----------------------------------- (6)
−∞
If
η (x,y) = 0,
∞
g(x,y) = H [ f(x,y) ] = H[ ∫ ∫ f (α , β ) δ ( x − α , y − β ) dα d β ] ------------------- (7)
−∞
If H is a linear operator and additivity property to integrals;
∞
g(x,y) = ∫ ∫ H [ f (α , β ) δ ( x − α , y − β )] dα d β
----------------- (8)
−∞
Since f (α , β ) is independent of x, y and homogeneity property.
∞
g(x,y) = ∫ ∫ f (α , β ) H [ δ ( x − α , y − β )] dα d β
----------------- (9)
−∞
The term
h ( x,α , y, β ) = H [ δ ( x − α , y − β )]
is called impulse response of H.
Substituting eq.(10) into eq.(9)
----------------- (10)
∞
g(x,y) = ∫ ∫ f (α , β ) h ( x,α , y, β )] dα d β
---------------- (11)
−∞
which is called the super-position integral of the first kind.
If H is position invariant,
H [ δ ( x − α , y − β )] = h ( x − α , y − β )
eq.(11) reduces;
---------------- (12)
∞
g(x,y) = ∫ ∫ f (α , β ) h ( x − α , y − β )] dα d β
---------------- (13)
−∞
If the present of additive noise,
∞
g(x,y) = ∫ ∫ f (α , β ) h ( x,α , y, β )] dα d β + η (x,y)
---------------- (14)
−∞
H is position invariant,
∞
g(x,y) = ∫ ∫ f (α , β ) h ( x − α , y − β )] dα d β + η (x,y)
---------------- (15)
−∞
Many types of degradations can be approximated by linear, position invariant process.
---------------- ------------------------------------------------------------- ---------------------9. (a) Derive and construct a circulant matrix for H.
(b) Suppose that A = 4 and B = 3. Construct the matrix for H and describe its
all elements.
(10 marks)
(a)
The development of a discrete, space invariant degradation model is simplified
by starting with the 1-D case and temporarily neglecting the noise term. Two
functions f (x) and h (x) are sampled uniformly to form arrays of dimensions A and B
respectively. x is a discrete variable in the ranges 0, 1, 2, . . . , A-1 for f (x) and 0, 1, 2,
. . . , B-1 for h(x).
By choosing M ≥ A+B-1 and extending the functions with zeros so that their
length is equal to M.
M −1
g e ( x) = ∑ f e (m) he ( x − m)
m =0
Using matrix notation,
g = Hf
where f and g are M dimensional column vectors.
⎡ f e (0)
⎤
⎢ f (1)
⎥
⎢ e
⎥
⎢.
⎥
f= ⎢
⎥
⎢.
⎥
⎢.
⎥
⎢
⎥
⎣⎢ f e ( M − 1)⎦⎥
⎡ g e (0)
⎤
⎢ g (1)
⎥
⎢ e
⎥
⎢.
⎥
g= ⎢
⎥
⎢.
⎥
⎢.
⎥
⎢
⎥
⎣⎢ g e ( M − 1)⎦⎥
he (−1)
he (−2)
..... he (− M + 1) ⎤
⎡he (0)
⎢h (1)
he (0)
he (−1)
..... he (− M + 2) ⎥⎥
⎢ e
⎢he (2)
he (−1)
he (0)
...... he (− M + 3)⎥
⎥
⎢
H = ⎢.
⎥
⎥
⎢.
⎥
⎢
⎥
⎢.
⎢h ( M − 1) h ( M − 2) h ( M − 3) ......... h (0) ⎥
e
e
e
⎦
⎣ e
Because of the periodicity assumption on he (x) , he (x) = he ( M + x)
..... he (1)⎤
he ( M − 1)
he ( M − 2)
⎡he (0)
⎢h (1)
..... he (2) ⎥⎥
he (0)
he ( M − 1)
⎢ e
⎢he (2)
...... he (3) ⎥
he (1)
he (0)
⎢
⎥
H = ⎢.
⎥
⎢.
⎥
⎢
⎥
⎢.
⎥
⎢h ( M − 1) h ( M − 2) h ( M − 3) ......... h (0) ⎥
e
e
e
⎣ e
⎦
(b)
A = 4, B = 3
M ≥ A+B–1
M ≥ 4+3–1
M=6
f and g are 6-D vectors and H is the 6 × 6 matrix
⎡he (0)
⎢h (1)
⎢ e
⎢he (2)
H= ⎢
⎢he (3)
⎢h (4)
⎢ e
⎢⎣he (5)
he (5)
he (4)
he (3)
he (2)
he (0)
he (5)
he (4)
he (3)
he (1)
he (0)
he (5)
he (4)
he (2)
he (1)
he (0)
he (5)
he (3)
he (2)
he (1)
he (0)
he (4)
he (3)
he (2)
he (1)
he (1)⎤
he (2)⎥⎥
he (3)⎥
⎥
he (4)⎥
he (5)⎥
⎥
he (0)⎥⎦
he (x) = 0 for x = 3, 4, 5, and he (x) = h (x) for x= 0, 1, 2,
h(2)
h(1) ⎤
0
0
0
⎡ h ( 0)
⎢h(1)
h(0) 0
0
0
h(2) ⎥⎥
⎢
⎢h(2)
0
0 ⎥
h(1) h(0) 0
H= ⎢
⎥
0 ⎥
h(2) h(1) h(0) 0
⎢0
⎢0
0
0 ⎥
h(2) h(1) h(0)
⎢
⎥
0
0
h(2) h(1)
h(0)⎦⎥
⎣⎢0
--------------------------------- ------------------------------------------------------------10. The objective of image restoration is to estimate an original image f from a
degraded image g and some knowledge or assumptions about H and η . Seeking
an estimate of f using equation g = Hf + n; Consider an unconstrained approach
to the least square restoration.
(10 marks)
g = Hf + n
--------------------(1)
g is given, H and n are known value. Seeking the f by unconstrained approach
n = g – Hf
-------------------(2)
the norm of the noise term is as small as possible, we want to find an fˆ
|| n || 2 = || g - H fˆ || 2
-------------------(3)
By definition; || n || 2 = nT n
|| g - H fˆ || 2 = (g - H fˆ )T (g - H fˆ )
minimizing the criterion function,
J ( fˆ ) = || g - H fˆ || 2
differentiate J with respect to fˆ
∂ J ( fˆ )
= 0 = - 2 HT (g - H fˆ )
ˆ
∂( f )
solving,
fˆ = ( HT H )-1 HT g
If M = N , assume H is square matrix,
fˆ = H-1 ( HT)-1 HT g
-1
fˆ = H g
---------------------------------- --------------------------------- ------------------------------11. Write down the constrained least squares restoration procedure.
(10 marks)
Constrained least squares solution is;
T
T
-1 T
fˆ = ( H H + γ Q Q ) H g
The constrained least squares restoration procedure can be summarized as follows.
Step1: Choose an initial value of γ and obtain an estimate of || n2 || by using equation,
|| n || 2 = (M-1) (N-1) ⎡⎣σ n2 +ηe−2 ⎤⎦
Step2: Compute Fˆ (u,v) by using,
⎡
⎤
H * (u , v)
Fˆ (u,v) = ⎢
⎥ G (u , v) , obtain fˆ by taking the inverse Fourier
2
2
⎢⎣ H (u , v) + γ P (u , v) ⎥⎦
Transform of Fˆ (u,v).
2
Step3: Form the residual vector r according r = g- H fˆ and compute Φ (γ ) = r .
Step4: Increment or decrement γ .
(a) Φ (γ ) < ||n||2 – a. Increment γ .
(b) Φ (γ ) > ||n||2 + a. Decrement γ .
Step5: Return to step2 and continue unless step6 is true.
Step6: Φ (γ ) > ||n||2 ± a, where a determines the accuracy with which the constraint is
satisfied.
Stop the estimation procedure, with fˆ for the present value of γ being the
restored image.
--------------------------------- -----------------------------------------------------------12. Discuss about one of geometric transformation which define the
rearrangement of pixels on the image plane.
(10 marks)
Spatial Transformation:
Suppose that an image f with pixel coordinates (x, y) undergoes geometric
distortion to produce an image g with coordinates ( xˆ , yˆ ) .
This transformation may be expressed as
xˆ = r ( x, y )
and
yˆ = s( x, y )
where r (x, y) and s (x, y) represent the spatial transformation that produced the
geometrically distorted image g ( xˆ , yˆ ) . For example, if r (x, y) = x/2 and s (x, y) = y/2,
the “distortion” is simply a shrinking of the size of f (x, y) by one half in both spatial
directions.
Figure. Corresponding tiepoints in two image segments
Figure shows quadrilateral region in a distorted and corresponding corrected
image. The vertices of the quadrilaterals are corresponding tiepoints.
Suppose that the geometric distortion process within the quadrilateral regions
is modeled by a pair of bilinear equations so that.
xˆ = r ( x, y ) = c1 x + c 2 y + c3 xy + c 4
and
yˆ = s ( x, y ) = c5 x + c6 y + c7 xy + c8
------------------------------------------------------ ---------------------------------13. Discuss about one of geometric transformation which deal with the
assignment of gray levels to pixels in the spatially transformed image.
(10 marks)
Gray-Levels Interpolation:
Using non-integer value for xˆ and yˆ causes a mapping into locations of g for
which no gray levels are defined. Inferring what the gray level values at those location
should be, based on the pixel values at integer coordinates locations, and then become
necessary. The technique used to accomplish this is called gray-level interpolation.
The simplest scheme for gray level interpolation is based on the nearest
neighbor approach. This method is called zero-order interpolation. This figure shows:
(1) the mapping of integer coordinate (x, y) into fractional coordinates ( xˆ, yˆ ).
(2) the selection of the closest integer coordinate neighbor to ( xˆ, yˆ ); and (3) the
assignment of the gray level of this nearest neighbor to the pixel located at (x, y).
Although nearest neighbor interpolation is simple to implement, this method
often has the drawback of producing undesirable artifacts, such as distortion of
straight edges in images of fine resolution. Smoother results can be obtained by using
more sophisticated techniques, such as cubic convolution interpolation.
The gray level value of ( xˆ, yˆ ), denoted v( xˆ, yˆ ), can be interpolated from the
values of its neighbors by using the relationship.
v( xˆ , yˆ ) = axˆ + byˆ + cxˆyˆ + d
( xˆ , yˆ )
(x, y)
Nearest neighbor to ( xˆ , yˆ )
f(x, y)
g(x, y)
Gray level assignment
Figure. Gray level interpolation based on the nearest neighbor concept
------------------------------------------------------------- ----------------------------14. What is data compression and how many data redundancies in digital image
compression.
(10 marks)
Data compression refers to the process of reducing the amount of data required
to represent a given quantity of information. Various amounts of data may be used to
represent the same amount of information.
Data redundancy is a central issue in digital image compression. It is not an
abstract concept but a mathematically quantifiable entity. If n1 and n2 denote the
number of information carrying units in two data sets that represent the same
information, the relative data redundancy RD of the first data set (n1) can be defined
as;
RD = 1-
1
CR
-------------------------- (1)
CR called the compression ratio.
CR =
n1
n2
n2 = n1 , CR = 1 and RD = 0 ( no redundant data )
n2 << n1 , CR → ∞ and RD → 1 ( highly redundant data )
n2>> n1 , CR → 0 and RD → −∞ ( Second data set much more than original )
There are three basic data redundancy. They are coding redundancy, interpixel
redundancy and psycho-visual redundancy.
-------------------------------------------------------------------------------------15. Explain an image compression system model briefly.
(10 marks)
The encoder is made up of a source encoder, which removes input
redundancies, and a channel encoder, which increases the noise immunity of the
source encoder’s output.
The decoder includes a channel decoder followed by a source decoder. If the
channel between the encoder and decoder is noise free (not prone error), the channel
encoder and decoder are omitted, and the general encoder and decoder become the
source encoder and decoder, respectively.
f(x,y)
Source
encoder
Channel
encoder
Encoder
Channel
Channel
decoder
Decoder
Figure. A general compression system model
Source
decoder
fˆ (x,y)
The Source Encoder and Decoder:
The source encoder is responsible for reducing or eliminating any coding,
interpixel, or psychovisual redundancies in the input image. The mapper transforms
the input data into a (usually nonvisual) format designed to reduce interpixel
redundancies in the input image.
Quantizer block reduces the accuracy of the mapper’s output in accordance
with the pre-established fidelity criterion. The symbol coder creates a fixed or
variable length code to represent the quantizer output and maps the output in
accordance with the code.
The source decoder contains only two components; a symbol decoder and an
inverse mapper. These blocks perform in reverse order the inverse operations of the
source encoder’s and mapped blocks.
Mapper
f(x,y)
Quantizer
Symbol
encoder
channel
Source encoder
(a)
Symbol
decoder
channel
Inverse
mapper
fˆ ( x, y )
Source decoder
(b)
Figure. (a) Source encoder and (b) source decoder model
---------------------------------------------------- -----------------------------------16. An 8-level image has the gray level distribution shown in following Table.
Determine the exact level of redundancy and illustrate data compression with
graph.
rk
r0=0
r1=1/7
r2=2/7
r3=3/7
r4=4/7
r5=5/7
r6=5/7
r5=5/7
Pr(rk)
0.19
0.25
0.21
0.16
0.08
0.06
0.03
0.02
Code 1
000
001
010
011
100
101
110
111
l1(rk)
3
3
3
3
3
3
3
3
Code 2
11
01
10
001
0001
00001
000001
000000
L2(rk)
2
2
2
3
4
5
6
6
(10 marks)
By code 1,
For code 2,
Lavg = 3 bits
( because l1(rk) = 3 for all rk)
Lavg
=
7
∑l
k =0
2
(rk ) Pr (rk )
= 2 (0.19) + 2 (0.25) + 2 (0.21) + 3 (0.16) + 4 (0.08) + 5 (0.06)
+ 6 (0.03) + 6 (0.02)
= 2.7 bits
The level of redundancy,
n
1
3
RD = 1where CR = 1 =
= 1.11
CR
n 2 2.7
RD = 1-
1
= 0.099
1.11
Thus approximately 10 percent of the data is redundant.
(Figure 6.1)
(page 312)
---------------------------------- --------------------------------17. Discuss about the Channel Encoder and Decoders.
----------------------------
(10 marks)
The Channel Encoder and Decoder:
The channel encoder and decoder play an important role in the overall
encoding-decoding process. They are designed to reduce the impact of channel noise
by inserting a controlled form of redundancy into the source encoded data. As the
output of the source encoder contains little redundancy, it would be highly sensitive to
transmission noise without the addition of this “controlled redundancy”.
One of the most useful channel encoding techniques was based on appending
enough bits to the data being encoded to ensure that some minimum number of bits
must change between valid code words.
The 7-bits Hamming (7, 4) code word h1…h5 h6 h7 associated with a 4-bits
binary number b3 b2 b1 b0 is
h1 = b3 ⊕ b2 ⊕ b0
h2 = b3 ⊕ b1 ⊕ b0
h4 = b2 ⊕ b1 ⊕ b0
h3 = b3 , h5 = b2 , h6 = b1 , h7 = b0
Where ⊕ denotes the exclusive OR operation. Note that bits h1, h2, and h4 are evenparity bits for the bits fields b3 b2 b0, b3 b1 b0, and b2 b1 b0, respectively.
To decode a Hamming encoded result, the channel decoder must check the
encoded value for odd-parity over the bit fields in which even parity was previously
established. A single-bit error is indicated by a nonzero parity word c4 c2 c1, where
c1 = h1 ⊕ h3 ⊕ h5 ⊕ h7
c 2 = h2 ⊕ h3 ⊕ h6 ⊕ h7
c 4 = h4 ⊕ h5 ⊕ h6 ⊕ h7
If a non-zero value is found, the decoder simply complements the code word bit
position indicated by the parity word. The decoded binary value is then extracted from
the corrected code word as h3 h5 h6 h7.
--------------------------------------------------------------------------------------18. By using Huffman’s Coding, compute these facts;
(a) Lavg (b) Huffman source reduction and (c) code assignment procedure from
the following facts.
Symbol
a2
a6
a1
a4
a3
a5
Original Source
Probability
0.4
0.3
0.1
0.1
0.06
0.04
(10 marks)
Lavg
= (0.4) (1) + (0.3) (2) + (0.1) (3) + (0.1) (4) + (0.06) (5) + (0.04) (50
= 2.2 bits / symbol
(Figure 6.11)
(Page 344)
(Figure 6.12)
(Page 345)
--------------------------------
--------------------------------------
----------------------
B.E ( Second Semester)
Sample Question
IT 5025 Artificial Intelligence
Chapter ( 5)
1. Define semantic network and give two advantages and two limitations.
(16 marks)
2. (a) compare and contract the production rule and frame.
(10 marks)
(b) List three types of facets of a frame and explain their meaning.
3. (a)Describe advantages and disadvantages of rule representation.
(b) What is a slot in a frame.
( 6 marks)
(10 marks)
( 6 marks)
4. Briefly explain about script. Develop a script about restaurant.
(16 marks)
5. (a)Define a list and give an example.
(10 marks)
(b)List the major knowledge representation method.
(6 marks)
6.(a) Describe about Decision Table and draw Decision Table Based on Dialogue with a
Fruit Expert.
( 8 Marks)
(b) Describe about Decision Tree and draw Decision Tree for Fruit Identification.
( 8 Marks)
7.(a) What do we mean by knowledge representation.
( 6 Marks)
(b) Construct a semantic network for following situation: Mini is a robin; it lives in a
nest which is on a pine tree in Ms. Wang’s backyard. Robins are birds; they can fly
and they have wings. They nare an endangered species and they are protected by
government regulations.
( 10 Marks)
8.(a) Describe about the benefits of Pictorial representations.
(b) What is propositional Logic? Give an example.
( 10 Marks)
( 6 Marks)
9. Prepare a set of frames of an organization given the following information. (16 marks)
Company
: 1050 employees,$130 million annual sales,
Jan fisher is the president
Department
: accounting, finance, marketing, production, personnel
Production department : five lines of production
Product
: computers
Annual budget
: $50,000+$12,000 × number of computers produced
Materials
: $6,000 per unit produced
Working days
: 250 per year
Number of supervisors : one for each twelve employees
Range of number of employees : 400-500 per shift (two shifts per Day)
overtimes or part time on a third shift is possible
10. Develop a script about shopping in a supermarket.
(16 Marks)
Chapter ( 6 )
11. (a) Define deductive reasoning and contrast it with inductive reasoning. (10 marks)
(b) What is meant that a rule ‘fires’.
12. (a)Define model-based reasoning.
(b)Define case-based reasoning.
13. (a)List the name of the purpose of explanation capability.
(b)Define static explanation.
14. (a)Briefly explain about inference tree.
(b)Define meta rule.
(6 marks)
(8 marks)
(8 marks)
(10 marks)
(6 marks)
(10 marks)
(6 marks)
15.(a) Define backward chaining and contrast it with Forward chaining.
( 10 Marks)
(b) Define pattern matching. Explain how it is used in rule chaining.
( 6 Marks)
16. You are given a set of rules for this question as follow.
(16 marks)
Goal : whether or not to invert in IBM stock.
R1
: If a person has $10,000 and she has a college degree,
THEN she should invest in securities
R2
: If a person’s annual income is at least $40,000 and she has a college degree,
THEN she should invest in growth stocks.
R3
: If a person is younger than thirty and if she is investing in securities,
THEN she should invest in growth stocks
R4
: If a person is younger than thirty, THEN she has a college degree
R5
: If a person wants to invest in growth stock, THEN the stock should be IBM
Run a backward chaining with the facts : The investor has $ 10,000 and She is twenty –
five year old.
17. You are given a set of rules for this question as follows.
(16marks)
R1
: If inflation is low
THEN interest rates are low
ELSE interest rates are high.
R2
: If interest rates are high
THEN housing prices are high
R3
: If housing prices are high
THEN do not buy a house
ELSE buy it
Run a forward chaining with the fact : Low inflation
: rate as given
18. You are given an ES with Following rules:
( 16 Marks)
Goal : Should we buy bonds or not.
R1
: IF interest rate falls
THEN bond prices increase
R2
: IF interest rate increases
THEN bond prices decline
R3
: IF interest rate is unchanged
THEN bond prices remain unchanged
R4
: IF the dollar rises ( against other currencies)
THEN interest rate declines
R5
: IF the dollar falls
THEN interest rate increases
R6
: IF bond prices decline
THEN buy bonds
Run a backward chaining with the fact: The dollar exchange rate is falling.
&&&&&&&&&&&&&&&&&&&&&&&
4. When a datagram arrive at a host, how to handle it.
( 8 Marks)
Chapter ( 9 )
5. When encounter an error how to report the error to the original source and how to
correct it.
( 16 Marks)
6. Describe about testing destination Reachability and Status.
( 8 Marks)
7. When the routers make routing changes. Explain about it completely.
( 16 Marks)
8. Explain the discovering router before it can send datagrams to destinations on other
Networks.
( 16 Marks)
Chapter ( 12 )
9. Describe the Protocol which provides ports used to distinguish among multiple
programs executing on a single machine, completely.
10. Describe the Format of UDP messages.
( 8 Marks)
( 8 Marks)
11. How a UDP datagram encapsulate in an IT datagram for transmission across an
internet. And the also describe the conceptual layering of UDP.
12. Discuss about UDP Multiplexing, Demultiplexing, and Ports.
( 16 Marks)
( 8 Marks)
Chapter ( 13 )
13. How many features that can characterize the interface between application programs
and the TCP/IP reliable delivery service. And also explain those features. ( 16 Marks)
14. Show how the simplest positive acknoeledgement protocol transfers data and also
show Timeout and retransmission that occurs when a packet is lost.
( 8 Marks)
15. Describe the format of a TCP segment. Explain it completely.
( 16 Marks)
16. Discuss the Acknowledgements and Retransmission.
( 8 Marks)
17. How to establish a TCP connection. Explain it briefly.
( 8 Marks)
18. How to close a TCP connection. Explain it briefly.
( 8 Marks)
19. Draw the diagram of the TCP finite state Machine and explain about it. ( 16 Marks)
B.E (Second Semester)
Sample Question
Artificial Intelligence (IT 5025)
1. Sematic Networks
Sematic network is composed of nodes and links. Sematic networks are basically graphic of
knowledge that show hierarchical relationshhips between object. It is made up of a number of
circles, or nodes, which represent objects and descriptive information about those objects. Objects
can be any physical item such as a book, car, desk or even a person. Notes can also be concepts,
events, actions. Attributes of an object can also be used as anodes.
The nodes in a sematic network are also interconnected by links, or arcs. These arcs show
the relationships between the various objects and descriptive factors.Some of the most common arc
are of the is a or has-a type.Is-a is used to show class relationship,or category of objects.Has-a links
are used to idantify characteristics or attributes of the objects nodes.
Advantages of Sematic Networks
-The sematic offers flexibility in adding new nodes and links to a definition as needed.The visual
representation is easy to understand.
-The sematic network functions in a manner similar to that of human information storage.
Limitation of Sematic Networks
-No standards exit for the definition of nodes or relationships between and among nodes.
-The power of inheriting characteristics from one node to another offers potential difficulties with
exception.
2. Production Rules
The production systems are modular knowledge representatic schemes that are finding
increasing popularity in many AI applications.The basic ideas of these systems is that knowledge is
presented as production rules in the form of condition-action pairs: If this condition cor premise or
antecedent,occur,THEN some action cor result,or conclusion,or consequence will occur.
If the stoplight is red AND you have stopped, THEN a right turn is okay.
Frame
A frame is a data structure that includes all the knowledge about a particular objectt.This
knowledge is organized in a special hierarchal structure that permits a diagnosis of knowledge
independence.Frames are basically an application of object-oriente programmingfor AI and ES.
They offer representation of knowledge in concise structure and natural manner.A frame is
a relatively large block or chunk of knowledge about a paryicular object, events, location, situation,
or other elements.The frame describes that object in great detail.
Frames are normally used to represent stereotyped knowledge or knowledge built on wellknown characteristics and experiences.
Values: These describe the attributes such as blue, red and yellow for a color slot.
Default: This facet is used if the slot is empty, that is, without any description.For example,in the
car frame one default value is that the number of wheels on the car is four.It means that we can
assume the car has four wheels unless otherwise indicated.
If-needed: This facet is used in a case when no slot value is given.It triggers, much like the if-added
situation, a procedur that gose out and gets or computes a value.
3.(a) Advantages and Limitations of rule representation
It has served major advantages:
1. Rules are easy to understand. They are communicable because they are a natural form of
knowledge.
2. Inference and explanations are easily derived.
3. Modifications and maintenance are relatively easy.
4. Uncertainly is easily combined with rules.
5. Each rule is usually independent of all others.
The major limitations of rule representation are as follows:
1. Complex knowledge requires many, many (thousands of) rules. This may create problems in
both using the system and maintaining it.
2. Builders like rules; therefore they try to enforce all knowledge into rules rather than looking for
more appropriate representations.
3. Systems with many rules may have a search limitation in the control program. Some programs
have difficulty in evaluating rule-based systems and making inferences.
(b) Each slot contains one or more facets. The Facets describe some knowledge or procedures about
the attribute in the slot.
4. Scripts
A script is a knowledge representation scheme similar to a frame, but instead of describing
an object, the script describe a sequence of events. Like the frame , the script portrays a stereotyped
situation. Unlike the frame, it is usually presented in a particular context. To describe a sequence of
events, the script uses a series of slots containing information about the people, object and actions
that are involved in the events.
Some of the elements of a typical script include entry conditions, props, roles, tracks, and
scenes. The entry conditions describe situations that must be satisfied before events in this script
can occur or be valid. Props refer to the people that are used in the sequence of events that occur.
Roles refer to the people involved in the script. Track refers to variations that might occur in a
particular script. And finally, scenes describe the actual sequence of events that occur.
Restaurant Script
Track: Fast-food restaurant
Roles: Customer (c)
Server(s)
Props: Counter
Tray
Food
Money
Napkins
Salt/ Pepper/ Catsup/ Straws
Entry conditions: Customer in hungry
Customer has money
Scene 1: Entry
•
Customer parks car.
o
Customer enters restaurant.
o
Customer waits in line at the counter.
•
Customer reads the menu on the wall and makes a decision about what to order.
Scene 2: Order
•
Customer gives order to server.
•
Server fills order by putting food on tray.
•
Customer pays server.
Scene 3: Eating
•
Customer gets napkins, straws, salt, etc.
•
Customer takes tray to an unoccupied table.
•
Customer eats food quickly.
Scene 3A (option): Take-out
•
Customer takes food and exists.
Scene 4: Exit
•
Customer cleans up table.
•
Customer discards trash.
•
Customer leaves restaurant.
•
Customer drives away.
Results:
•
Customer is no longer hungry.
•
Customer has less money.
•
Customer is happy.
•
Customer is unhappy.
•
Customer is too full.
•
Customer has upset stomach.
Options
Figure: Typical Script
5.(a) Lists
A list is a written series of related items. It can be a list of names of people, things to buy,
things to do, or products in a catalog.
Lists are normally used to represent knowledge in which objects are grouped, categorized or
graded according to rank or relationship. Objects are first divided into groups or classes of similar
items. Then, their relationships are shown by linking them together. The simplest form is one list
but a hierarchy is created when two or more related Lists are combined
An element in one list can be the name of another list containing sub elements.
List
A
Element 1
2
3
4
5
6
Element
Subelement
Subelement
Subelement
Element
2
Subelement a
b
c
d
4
a
b
c
Subelement c
Sub –subele (1)
(2)
Figure : List Representing Hierarchical Knowledge
5.(b) Major knowledge representation methods are
1. Representation in logic
2. Analysis representation
•
Semantic Network
•
Scripts
•
Lists
•
Decision tables
•
Decision trees
3. Coding Representation
• Production rules
• Frames
(6) (a)Decision Trees
A decision tree may be though of as a hierarchical semantic network bound by a series of
rules. They are composed of nodes representing goals and links representing decisions. The root of
the tree is on the left and the leaves are on the right. All terminal nodes except the root node are
instances of a primary goal.
Decision trees, like rules, depict a strong sense of cause and effect. Their major advantage is
that they can simplify the knowledge acquisition process.
Orange
The fruit
is
orange.
Green
The fruit
is
grapefruit
Colour?
Round
The fruit
is orange.
Smell?
Shape?
Oval
Yellow
Acid
Not acid
The fruit
is orange.
The Fruit may be
lime, lemon,
kumquat,etc.
More
information is
The fruit
is
grapefruit
Equivalent rule:
If the smell is acid and the shape is round and the color is orange THEN the fruit is an orange.
Fig: Decision tree for Fruit Identification.
(b)Decision Tables
Another method of knowledge representation is the decision table, which is organized in a
spreadsheet format, using columns and rows. The table is divided into two parts. First, a list of
attributes is developed, and for each attribute all possible values are listed. Then, a list of
conclusion is developed. Finally, the different configurations of attributes are matched against the
conclusion.
Attributes
Shape
round
round
round
round
oblong
oblong
oblong
oblong
Smell
acid
acid
sweet
sweet
sweet
sweet
acid
sweet
Color
yellow
orange
yellow
red
yellow
yellow
orange
green
Taste
sour
sweet
sweet
sweet
sweet
sweet
sour
sweet
Skin
rough
rough
smooth
smooth
smooth
smooth
smooth
smooth
sees
yes
yes
yes
yes
yes
yes
yes
yes
Conclusions
x
grapefruit
x
orange
x
apple
x
x
banana
x
x
pear
x
kumquat
Fig: Decision Table Based on Dialogue with a Fruit Expert
7.(a) What do we mean by knowledge representation
The a equired knowledge is organized in an activity called knowledge of a “ knowledge
map” and encoding the knowledge in the knowledges base.
Knowledge captured from experts and other sources must be organized in such a fashion
that a computer inferencing program will be able to access this knowledge whenever needed and
draw conclusions. They have two common characteristics. First they can be programmed with
existing computer languages and stored in memory. Second, they are designed so that the fact and
other knowledge basse contained within them can be used in measoning
(b)
is a
Lives
robin
Mini
nest
is an
is on a
is a
can fly and has
wing
is protected by
pine
tree
bird
endangered
species
in
Ms. wang’s
backyard
Government
regulation
8. (a) Seven benefits of pictorials representations are
1. Validation through enhanced, uniform communication between develops team and users.
2. Testing and debugging systems logic because of clean design and documentation.
3. Completeness because methodologies encourage complete documentation and qualify
assurance reviews with users.
4. Accuracy of solution because of documented and tested logic.
5. Ease of maintenance because reduced effort is needed to understand and interpret someone’s
else code.
6. Programming productivity through enhanced uniform communication and documentation.
7. Ease in coding system because of structured approach.
8. (b) Propositional Logic
A proposition is nothing more than a statement that is either true or false. Once use know
what it is, it becomes a premise that can be used to derive new propositions, premise or
conclusions. Ruler are used to determine the truth (T) or False(F) of the new proposition. In
propositional logic, we use symbols such as letters of the alphabet to represent various propositions
and inferences.
For example;
Statement A= The mail carrier comes moadey through Saturday.
Statement B= Today is Sunday.
Statement C = The mail carrier will not come today.
Name
Employees
Annual sales
President
Has a
Company
1050
$ 130 million
John fisher
Name
Production
Lines of production 5
Product
Computer
Name
Name Department
is-a
is-a
is-a
is-a
accounting
is-a
marketing
Name
Working –days
No: of supervisors
Range of employee
No: of shift
Third shift
10.
Personal department
250 per year
88
400-500 per shift
3
Overtime
Supermarket Script
Track: supermarket
Roles: customer
organizer
Sale: clerk
cashier
props: Food stuff
Trays
Rocks
Refrigerated cabinet
Meat and vegetables
Cosmetics
Domestic applicance
Electronic product
Basket
Finance
Department
Annual
budge
Material $600 per unit
Name Annual budget
Equation
From $50000
+$120000
*no:of computer
produce
Roles: customer need to buy something window shoppinh
Scene 1: Entry
•
Customer parts car
•
Customer wants in line at the security service
•
Customer enters Supermarket
Scene 2: Look through
•
Customer Look through
•
Customer asks sale clerk about the goods
that is wanted to buy
•
Customer makes a decision about what to buy
Scene 3: Buying
•
Customer takes the things she likes
•
Customer puts the things into the basket
•
Customer brings the things to cashier
Scene 4: Payment
•
Cashier calculates and gives total bill
•
Customer gives the money for bill
•
Cashier packs the goods
Scene 5: Receive
•
Customer receives the package
Scene 6: Exit
•
Customer takes the goods and leaves the supermarket
•
Customer drive the away
Result:
11. (a)
•
Customer has less money
•
Customer is happy
Deductive reasoning
Deductive reasoning is a process in which general premises are used to obtain a specific
inference. Reasoning moves form a general principle to a specific conclusion.
The deductive process generally begins with a statement of the premises and
conclusions. It consists of three parts: a major premise, a minor premise, and a conclusion.
Major premise
: I do not job when the temperature exceeds 90 degrees.
Minor premise
: Today the temperature is 93 degrees.
Conclusion
: Therefore, I will not jog today.
The whole idea is develop new knowledge from previously given knowledge.
Inductive Reasoning
Inductive reasoning uses a number of established facts or premises to draw some general
conclusion.
Premise : Faulty diodes cause electronic equipment failure.
Premise : Defective transistors cause electronic equipment failure.
Premise : Defective integrated circuits cause electronic equipment malfunction.
Conclusion: Therefore, defective semiconductor devices are a cause of electronic
equipment failure.
Inductive reasoning is that the conclusion may be difficult to arrive at, or it may never be
final or absolute conclusion can change if new facts are discovered.
The more knowledge you have, the more conclusive your inference can be.
11. (b)Rule “Fires”
Firing a rule occurs only when all of the rule’s parks are satisfied. Then, the conclusion
draw is stored in the assertion base.
Testing a rule premise or conclusion can be as simple as matching a symbolic pattern in
the rule to a similar pattern matching.
Every rule in the rule base can be checked to see if its premise or conclusion can be
satisfied by previously made assertions. This process may be done in one of two directions, forward
or backward and it will continue until no more rules can fire, or until a goal is achieved.
12.(a) Model-based reasoning
Model-based reasoning is based on knowledge of the structure and behavior of the
devices the system is designed to understand. Model based systems are especially useful in
diagnosed equipment problems. The systems include a model of the device to be diagnosed that is
then used to identify the cause(s) of the equipment failure. Because they draw conclusions directly
from knowledge of a device’s structure and behavior, model-based expert systems are said to reason
from “first principles”.
12.(b) Case – based reasoning
The basic idea of case-based reasoning is to adapt solutions that were used to solve old
problems and use them for solving new problems. One variation of this approach is the ruleinduction method. In rule induction the computer examines historical cases and generates rules,
which are chained to solve problems. Case-based reasoning follows a different process ;
ƒ
Finds those cases in memory that solved problems similar to the current problem, and
ƒ
adapts the previous solution or solution to fit the current problem, taking into account
any difference between the current and previous situations.
Finding relevant cases involves
ƒ
Characterizing the input problem, by assigning the appropriate features to it.
ƒ
Retrieving the cases from memory with those features, and
ƒ
Picking the case or cases that match the input best.
It is basically a processing of the right information retrieve at the right time.
13. (a) Explanation
The part of an ES that provides explanations is called an explanation facility. The
explanation facility has several specific purposes:
- Make the system more intelligible to the user.
- Uncover the shortcomings of the rules and knowledge base.(debugging the systems by
the knowledge engineer).
- Explain situations that were unanticipated by the user.
- Satisfy psychological and / or social needs by helping a user feel more assured about
the actions of the ES.
- Clarify the assumptions underlying the system’s operations, both to the user and the
builder.
- Conduct sensitivity analyses.(Using the explanation facility, the user can predict and
test the effects of changes on the system)
13. (b) Static explanation.
There are different methods for generating explanations. An easy way to do them is to
pre-insert pieces of English text in the system. For example, each question that could be asked by
the user may have an answer test associated with it. This is called static explanation.
14.(a) Inference tree.
Inference tree provides a schematic view of the inference process. It is similar to a
decision tree. Each rule is composed of a premise and a conclusion. In building the inference free
the premise and conclusion. In building the inference free the premises and conclusions are shown
as nodes. The branches connect the premises and conclusions. The operators AND and OR are used
to reflect the structures of the rules.
By using the tree, we can visualize the process of inference and movement along the
branches of the tree. This is called tree traversal. The inference tree is constructed upside down. The
root is at the top and the branches point downward. The tree ends with “leaves” at the bottom.
Inference trees are composed basically of clusters of goals. Each goal may have sub
goals (children) and a super goal (parent).
14.(b) Metarule.
Conflict resolution is done in may cases by introducing inference rules, for example,
deciding about which rules to use next. In such a case, we deal with metarules, or rules about rules.
Inference engines that include metarules are more complex than those that do not.
15.(a) Backward chaining
Backward chaining is a goal-driven approach staring from an expectation of what is to
happen, then seek evidence that supports the expectation.
The program starts with a goal to be verified as either true or false. Then it looks for a
rule that has that goal in its conclusions. It checks the premise of that rule to satisfy this rule. It
checks the assertion here first. If the search fails, the ES premise of first rule. An attempt is then
make to satisfy the second rule. The process continues until all the possibilities are checked.
Forward chaining
Forward chaining is a data-driven approach starting from available information as it
comes on or from a basic idea then try conclusion.
The computer analyze the problem by looking for the foots that metch the IF portion of
its IF THEN rules. As each rule is tested, the prosrom cuorke if way toward a conclusions
15.(b) Pattern matching
Testing a rule premise or conclusion can be as simple matching a symbolic pattern in the
rule to a similar pattern in the assertion base. This activity is referred to as pattern match.
Every rule in the rule base can be checked to see if its premise or conclusion can be
satisfied by previously made assertions. This process may be done in one of two directions: forward
or backward and it will continue until no more rules can fire an until a goal is achieved.
N0 16
A= Have $10,000
B= Younger than thirty
C= Education at college level
D= Annual income of at least $ 40,000
E= Invert in securities
F= Invert in growth stocks
G= Invert in IBM stock
R1: IF
A and C,
R2: IF
D and C, THEN
R3: IF
B and
R4: IF B
THEN E step (5)
E,
THEN
R5: IF F, THEN
THEN
F
F
C
G
Step (2)
Fact: investor has $ 10,000
She is twenty-five years old
A is true.
B is true.
step (3)
step (4)
step (6)
step(1)
Goal: whether or not to invest in IBM stock.
G or not
Starting point: We start by looking for a rule that include goal (G) in its conclusion (THEN) part.
Step(1): Try to access or reject(G). In a assertion base,
A is true.
B is true.
G is not in assertion base but G is a conclusion R5
Step (2) : R5 says that if F is true, THEN G is true. F is not assertion base but F is in conclusion of
rule R2 and R3.
Step (3) : We try R2 first. In R2, if both D and C are true, THEN F is true. D is not in
conclusion of any rule nor or fact. So we return to another rule R3.
Step (4) : R3 says that if both B and E are true, THEN F is true. Because it is given Fact, B
is true. E is not in assertion base. E is a conclusion of R1.
Step (5) : R1 says that if both A and C are true, THEN E is true. A is true because it is given
fact. C is no in assertion base but is in conclusion of R1.
Step (6) : R4 says that if B is true, THEN C is true. C is true because B is given fact. C become a
fact and added to assertion base.
Step (7) : E is true because A and C are true. So R1 fired and which valid F. So R3 is fired.
F is true, THEN G is true. ES will recommend to invert in IBM stock.
17.
A = information is low
B = information is low
C = interest rates are high
D = housing prices are high
E = don’t buy a house
F = buy a house
R1: IF
A THEN B
R2: IF
C
R3: IF
THEN
D THEN E
ELSE C step 1
D
ELSE F
step 2
step 3
Fact: Low inflation rode
(A is true)
Goal: F or E
Starting point: start from fact A. We look for a rule that includes an A in the IF side of rule. This is
R1.
Step 1
Step 2
Step 3
: R1 says that If A is true then B is true then B is true else C is true A is true in assertion
base, if A is true, B is true but B is not a premise of any rule. R1 says that if A is true, C
is false. So we take C is false C is a premise of R2.
: R2 says that if c is true, then D is true. C is false in assertion base. So, D is False R2 fires.
D is added to assertion base. D is a premise of R3
: R3 says that if D is true then E is true else F is true. D is false in assertion base. So, F is
True.
Therefore Es will recommend to buy a house.
18.
A = interest rates falls
B = Bond prices increase
C = interest rates increase
D = Bond prices decline
E = interest rates is unchanged
F = Bond prices remain unchanged
G = the dollars rises
H = the dollars falls
I = buy bonds
R1: IF
A THEN
B
R2: IF
C
THEN
D
R3: IF
E
THEN
F
R4: IF
G
THEN
A
R5: IF
H
THEN
C
R6: IF
D
THEN
I (start point)
Step 1
Fact: the dollar exchange rate is falling
(H is true)
Goal: I or not
step 2
srep 3
Starting point: start from goal (I). I is not in Assertion Base. But I is in conclusion of R6
Step 1 : R6 says that If D is true then I is true. is not in Assertion Base. But D is in conclusion of
R2.
Step 2 : R2 says that if c is true, then D is true. C is not in Assertion Base. But C is in conclusion of
R5.
Step 3 : R5 says that if H is true then C is. C is true because His an given fact.R5 fires.C is added
to assertion Base.R2 fires D is added to Assertion Base which validates I
Therefore ES will recommend to buy bonds.
B.E ( Second Semester)
Sample Question
IT-5022 Computer Architecture ( II )
Chapter ( 5)
1. Illustrate the execution of R type instruction and show the appropriate control line,
datapath units and connection high lighted with datapath design, such as
add $t1, $t2, $t3. (page 308,309 fig: 5.19)
( 16 Marks)
2. Illustrate the execution of load word instruction and shows active functional units and
asserted control lines for a load such as lw $t1, offset ($t2).(. page 308,310 fig: 5.20)
( 16 Marks)
3.Show the operation of the branch-on-equal instruction executions step by step and
highlighted the control line, datapath units and connection with its datapath design,
such as beq $t1, $t2, offset. ). (. page 310,311 fig: 5.21) ).
( 16 Marks)
4. Assume that the operation times for the major functional units in this implementation
are the following:
( 8 Marks)
- memory units 200 pico seconds
- ALU and address : 100 ps
- Register file ( read or write ) : 50 ps
Instruction mix: 25% loads, 10% stores, 45% ALU instructions, 15% of branches and
5% of jumps. Using these critical paths, you can compute the required length for each
instruction class:
Instruction
Instruction
Register
ALU
Data
Register
Total
class
memory
read
operation
memory
write
R-type
200
50
100
0
50
400 ps
Load word
200
50
100
200
50
600 ps
Store word
200
50
100
200
-
550 ps
Branch
200
50
100
0
-
350 ps
jump
200
-
-
-
-
200 ps
To compare performance of single cycle machine for a single clock and a variable clock,
then find performance ratio. (. page 315 eg)
( 8 Marks)
5.(a) Express differences between the datapath for the single cycle and multicycle.
(. page 319)
(b) What types of temporary register added to meet requirement of multicycle datapath,
explain.
(. page 319) ( 8 Marks)
6. (a) Multicycle datapath requires additions to support branches and jumps, how
operation of three possible sources for the value to be written into the PC, explain.
(. page 321) ( 4 Marks)
(b) Show the complete multicycle datapath and control unit, including the additional
control signals and multiplexor for implementing the PC updating.
(. page 323 fig 5.28) (12 Marks)
7. Using the SPECINT 2000 instruction mix, The mix is 25 % load ( 1% load byte + 24
% load word ), 10 % stores ( 1 % store byte + 9 % store word ), 11% branches ( 6%
beq, 5% bne ), 2 % jump ( 1 % jal + 1 % jr ) and 52 % ALU. The number of clock cycles
for each instruction class is following : loads
:
5
:
4
ALU instructions :
4
branches
:
3
jumps
:
3
stores
what is the CPI, assuming that each state in multicyale CPU requires 1 clock cycle?
(. page 330 eg ) (8 marks)
8. Show complete finite state machine, including memory reference instructions, R-type
instruction, Branches instruction and jump inatructions for datapath.
(. page 339 fig 5.38) (8 marks)
9. . Show complete finite state machine with handle exception control for datapath.
(. page 340 fig 5.40) ( 8 Marks)
10. How do you understand exception and interrupts. (. page 340) ( 4 Marks)
11. How canbe handle the exceptions in current implementation, what perform of basic
action for machine and operating system.
(. page 341 ( 4 Marks)
Chapter ( 6 )
12.(a) lw
$ 1, 100 ( $ 0 )
lw
$ 2, 200 ( $ 0 )
lw
$ 3, 300 ( $ 0 )
Compare nonpipelined and pipelined executin of these load word instruction.
(page 372,fig 6.3) ( 4 Marks)
(b) What do you understand about hazards in pipeling, explain them?
(page 375,376,379) ( 4 Marks)
13. Consider the following code segments in C:
A=B–E;
C=B+F;
Here is the generated M code for this segment, assuming all variables are in memory
and are addressable as offset from $t0.
lw
$ t1, 0 ($ t0 )
lw
$ t2 , 4 ($ t0 )
sub
$ t3 , $ t1 , $ t2
sw
$ t3 , 12 ( $ t0 )
lw
$ t4 , 8 ($ t0 )
add
$ t5 , $ t7 , $ t4
sw
$ t5 , 16 ($ t0 )
Find the huzards in the following code segments and recorder the instructions to avoid
any pipeline stalls.
(page 378 eg style)(4 Marks)
14.Draw pipeline showing stalling in following instructions.
add
$ 4, $ 5, $ 6
beq
$ 1, $ 2, 40
or
$ 7, $ 8, $ 9
and
computer do indeed use predication to handle branches: pipeline proceds at full speed
always predict that branches will be untaken and pipeline is stall when branches are
taken. Shows drawing the pipeline with these approaches with figure.
(pg 380 eg fig 6.7,fig 6.8)
15. What is the latency.
( 8 Marks)
(pg 383)(2 Marks)
16. Draw the correct pipelined datapath to property handle the load instructions, then
highlighting the portion of First and Fourth pipeline state.
(pg 388 fig 6.17)(16 Marks)
17. Draw the correct pipelined datapath to property handle the store instructions, then
highlighting the Full stage pipeline, what happen in write back stage.
(pg 393 fig 6.15)(16 Marks)
18. Consider the following five instruction sequence:
lw
$ 5, 40 ( $ 2 )
add
$ 6, $ 3, $ 2
or
$ 7, $ 2, $ 1
and
$ 8, $ 4, $ 3
beq
$ 9, $ 2, $ 1
Show the multicycle-clock pipelined datagram using physical resources at each stage.
(pg 397 fig 6.19style) ( 8 Marks)
19. Specify control signal for execution / address calculation, memory access and write
back stage, shows draw that these control signal are used in the appropriate pipeline
stage.
(pg 402 fig 6.26)(8 Marks)
20. Considering executing the following code in the pipeline data path.
lw
$ 2, 20 ( $ 1 )
and
$ 4, $ 2, $ 5
or
$ 8, $ 2, $ 6
add
$ 9, $ 4, $ 6
slt
$ 1, $ 6, $ 7
How many clocks cycle will it take to execute this code? Draw a diagram that
illustrates the dependencies these instruction? (pg 414 fig 6.24 Style)(8 Marks)
21. Draw the pipeline connection for both the hazard detection unit and forwarding unit, if
necessary adding two multiplexors for these units? (pg 416 fig 6.36)(8 Marks)
Chapter ( 7 )
22.(a) Show how to map referenced lower order bits of an address is used to find the
unique cache entry.
(b) Why does a valid-bit add to direct mapped cache.
(c) How many total bits are required for a directed mapped cache with 16KB of data
and if word blocks, assuming 32 bit address?(pg 478-479 fig 7.7, Eg ) (16 Marks)
1.
Illustrate the execution of R-type instruction and show highlighting the appropriate control line,
datapath unit and connection with data path design, such as add $t1, $t2, $t3.
Add
Add
4
Reg Dst
Shift
left 2
Branch
Instruction
[31-26]
MemRead
MemtoReg
ALUOP
Control
ALU
result
0
M
U
X
1
MemWrite
ALUSrc
RegWrite
Read
address
PC
Instruction
[31-0]
Instruction
Memory
Instruction [25-21]
Instruction [20-16]
0
Instruction M
U
[15-11]
X
1
Instruction [15-0]
Read
reg:1
Read
reg:2
Write
reg:
Read
Data 1
Read
Data 2
Write
reg:
Registers
16
Sign
extend
32
ALU zero
ALU
result
0
M
U
X
1
Address Read
data
Data
Memory
1
M
U
X
0
Write
data
ALU
control
Instruction [5-0]
1.
2.
3.
4.
The datapath design for R-type instruction; add $t1, $t2, $t3
The instruction is fetched, and the PC is incremented.
Two registers, $t2 and $t3, are read from the register file, and main control unit computes the setting
of the control lines during this step also.
The ALU operates on the data read from the register file, using the function code (bits 5:0, which
is the funct field of the instruction) to generate the ALU function.
The result from the ALU is written into the register file using bits 15:11 of the instruction to select
the destination register ($t1).
2. Illustrate the execution of load word instruction and show active function units and asserted control lines
for a load, such as lw $t1, offset ($t2).
Add
Add
4
Reg Dst
Shift
left 2
Branch
Instruction
[31-26]
MemRead
MemtoReg
ALUOP
Control
ALU
result
0
M
U
X
1
MemWrite
ALUSrc
RegWrite
Read
address
PC
Instruction
[31-0]
Instruction
Memory
Instruction [25-21]
Instruction [20-16]
0
Instruction M
U
[15-11]
X
1
Instruction [15-0]
Read
reg:1
Read
reg:2
Write
reg:
Read
Data 1
Read
Data 2
Write
reg:
Registers
16
Sign
extend
32
ALU zero
ALU
result
0
M
U
X
1
Address Read
data
Data
Memory
1
M
U
X
0
Write
data
ALU
control
Instruction [5-0]
1.
2.
3.
4.
5.
The datapath operation for load instruction; lw $t1, offset ($t2)
An instruction is fetched from the instruction memory, and ttu PC is incremented.
A register ($t2) value is read from the register file.
The ALU computes the sum of the value read from the register file and the sign-extended, lower
16 bits of the instruction (offset).
The sum from the ALU is used as the address for the data memory.
The data from the memory unit is written into the register file, the register destination is given by
bits 20:16 of instruction ($t1).
3. Show the operation of branch-on-equal instruction execution step by step and highlighting, control line,
datapath units and connection with its datapath design, such as beq $t1, $t2, offset.
Add
Add
4
Reg Dst
Shift
left 2
Branch
Instruction
[31-26]
MemRead
MemtoReg
ALUOP
Control
ALU
result
0
M
U
X
1
MemWrite
ALUSrc
RegWrite
Read
address
PC
Instruction
[31-0]
Instruction
Memory
Instruction [25-21]
Instruction [20-16]
0
Instruction M
U
[15-11]
X
1
Instruction [15-0]
Read
reg:1
Read
reg:2
Write
reg:
Read
Data 1
Read
Data 2
Write
reg:
Registers
16
Sign
extend
32
ALU zero
ALU
result
0
M
U
X
1
Address Read
data
Data
Memory
1
M
U
X
0
Write
data
ALU
control
Instruction [5-0]
1.
2.
3.
4.
The datapath design for branch-on-equal instruction; beq $t1, $t2, offset
An instruction is fetched from the instruction memory and the PC in incremented.
Two registers, $t1 and $t2 are read from the register file.
The ALU performs a subtract on the data values read from the register file. The value of PC+4 is
added to sign-extended, lower 16 bits of the instruction (offset) shifted left by two; the result is the
branch target address.
The zero result from the ALU is used to decide which adder result to store into the PC.
4.
Assume that the operation times for the major functional its in this implementation are the following:
– memory units : 200 picoseconds
– ALU and Address : 100 ps
– Register file (read or write) : 50 ps
Instruction mix : 25% loads, 10% stores, 45% ALU instructions, 15% brand and 5% jumps. Using
these critical paths, you can compute the required length for each instructions class;
Instruction
class
Instruction
memory
Register
read
ALU
operation
Data
Memory
Register
write
Total
R-type
200
50
100
0
50
400 ps
Load word
200
50
100
200
50
600 ps
Store word
200
50
100
200
-
550 ps
Branch
200
50
100
0
-
350 ps
Jump
200
-
-
-
-
200 ps
To compare performance of single cycle machine for a single clock and variable clock, the find
performance ratio.
→
–
–
Let's start by comparing the CPU execution times.
CPU execution time = Instruction count × CPI × clock cycle time since CPI must be 1,
CPU execution time = Instruction count × clock cycle time
The clock cycle for a machine with a single clock for all instructions will be determined by the
longest instruction, which is 600 ps.
The average time per instruction with a variable clock is CPU clock cycle
= 600 × 25% + 550 × 10% + 400 × 45% + 350 × 15% + 200 × 5%
= 447.5 ps
Since the variable clock implementation has a shorter average clock cycle, it is clearly faster.
CPU performance variable clock
CPU execution time single clock
—————————————— = ——————————————
CPU perfromance single clock
CPU execution time variable clock
IC × CPU clock cycle single clock
CPU clock cycle single clock
= ———————————————– = —————————————
IC × CPU clock cycle variable clock
CPU clock cycle variable clock
600
= ——— = 1.34
447.5
The variable clock implementation would be 1.34 times faster.
5. (a) Express differences between the data path for the single cycle and multicycle.
(b) What are type of temporary register added to meet requirement of multicycle datapath, explain.
(a)
– A single memory unit is used for both instructions and data.
– There is a single ALU, rather than an ALU and two adders.
– One or more registers are added after every major functional unit to hold the output of that unit
until the value is used in a subsequent clock cycle.
(b)
–
The instruction register (IR) and the Memory data register (MDR) are added to save the output
of the memory for an instruction read and a data read, respectively. Two separate registers are
used, since, as will be clear shortly, both values are needed during the same clock cycle.
– The A and B registers are used to hold the register operand values read from the register file.
– The ALU out register holds the output of the ALU.
6. (a) Multicycle datapath requires additions to support branches and jump how operation of these
possible sources for the value to be written into PC, explain?
(b) Show complete multicycle datapath and control unit, including the additional control signals and
multiplexors for implementing the PC updating.
(a)
There are three possible sources for the value to be written into the PC:
1. The output of the ALU, which is the value PC + 4 during instruction fetch. This value should
be stored directly into the PC.
2. The register ALUOut, which is where we will store the address of the branch target after it is
computed.
3. The lower 26 bits of the Instruction register (IR) shifted left by two and concatenated with the
upper 4 bits of the incremented PC, which is the source when the instruction is a jump.
PC
0
M
U
X
1
Write
data
Memdata
Address
Memory
Memory
data
register
Instruction
[15-0]
Instruction
Memory
Instruction
[15-0]
Instruction
[20-16]
Instruction
[25-21]
Instruction
[31-26]
Instruction
[15-11]
[5-0]
OP
Control
Outputs
0
M
U
X
1
16
0
M
U
X
1
RegDst
RegWrite
32
Write
data
Write
register
Read
register 2
Read
register 1
Registers
Shift
left 2
Read
data 2
Read
data 1
Instruction [5-0]
Sign
extend
ALUSrcA
ALUSrcB
ALUOp
PCSource
B
A
4
0M
1 U
2 X
3
0
M
U
X
1
Figure : The complete datamth for the multicycle implementation
Instruction
[25-0]
MemtoReg
IR Write
MemWrite
MemRead
IorD
PCWrite
PCWriteCond
Shift
left 2
ALU
Control
28
ALU
result
ALU zero
PC [31-28]
26
ALU out
Jump
address
[31-0]
M
1 U
2 X
0
6. (b)
7.
Soln:
Using the SPECINT 2000 instruction mix; The mix is 25% load (1% load byte. 24% load word),
10% stores. (1% store bute + 9% Store woed): 11% branches (6% beq, 5% bne), 2% jump (1%
jal+ 1% jr) and 53% ALU. The number of clockcycle for each instruction class is following:
loads : 5
stores : 4
ALU instruction : 4
Branches : 3
Jumps : 3
What is the CPI, asuming that each state in multicycle CPU requires 1 clock cycle?
CPI
CPU clock cycles
Instruction count: × CPI
= ———————— = Σ ——————————i
Instruction count
Instruction count
Instruction counti
= Σ ————————
× CPIi
Instruction count
The ratio
Instruction counti
———————–
Instruction count
is simply the instruction frequency for the instruction class i.
CPI = 0.25 × 5 + 0.10 × 4 + 0.52 × 4 + 0.11 × 3 + 0.02 × 3 = 4.12
This CPI is better than the worst - case CPI of 5.0 when all the instruction take the same number
of clock cycles.
8.
Show complete finite state machine, including memory reference instructions, R type instruction,
Branches instruction and jump instruction control for datapath.
Instruction Fetch
6
ALUSrcA=1
ALUSrcB=00
ALUOp=10
ALUSrcA=1
ALUSrcB=10
ALUOp=00
(O
p
=
'SW
')
Memory
access
Memory
access
5
MemRead
IorD = 1
'J')
(Op = 'BEQ')
)
pe
Execution
2
(Op = 'LW')
ty
p
(O
Memory address
computation
3
')
SW
'
=
=
Op
r(
o
')
'LW
ALUSrcA=0
ALUSrcB=11
ALUOp=00
R-
Start
p=
(O
Instruction decoder/
register fetch
1
MemRead
ALUSrcA = 0
IorD = 0
IRWrite
ALUSrcB = 01
ALUOp = 00
PCWrite
PCSource = 00
Jump
completion
Branch
completion
8 ALUSrcA = 1
ALUSrcB = 00
ALUOp = 01
PCWriteCond
PCSource = 01
R-type completion
7
MemWrite
IorD = 1
=
(OP
0
RegDst = 1
RegWrite
MemtoReg=0
Memory read
completion
step
4
RegDst = 0
RegWrite
MemtoReg=1
Fig : The complete finite state machine control for the datapath.
9
PCWrite
PCSource=10
9.
Show complete finite machinc with handle exception control for the datapath.
Instruction Fetch
0
Instruction decoder/
register fetch
1
MemRead
ALUSrcA = 0
IorD = 0
IRWrite
ALUSrcB = 01
ALUOp = 00
PCWrite
PCSource = 00
Start
ALUSrcA=0
ALUSrcB=11
ALUOp=00
(O
p
=
ot
he
6
ALUSrcA=1
ALUSrcB=00
ALUOp=10
ALUSrcA=1
ALUSrcB=10
ALUOp=00
p=
(O
')
'SW
Memory
access
3
Memory
access
5
MemRead
IorD = 1
Write back
step
8 ALUSrcA = 1
ALUSrcB = 00
ALUOp = 01
PCWriteCond
PCSource = 01
R-type
completion
7
MemWrite
IorD = 1
'J')
=
(OP
Jump
completion
Branch
completion
Execution
2
(Op
= 'BE
Q')
)
pe
ty
R=
p
(O
Memory address
computation
(Op = 'LW')
r)
p=
(O
Op
r(
o
')
'LW
')
SW
'
=
RegDst = 1 over
RegWrite
MemtoReg=0 flow
11 IntCause=1
CauseWrite
ALUSrcA=0
ALUSrcB=01
ALUOp=01
EPCWrite
PCWrite
PCSource=11
9
PCWrite
PCSource=10
10
IntCause=0
CauseWrite
ALUSrcA=0
ALUSrcB=01
ALUOp=01
EPCWrite
PCWrite
PCSource=11
———
overflow
4
RegDst = 0
RegWrite
MemtoReg=1
Fig : Complete finite machine with handle exception control for the datapath
10.
How do you understand exception and Interrupts.
Exception
Alsos called interrupt. An unscheduled event that disrupts program execution; used to detect overflow.
Interrupts
An exception that comes from outside of the processor.
11.
How can be handled the exceptions in current implementation, what perform of basic action for
machine and operating system
The two types of exceptions that our current implementation can generate are execution of
an undefined instruction and an arithmetic overflow. The basic action that the machine must perform
when an exception program occurs is to save address of the offending instruction in the exception
program counter (EPC) and then transfer control to the operating system at same specified address.
The operating system can then take the appropriate action, which may involve providing
some service to the user program, taking some predefined action in response to an overflow, or
stopping the execution of the program and reporting an error. After performing whatever action is
required because of the exception, the operating system can terminate the program or may continue
its execution, using the EPC to determine where to restart the execution of the program.
12. (a)
lw $1, 100 ($0)
lw $2, 200 ($0)
lw $3, 300 ($0)
Compare nonpipelined and pipelined execution of three load ward instruction.
(b) What do you understand about hazards in pipelining, explain them?
(a)
Program
execution
order
Time
200
400
600
800 1000 1200 1400 1600 1800
————————————————————————————→
?
?
?
?
?
?
?
?
?
(in instructions)
lw $1, 100 ($0) Instruction Reg ALU Data Reg
Fetch
access
←———————–————→ Instruction
Data
lw $2, 200 ($0)
800 ps
Reg
Reg ALU
Fetch
access
lw $3, 300 ($0)
Program
execution Time
order
←———————–————→ Instruction
800 ps
Fetch
←—...→
800 ps
200
400
600
800
1000
1200 1400
?
?
?
?
?
?
?
———————————————————————————————→
(in instructions)
Instruction
Data
lw $1, 100 ($0)
Reg
ALU
Reg
Fetch
access
←——→
Data
lw $2, 200 ($0) 200 ps Instruction
Reg
ALU
Fetch
access
←——→ Instruction
lw $3, 300 ($0)
200 ps
Reg
ALU
Fetch
←——→ ←——→ ←——→
200 ps
200 ps
200 ps
Reg
Data
Reg
access
←——→ ←——→
200 ps
200 ps
Fig : Nonpipelined and pipelined execution of three load ward instruction
(b)
There are situations in pipelining when the next instruction cannot execute in the following clock
cycle. These events are called hazards, and there are three different types.
Structural hazard
An occurrence in which a planned instruction cannot execute in the proper clock cycle because the
hardware cannot support the combination of instructions that are set to execute in the given.clock cycle
Data hazard
Also called pipeline data hazard. An occurrence in which a planned instruction cannot execute in
the proper clock cycle because data that is needed to execute the instruction is N yet available.
Control hazard
Also called branch hazard. An occurrence in which the proper instruction cannot execute in the
proper clock cycle because the instruction that was fetched is not the one that is needed; that is, the flow
of instruction address is not what the pipeline expected.
13.
Consider the following code segments in C:
A=B–E;
C=B+F;
Here is the generated MIPS code for this segments, assuming all variables are in memory and are
addressable as offset from $t0
lw $t1, 0 ($t0)
lw $t2, 4 ($t0)
sub $t3, $t1, $t2
sw $t3, 12 ($t0)
lw $t4, 8 ($t0)
add $t5, $t1, $t4
sw $t5, 16 ($t0)
Find the hazards in these following code segments and reorder the instructions to avoid any pipeline
stalls.
Ans:
Both sub and add instructions have a hazard because of their respective dependence on the
immediately preceeding lw instruction. Moving up the third lw eliminates both hazards.
lw $t1, 0 ($t0)
lw $t2, 4 ($t0)
lw $t4, 8 ($t0)
sub $t3, $t1, $t2
sw $t3, 12 ($t0)
add $t5, $t1, $t4
sw $t5, 16 ($t0)
14.
Draw pipeling showing stalling in the following instructions:
add
$4, $5, $6
beq
$1, $2, 40
or
$7, $8, $9 and
Computers to indeed use prediction to handle branches, pipeline is stall when branches are taken.
Shows drawing the pipeling these approaches with figures.
Program
200
400
600
800
1000
1200 1400
?
?
?
?
?
?
?
execution Time ———————————————————————————————→
order
(in instructions)
Instruction
Data
Reg
ALU
Reg
add $4, $5, $6
Fetch
access
←——→ Instruction
Data
beq $1, $2, 40
200 ps
Reg
ALU
Reg
Fetch
access
bubble
or
$7, $8, $9
bubble
←———————→ Instruction
400 ps
Fetch
bubble
Reg
bubble
bubble
ALU
Data
access
Reg
Fig : Pipeline stalling on these three instructions
Program
200
400
600
800
1000
1200 1400
?
?
?
?
?
?
?
execution Time ———————————————————————————————→
order
(in instructions)
Instruction
Data
Reg
ALU
Reg
add $4, $5, $6
Fetch
access
←——→ Instruction
Data
200 ps
Reg
ALU
Reg
beq $1, $2, 40
Fetch
access
←——→ Instruction
Data
Reg
ALU
Reg
200 ps
lw $3, 300 ($0)
Fetch
access
Fig : Untaken branch in pipelining
200
400
600
800
1000
1200 1400
Program
?
?
?
?
?
?
?
execution Time ———————————————————————————————→
order
(in instructions) Instruction
Data
Reg
ALU
Reg
Fetch
add $4, $5, $6
access
←——→ Instruction
Data
Reg
ALU
Reg
beq $1, $2, 40 200 ps
Fetch
access
bubble
or
$7', $8, $9
bubble
←———————→ Instruction
400 ps
Fetch
Fig : Taken branch in pipelining
bubble
Reg
bubble
bubble
ALU
Data
access
Reg
15.
What is the latency.
Latency (pipeline)
The number of stages in a pipeline or the number of stages between two instructions during
execution.
16.
Draw the correct pipelined datapath to property handle the load instruction, then highlighting the
portion of first and fourth pipeline state.
123456
123456
123456
0
123456
123456
123456
M
123456
123456
U
123456
123456
123456
X
123456
123456
1
123456
123456
123456
123456
123456
123456
123456
123456
123456
PC
123456
123456
123456
123456
123456
123456
Fig :
12345678
12345678
12345678
12345678
Address
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
Instruction
12345678
12345678
12345678
memory
12345678
12345678
12345678
12345678
12345678
IF/ID
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
EX/MEM
1234
ID/EX
Shift
left 2
Instruction
4
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
Add
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
Add
ALU
result
Read
register 1
Read
Read
register 2 data 1
Write
register
Read
data 2
Write
data Registers
16
Sign
extend
32
0
M
U
X
1
Zero
ALU
ALU
result
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
MEM/WB
123
12345678
12345678
12345678
12345678
Address
12345678
Read
12345678
12345678
data
12345678
12345678
12345678
12345678
Data12345678
12345678
12345678
memory
12345678
12345678
12345678
Write12345678
12345678
data 12345678
12345678
12345678
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
1
M
U
X
0
The correct pipelined datapath to property handle the load instruction, then highlighting the portion
of first and fourth pipeline state.
17.
Consider the following five instructions sequence.
lw
$5, 40 ($2)
add
$6, $3, $2
or
$7, $2, $1
and
$8, $4, $3
sub
$9, $2, $1
Show the multiple clock cycle pipeline design using physical resources at each stage.
Program
Time (in clock cycle)
execution
——————————————————————————————————→
CC2
CC3
CC4
CC5
CC6
CC1
CC2
CC3
CC1
order
123
12
123
123
123
12
123
123
123
12
123
123
1234567 123
12345 123
1234 12
12345 123
12345
123
12
123
123
1234567
(In instruction)
12345 123
1234 12 1234567 123
12345 123 12345
12345 123
1234 12 1234567 123
12345 123 12345
12345 123
1234 12 1234567
123
12345 123 12345
IM
Reg
A
L
U
DM
Reg
12345
1234
12345
1234567 123
lw $5, 40 ($2)
12345 123
123
1234 12
123
12345 123
123 12345
12345
12
123
12 1234567
123
1234567 123
123
123
123
123
add $6, $3, $2
or
$7, $2, $1
and $8, $4, $3
sub $9, $2, $1
12345
12345
12345
12345
12345
IM
12345
12345
12
12
12
12
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
1234
1234
1234
1234
1234
Reg
1234
1234
12345
12345
12345
12345
12345
IM
12345
12345
123
123
123
123
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
1234567
1234567
1234567
1234567
1234567
ALU
1234567
1234567
1234567
12345
12345
12345
12345
12345
Reg
12345
12345
1234
1234
1234
1234
1234
IM
1234
1234
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
DM
123456
123456
123456
123456
123456
ALU
123456
123456
123456
1234
1234
1234
1234
1234
Reg
1234
1234
12345
12345
12345
12345
12345
IM
12345
12345
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
1234
1234
1234
1234
1234
Reg
1234
1234
123
123
123
123
123
123
123
123
DM 123
123
123
123
123
123
123
123
123
123
123
123
1234567
1234567 123
123
1234567
1234567 123
123
1234567
A
L
U
1234567 123
123
1234567
1234567 123
123
123
123
123
123
123
123
123
123
12345
123
123
12345
123
12345
12345
123
123
12345
Reg
12345
12345 123
123
123
123
123
123
123
Fig : Multiple clock cycle pipelining design using resources.
12345
12345
12345
12345
12345
Reg
12345
12345
DM
123456
123456
123456
123456
123456
ALU
123456
123456
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
1234
1234
1234
1234
1234
Reg
1234
1234
DM
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
12345
12345
12345
12345
12345
Reg
12345
12345
Draw the correct pipelined datapath to property handle the store instruction, then highlighting the full stage
pipeline, what happen in write back stage. (16 M)
4
123456
123456
123456
0
123456
123456
M
123456
123456
123456
U
123456
123456
X
123456
123456
123456
1
123456
Figure :
123456
123456
123456
123456
123456
123456
123456
123456
123456
PC
123456
123456
123456
123456
123456
123456
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
Add
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678901
12345678
12345678
12345678
12345678
Address
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
Instruction
12345678
12345678
12345678
memory
12345678
12345678
12345678
12345678
IF/ID
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
12345
Instruction
18.
EX/MEM
123456
ID/EX
123456
123456
12345678901
12345678901
12345678901
Read 12345678901
12345678901
12345678901
register 12345678901
1
12345678901
12345678901
12345678901
12345678901
Read 12345678901
Read
12345678901
12345678901
register 12345678901
2 data 1
12345678901
12345678901
12345678901
Write 12345678901
12345678901
12345678901
Read
register 12345678901
12345678901
12345678901
12345678901
data 2
12345678901
Write 12345678901
12345678901
12345678901
12345678901
data Registers
12345678901
12345678901
16
Sign
extend
32
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
Shift
left 2
0
M
U
X
1
Add
ALU
result
Zero
ALU
ALU
result
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
123456
MEM/WB
12345678
12345678
12345678
Address
12345678
12345678
Read
12345678
12345678 data
12345678
12345678
12345678
12345678
Data
12345678
12345678
12345678
memory
12345678
12345678
12345678
12345678
Write
12345678
12345678
data
12345678
12345678
The correct pipelined datapath to handle the store instruction, highlighting the full stage pipeline
Nothing happens in the write back stage.
1
M
U
X
0
19.
Specify control signal for execution / address calculation, memory access and write back stage. Shows
draw that there control signals are used in the appropriate pipeline stage. (8 M)
Solution
Execution / address calculation : The signals to be set are RegDst, ALUOp, and ALUSrc. The signals
select the Result register, the ALU operation, and either Read data 2 or a sign-extended immediate for the ALU.
Memory access : The control lines set in this stage are Branch, MemRead and MemWrite. These signals
are set by the branch equal, bad, and store instructions, respectively. Recall that PCSrc selects the next sequential
address unless control asserts Branch and the ALU result was zero.
Write back : The two control lines are MemtoReg, which decides between sending the ALU result or the
memory value to the register file and RegWrite, which writes the chosen value.
WB
Instruction
M
WB
Control
M
WB
EX/MEM
MEM/WB
EX
IF/ID
ID/EX
Fig : The control lines for the final three stages.
20.
Considering executing the following code in the pipeline datapath.
lw
$2, 20 ($1)
and
$4, $2, $5
or
$8, $2, $6
add
$9, $6, $4
Slt
$1, $6, $7
How many clockcycles will it takes to execute this code? Draw a diagram that illustrates the dependencies
these instruction.
Program
Time (in clock cycle)
execution
——————————————————————————————————→
CC2
CC3
CC4
CC5
CC6
CC7
CC8
CC9
CC1
123
12
123
123
order
123
12
123
123
12
123
123
123
12
123
123
123
12345 123
1234 12
1234567 123
12345 123
(In instruction)
12
123
123 1234
12345 123
1234
1234567
12345
12 1234567 123
123 1234
12345 123
1234
12345
12 1234567 123
123
123 1234
12345
1234
12345
1234
12345 123
1234 12
1234567
12345 123
1234
IM
Reg
ALU 123
DM
Reg
12
123
123
123
1234567
12345
1234
12345
1234
lw
$2, 20 ($1) 12345 123
12 1234567 123
123
1234
12345
123
12 1234567 123
123 1234
123
123
123
123
and
or
$4, $2, $5
$8, $2, $6
12345
12345
12345
12345
12345
IM
12345
12345
12
12
12
12
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
1234
1234
1234
1234
1234
Reg
1234
1234
12345
12345
12345
12345
IM
12345
12345
12345
1234567
1234567
1234567
1234567
1234567
ALU
1234567
1234567
12345
12345
12345
12345
Reg
12345
12345
12345
1234
1234
1234
add
Slt
$9, $6, $4
$1, $6, $7
1234
IM
1234
1234
1234
DM
123456
123456
123456
123456
ALU
123456
123456
123456
1234
1234
1234
1234
Reg
1234
1234
1234
12345
12345
12345
12345
IM
12345
12345
12345
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
1234
1234
1234
1234
1234
Reg
1234
1234
123
123
123
123
123
123
123
DM 123
123
123
123
123
123
123
123
123
123
123
123
123
1234567
1234567 123
123
1234567
123
1234567
ALU 123
123
1234567
123
1234567
1234567 123
123
123
123
123
123
123
123
123
123
12345
12345 123
123
12345
123
12345
Reg
12345 123
123
12345
12345 123
123
123
123
123
123
123
12345
12345
12345
12345
Reg
12345
12345
12345
DM
123456
123456
123456
123456
ALU
123456
123456
123456
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
1234
1234
1234
1234
Reg
1234
1234
1234
DM
A pipelined sequence of instruction showing the dependence between the 'load' and 'and' instructions.
It will takes 9 clock cycles to execute this code.
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
12345
12345
12345
12345
Reg
12345
12345
12345
21.
Draw the pipeline connection for both hazard detection unit and forwarding unit, if necessary, adding two
multiplexors for there units?
PC Write
IF/ID Write
Hazard
detection
unit
PC
Control
0
0
M
U
X
1
IF/ID
Instruction
memory
Read
Read
register 1
data 1
Read
register 2
Write
register
ID/EX
EX/MEM
MEM/WB
WB
WB
WB
M
M
EX
0
M
U
X
1
Add
ALU
result
0
M
U
X
1
Address
Read
data
Data
memory
Write
data
Read
data 2
Write
data Registers
IF/ID RegisterRs
IF/ID Register Rt
IF/ID Register Rt
Rt 0
IF/ID Register Rd
M
U
X
Rd 1
ID/EX Register Rt
Rs
Rt
Forwarding
Unit
Fig : Pipeline control which two multiplexore for both hazard detection unit and forwarding unit.
1
M
U
X
0
22. (a) Show how to map referenced lower order bits of an address is used to find the unique cache entry.
(b) Why does a valid bit add to direct mapped cache.
(c) How many total bits are required for a direct mapped cache with 16KB of data and 4 word blocks,
assuming 32 bits address? (16 M)
Address (showing bit positions)
31 30 . . . . . . 13 12 11 . . . 2 1 0
(a)
Byte
offset
20
Hit
10
Tag
Index
Index
0
1
2
.....
.....
.....
.....
1021
1022
1023
Valid
Data
Data
Tag
20
32
=
(b)
(c)
To add a valid bit to indicate whether an entry contains a valid address. If the bit is not set, there cannot
be a match for this block.
16 KB
desire cache data size = ———
4
= 4 Kwords
= 22 × 210 words
So, Block size is 4 words (22 = m) and then 210 = n blocks. The word within the block is
Index is = n = 10
The number of total required bits in cache is
2n × (m × 32 + (32 – n – m – 2) + 1)
= 210 (128 + (32 – 10 – 2 – 2) + 1)
= 210 (128 + 18 + 1)
= 147 Kbits
147 K
= ——— = 18.37 ≈ 18.4 KB
8
For the cache, total number of bits in cache is about 1.15 times of 16 KB cache.
BE – IT – 5017
Fuzzy Control and Neural Network
Sample Questions and Answers
For
Final Exam, 2008.
B.E. (IT)
Fuzzy Control and Neural Network
Chapter - 7
Classical Logic & fuzzy Logic
1.
Suppose we have two universe of discourse for a heat exchanger problem described
by the following collection of elements, X = {1, 2, 3, 4} and Y = {1, 2, 3, 4, 5, 6}. Suppose X
is a universe of normalized temperatures and Y is a universe pressure. Define crisp set A on
Universe X and crisp set B on Universe. Y as follows : A = {2, 3} and B = {3, 4}. The
deductive inference. If A, THEN B (i.e., If temperature is A, THEN pressure is B. Determine
the matrix R represents the rule If A, THEN B by using classical implication.
Suppose we define a crisp set C on the universe of normalized pressure Y as C = {5, 6}, or wing
Zadeh's notation, determine the matrix R represents the rule If A, THEN B, ELSEC.
2.
For research on the human visual system, it is sometimes necessary to characterize the strength
of response to C visual stimulus based on magnetic field measurement or on an electrical potential
measurement. When using magnetic field measurement, a typical experiment will require nearly 100off/
on presentations of the stimulus at one location to obtain useful data. If the researcher is attempting to
map the visual cortex of the brain, several stimulus locations must be used in the experiments. When
working with a new subject, a researcher will make preliminary measurements to determine if the type
of stimulus being used evoker a good response in the subject. The magnetic measurements are in units
of fan totesla (10-15 tesla). Therefore, the inputs and outputs are both measured in terms of magnetic
units.
We will define inputs on the universe X = [0, 30, 100, 150, 200] fanto tesla, and outputs on the
universe Y = [0, 50, 100, 150, 200] fantotesla. We will desire.
two fuzzy sets, two different stimuli, on universe X.
W = "weak stimulus" = { 1 + 0.9 + 0.3 + 0 + 0 } C X
~
0
50 100 150 200
M = ''medium stimulus" = { 0 + 0.4 + 1 + 0.4 + 0 } CX
~
0
50 100 150 200
and one fuzzy at on the output universe Y,
0.5
0.9
S = "severe response" = { 0 + 0 +
+
+ 1 } CY
~
0
50
150
200
100
And the proposition : IF "weak stimulus" THEN not "severe response", using classical implication.
Now, using a new antecedent (IF part) for the input, M
~ = "medium stimuli" Find another response on the Y universe to relate approximately to the new stimulus M
~ , by using max-min composition.
3.
Prove that the following statements are tautologies.
(a) [(P Ž Q) ∩ P] Ž Q
(b) (P
(c) {(P
4.
Q) Ž P
Q)
}ŽQ
Suppose we have a distillation process where the objective is to separate component of a
∪ the input variable, temperature, and the output
∩
mixture in the input stream. The relationship between
P~
A
variable, distillate fractions, is not precize but the human operator of this process has developed an
intuitive understanding of this relationship. The universe for each of there variables is
X
= Universe of temperature (ºF) = {160, 165, 170, 175, 180, 185, 190, 195}
Y
= Universe of distillate fractions (percentages) = {77, 80, 83, 86, 89, 92, 95, 98}
and B
~ on X and Y, respectively :
= temperature of input steam is hot = { 0 + 0.7 + 1 + 0.4 }
175 180 185 190
Now we define fuzzy sets,
A
~
B
~
= Separation of mixture is good = {
0
0.5 0.8
+
+
+ 1 }
89 92
95 98
We wish to determine the proposition, If "temperature is hot" THEN separation of mixture is good" or
→ B from this.
symbolically. A
~
~
(a)
A B
Find R
~ =(~ x ~ ) ∪ (
(b)
Now define another fuzzy linguistic variable as
x Y)
A' = { 1 + 0.8 + 0.5 + 0.2 }
~
170 175 180 185
For the "new" rule If A' THEN B' using max-min composition
5.
A company sells a product called a video multiplexer that multiplexes the video signal from 16
video cameras into a single video cassette recorder (VCR). Define the universe of X to be the
discrete speed of the objects that are present in the video of camera 1, X = {Low speed,
medium speed, high speed} = {LS, MS, HS}. Define the universe of Y to represent the
discrete frequency with which the video from camera 1 is recorded to VCR tape, recording
rate of camera 1:
Y
Ž= {Slow recording rate, medium rate, fast recording rate} = {SRR, MRR, SRR}. Define fuzzy
variable A
~ to be "slow-moving object"
present in camera 1 and fuzzy variable B
~ to be "slow recording rate". The two membership functions
are as follows.
1
+ 0.4 + 0.2 }
LS MS
HS
A
~
={
B
~
0.5
0.25
={ 1 +
+
}
SRR
MRR
FRR
B
(a) Calculate the associated fuzzy logic relation for the Compound proposition. "If x is A
~ , then y is ~ "
using classical implication.
'
(b) We pose another fuzzy linguistic variable A
~ = "fast-moving object" present in video camera 1,
which is also define on universe X, with membership function.
A'
~
= { 0.1 + 0.3 + 1 }
LS
MS
HS
Using max - min compostion, find the multiplexer’s recording rate associated with the relation developed in part a,
6.
In Computer system there is a relationship between CPU Žcapitalletter board tempera-
ture and power supply voltage. Let us consider the following relation: If the temperature (in degrees
Fahrenheit) is high, THEN the power supply voltage(in volts) will drop or become low. Let
A
~
= temperature is high
B
~
= voltage is low
A → B = If the temperature is high,THEN voltage will be low.
~
~
The following membership functions might be appropriate for there two variables.
 0.1 0.5 0.7 0.9
1 
A= +
+
+
+
~  50 75 100 125 150 
 1
0.8 0.5 0.2
0 
B=
+
+
+
+
~  4.0 4.25 4.5 4.75 5.0 
→B
(a)Using classical implication, find the relation A
~
~
(b)Suppose we consider another temperature; Say, let A
~ = temperature is very high.
 0 0.2 0.4 0.6
1 
A= +
+
+
+
~  50 75 100 125 150 
Find the appropriate voltage for this temperature using max-product composition. With the
relation found in part(a).
7.
Suppose we are trying to maintain a consistent voltage outgoing quality level in a manufacturing
A
process. Attribute imperfections are assigned a seventy
of S = {0,2,3,4,5} and the universe of sam~
pling rate (on a frequency basic) is F = {200, 250, 300, 350, 400}. A seventy of zero means “no
imperfection” . A severity of 5 means “severe imperfection” A sample is evaluated and the result is
denoted by two fuzzy sets
for “medium severity” and B
~ for “moderate sampling rate”. We wish to
B
construct a compound proposition. If A
~ THEN ~ . The evaluator has assigned the following fuzzy
sets to represent the linguistic assignment:
 0.4 1 0.5 
A =" medium severity"
+ +

~
 2 3 4 
 0.6 0.9 0.5 0.2 
B =" moderate samplingrate = 
+
+
+

~
 200 250 300 350 
(a) Find the relation expressing this compound
(b) Suppose the imperfection severity for a new batch of samples changes to “surve imperfection.”
i.e; the membership function for the new antecedent is
 0.6 1 0.6 
A=
+ +
~  3 4 5 
Find the sampling rate associcted with this imperfection.
8.
In machines, the energy of a moving body is called kinetic energy. If an object of mass
m(kg) is moving with a velocity v(m/s), the kinetic energy k (J) is given by the equation k=1/
2 mv2 suppose we modal the mass and velocity as inputs to a system (moving body) and the
energy as output, them observe the system for a while and dedue the following two dis
junctive rules of inference.
1
1
A (high velocity), THEN y is B1 (medium energy)
Rule1. If x1 is A
(small
mass)
and
x
is
2|
~
~1
~2
2
2
2
(large mass) or x 2 is A (medium velocity), THEN y is x 2 is B (high enRule2. If x1 is A
~1
~2
~
ergy)
Rule 1
small
A11
µ
High
µ
µ
Medium
B1
A 12
min
55
250
x2
x1
y
0.35
-1 -2 -3 -4 -5
20 40 50 60
Rule 2
Large
A21
µ
100 200
400 500
Medium
A 22
µ
max
55
x1
250
x2
0.35
0 -1 -2 -3 -4 -5
20 40 50 60
µ
y
y*
100 200 300 400 500
y
100 200 300 400 500
Let the two inputs, input(i) = 0.35kg(mass), input(j)=55m/s velocity, as crisp values. Find the output
fuzzy membership function is defuzzified using the weighted average method.
9.
A factory process control operation involves two linguistic(atomic) parameters consisting of
pressure and temperature in a fluid delivery system. Normal pressure limits range from 400 priminimom
to 100psi maximum. Normal temperature limits are 130ºF to 140ºF . We characterize each parameter
in fuzzy linguistic terms as follows:
(a)
.
 1
0 .8 0 .6 0 .4 0 .2
0 
+
+
“ low ” temperature = 131 132 133 + 134 + 135 + 136 


.
 0
0 .2 0 .4 0 .6 0 .8
1 
“ High” temperature = 134 + 135 + 136 + 137 + 138 + 139 


.
 0
0 .2 0 .4
0 .6 0 .8
1 
“ High” temperature =  400 + 600 + 700 + 800 + 900 + 1000 


.
 1
0 .8 0 .6
0 .4 0 .2
0 
“ low ” temperature =  400 + 600 + 700 + 800 + 900 + 1000 


Find the following membership functions:
(i) Temperature not very low
(ii) Temperature not very high
(iii)Temperature not very low and not very high
(b)
Find the following membership functions:
(i) pressure slightly high
2


(ii) pressure fairly high  [ligh]3 


(iii) pressure not very low or fairly low
10.
The sensitivity of typical CCD (Charge - Complect Device) cameras is defined in terms of the
minimum usable face-plate illumination as measured in food condles(fc). This is the illumination that
producer a specific peak to peak video level on an osilloscope. The universe of is defined as fc= face
- place illumination in foot condles = {0,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.1} . Two
atomic variables are defined on the universe fc(i) “sensitive” represent a camera that has high
sensitive hence a small minimum usable face. Plate illumination, so it has high membership
values at low illuminations and low membership values at high illuminations; (ii) “Insensitive”
represents a camera that has low sensitivity, hence a high minimum usable face - plate
ilumination, so it has low membership values at low illumunation and high membership values
of high illumination. The membership function for there two variables is given here, where the
summation sign denotes it union:
 1 − 0.1 i 
“sensitive” = ∑ 0.01.i  for i=1,2,...,10
 i

 0.1. i 
“Insensitive”= ∑
 for i-1,2,....,10
 i 0.01.i 
Define the membership function for the following there linguistic expressions:
(a) Not very sensitives.
(d) Very, very sensitive or very insensitive
(c) Not highly insensitive and not every sensitive
11.
In reference to car spaced, we have the linguistic variables “fast” and “slow” for speed:
 0 0.1 0.2 0.1 0.4 0.5 0.6 0.7 0.8 0.9 1 
+ +
+
+
+
+
+
+

“fast” =  + +
 0 10 20 30 40 50 60 70 80 90 100 
 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 
+
+
+
+
+
+ +
+ +

“slow” =  +
 0 10 20 30 40 50 60 70 80 90 100 
Using there variable, computer the membership function for the following linguistic terms:
(a) very fast
(b) very, very fast
(c) Hightly fast = minus very, very fast
(d) plus very fast
 = [fast ]23 

(e) fairly fast 


(f) Not very slow and not very fast
(g) slow or not very slow
12.
Consider the domain of attitude control or a spin - stabilized space verticle. In order to change
the attitude of the vehicle, the roll orientation of the vehicle, say φ , has to be in a specific position, and
the roll rate to be within a certain bound, say a slow rate and a fast rate. Let these two rates be defined
as linguistic variables on a universe of degrees per second.
“Fast” =
0 
1 0.8 0.6 0.4 0.2
+
+
+
+

=  +
1 100 200 300 400 500 
“Slow”
Find memberships functions for the following natural language phrases:
(a)
Slightly fast or very fast
(b)
Fairly slow(= [slow] /3)
(c)
Slightly fast and fairly slow
(d)
Not slightly fast or slow
(e)
Not very fast or fairly slow
13.
In vehicle navigation the mapping source of information uses shape points to define the curvature
2
1 
 0 0.2 0.4 0.6 0.8
+
+
+
+
 +

 1 100 200 300 400 500 
of a turning maneuver. A segment is a length of road between two points. If the segment is linear, it has
no or very few shape points. If the road is winding or circular, the segment can have many shape points.
Assume that up to nine shape points can define any curvature in a typical road segment. The universe
of discourse of shape points then varies from 0 (linear road) to 9 (extremely curved). Define the
following membership functions:
“some what straight”
 1 0 .9 0 .8 0 .7 0 .6 0 .5 0 .4 0 .3 0 .2 0 .1 
+
+
+
+
+
+
+
+
 +

1
2
3
4
5
6
7
8
9 
0
=
 0 0 .1 0 .2 0 .3 0 .4 0 .5 0 .6 0 .7 0 .8 0 .9 
+
+
+
+
+
+
+
+
+

1
2
3
4
5
6
7
8
9 
0
“Curved” = 
Calculate the membership functions for the following phrases :
(a)
Very curved
(b)
Fairly curved ( = [curved] /3)
(c)
Very, Very somewhat straight
(d)
Not fairly curved and very, somewhat straight
2
Chapter - 10
Fuzzy Decision Making
14.
Suppose we have three fuzzy sets as described using Zadeh’s notation
1 0 .8 
0.7 1.0
I1 =  +
 and I2 =  + 
~ 3 7 
~
4 6
and I~3 =
 0.8 1 0.5 
 + + 
 2 4 8 
Determine overall ordering for three fuzzy sets.
15.
In maufacturing, we often try to compare the capabilities of various microprocessors for their
appropriateness to certain application. Since many factors can affect this decision, including performance, cost, availability, software and others. Another consideration is that it is much easier to compare these microprocessors subjectively in pairs. We use pairwise membership functions that represent the subjective measurement of the appropriateness of each microprocessor when compared only
to one another. The following pairwise functions are as follows.
fx1 (x1) = 1
fx1 (x2) = 0.5
fx1 (x3) = 0.3
fx1 (x4) = 0.2
fx2 (x1) = 0.7
fx2 (x2) = 1
fx2 (x3) = 0.8
fx2 (x4) = 0.9
fx3 (x1) = 0.5
fx3 (x2) = 0.3
fx3 (x3) = 1
fx3 (x4) = 0.7
fx4 (x1) = 0.3
fx4 (x2) = 0.1
fx4 (x3) = 0.3
fx4 (x4) = 1
Develop a comparison matrix and determine the overall ranking.
16.
A geotechnical engineer on a construction project must prevent a large mass of soil from sliding
into a building site during construction and must retain this mass of soil indefinitely. The alternative
retaining wall designs are (i) a mechanically stabilizies embankment (MSE) wall (ii) a mass concrete
spread wall (conc) and (iii) a gabion (Gab) wall. The owner of the facility has defined four objective
that impact this decision (i) the cost of the wall (cost) (ii) the maintainablility (Main) of the wall (iii)
whether the design is a standard one (SD) and (iv) the environmental impact of the wall.
1
0.1 
 0.4
O1 = 
+
+

~
 MSE Conc Gab 
0.8
0.4 
 0.7
O2 = 
+
+

~
 MSE Conc Gab 
0.4
1 
 0.2
O3 = 
+
+

~
 MSE Conc Gab 
0.5
0.5 
 1
O4 = 
+
+

~
 MSE Conc Gab 
The preferences are given by b1 = 0.5, b2 = 0.7, b3 = 0.8, b4 = 0.7
Determine the optimum choice of retaining wall design.
17.
When designing a radav system for imaging purposes, we frequently need to set priorities in a
accomplishing certain features. Some feature that need to be traded off against each other Let x1
represent penetration; x2, resolution; x3, antenna size and x4 power. These are entities than can only be
compared in a very subjective manner, ideal for fuzzy techniques. Let fxi(xj) be relative importance of
feature xi with respect to xi. The comparison fxi(xj) are subjectively.
assigned as follows
xj
x1
x2
x3
x4
xi
x1
1
0.5
0.9
0.3
x2
0.6
1
0.8
0.2
x3
0.5
0.7
1
0.3
x4
0.9
0.8
0.5
1
Develop a comparison matrix and determine the overall ranking of the importance of each feature.
18. A carcinogen, trichloroethylene (TCE), has been detected in soil and ground water at levels higher
than the EPA maximum contaminatn levels (MCLs). There is an immediate need to remediate soil and
ground water. Three remediation alternative (i) pump and treat with air stripping (PTA) , (ii) pump and
treat with photoxidotion (PTP) and (iii) bioremediation of soil with pump and treat with air
stripping (BPTA) are investigated.
The objecitve are these cost (O1), effectiveness (O2), duration (O3) and speed of implementation (O4), The ranking of alternative on each objective are given as follows.
0.9
0.3 
 0.7
O1 = 
+
+

~
 PTA PTP BPTA 
0.6
0.8 
 0.4
O2 = 
+
+

~
 PTA PTP BPTA 
0.3
0.6 
 0.7
O3 = 
+
+

~
 PTA PTP BPTA 
0.5
0.5 
 0.8
O4 = 
+
+

~
 PTA PTP BPTA 
The preference for each objective are p= {0.6, 0.8, 0.7, 0.5}. Determine optimum choice of a
remediation alternative.
19.
Suppose you are geological engineer who has been asked by chief executive officer (CEO)
of a large oil firm to help make a decision about whether to drill for natural gas in a particular geographic region of northwestern. New Mexico. We had two states of nature, there is gas (S1) and no
gas (S2) Two alternative, drill for gas (O1) and don’t drill (O2). The prior probabilites were
P(S1) = 0.5
P(S2) = 0.5
Utility matrix
for natural
gas
Determine Posterior
Probability
based
on perfect information.
Uji
S1
S2
a1
4
-2
a2
-1
2
{ 1,2,3,4 }
No.1 X=
{ 1,2,3,4,5,6 }
Y==
X is aUniverse Of Normalized Temperature
Y is a Universe Of Normalized Pressure
A= { 2 , 3 }
B= { 3 , 4 }
C= { 5 , 6 }
A=
+
B=
+
C=
+
+
+
+
+
+
+
+
+
+
+
R=(A×B) ( A ×Y)
A×B=
Y=
A=
+
+
+
+
+
+
+
( A ×Y) =
R=(A×B) ( A ×Y)
=
If A ,THEN B, ELSE C
+
R=(A×B) ( A ×C)
( A ×C) =
R= (A×B) ( A ×C)
=
{ 0, 50,100,150,200 }
No.2 Universe X=
Universe Y= { 0, 50,100,150,200 }
W
~ =
M
~=
S
~=
weak stimulus=
medium stimulus=
Severe response=
S
~=
IF
(
+
W
~
+
+
THEN
S
~
W S
~ ×~
)=
=
+
=
W
~
+
+
+
+
+
+
+
+
+
X
+
X
+
Y
+
S
~
=(
W S
~ ×~
)
(
W
~ ×
Y)
W
~ ×
Y==
=
R
~=
(
W S
~ ×~
)
(
W
~ ×
Y)
R
~=
By using max-min composition
M
~
R
~
=
M
~
R
~
=
M
~
R
~
0.7 0 .7 0.7 0 .7
3 (a) ((P
Q)
((P
Q)
P
(( P
P ) (Q
(
(Q
P))
(Q
P)
Q
(Q
P) Q
P
Q
Q
Implication
P))
Q
Q
Distributivity
law of contradiction
Identity
(Q
P) Q
(Q
Q) P
X
P
X
T(X) =1
Truth Table
P
Q
P
0
0
1
0
1
0
1
1
0
1
1
0
0
0
1
1
1
1
1
1
3 (b)
((P Q)
((P
Q)
P
((P
Q)
P
( P
Q)
P
(P U P ) U Q
XUQ
X
T(X) =1
Q
Implication
P)
((P
Q)
P)
Q
Truth Table
P
Q
P Q
P Q
0
0
0
1
0
1
0
1
1
0
0
1
1
1
1
1
P
3(c)
(( P V Q)
(( P
(
P
Q
P) (Q
P ))
V (Q
P ))
(Q
P ))
(Q
P )) U Q
Q
Q
Q
(Q U Q )) U P
XUP
X
T( X) =1
Truth Table
P
Q
P
PVQ
((PVQ)
P ) ((PVQ)
P)
0
0
1
0
0
1
0
1
1
1
1
1
1
0
0
1
0
1
1
1
0
1
0
1
N0 4
X= Universe of Temperature = { 160,165, 170,175,180,185,190,195}
Y = Universe of distillate fraction= {77,80,83,86,89,92,95,98}
Q
A = Temperature of input stream is hot ={
+
+
B = Separation of mixture is good ={ +
+
+
R
~=
(
A
~=
{
B
~=
{
A
B
~× ~)
U(
+
A
~×
Y)
+
+
+
+
A
B
~× ~=
A
~
={
Y ={
}
A
~×
Y=
R
~=
(
A
B
~× ~)
U(
A
~×
Y)
}
+
}
}
=
A'
~ ={
}
A'
R
~
B'= ~
N0.5
X= { LS, MS, HS}
Y ={ SRR, MRR,FRR}
A
~
={
B
~=
{
A
~=
{
}
}
If x is
A
~,
then y is
B
~
Using classical implication
R
~=
(
A
B
~× ~)
A
B
~× ~=
A
~×
Y=
U(
A
~×
Y)
R
~=
(
A
B
~× ~)
U(
A
~×
Y)
R
~=
A'
~
}
= {
Using max-min composition,
B
~
=
A'
~
R
~
B
~ =
B
~=
No.6
A
~ = temperature is high
B
~ = voltage is law
A B
~
~ = If the temperature
R
~
=
A
~
B
A
B
~ =( ~ × ~
A
~
0.1 0.5 0.7 0.9
1
50 75 100 125 150
B
~
1
4.0
0.8 0.5
4.25 4.5
)U(
is high, then voltage will be low
A
~×
Y)
0.2
0
4.75 5.0
A
B
~× ~=
A
~=
{
}
(
A
~×
Y) =
Using Classical implication,
R
~=
(
A
B
~× ~)
U(
A
~×
Y)
R
~=
(b)
Let
A
~ =Temperature
A
~=
{
is very high
}
Using max-product composition,
B
A
~= ~
B
~
B
~
R
~
=
=
No.7 S= { 0,2,3,4,5}
F={ 200,250,300,350,400}
A
~ =medium
B
~=
}
severity = {
moderated sampling= {
(a) Using classical implication
R
~ =If
A then B=(
A
B
~× ~)
U(
A
~×
F)
}
R A
B
~=~× ~=
A
~
={
}
(
R
~
=(
A
~×
A
B
~× ~)
R
~
A'
~=
F) =
U(
A
~×
F)
=
{
Using max-min composition,
B
~=
B
~=
B
~
6
6
=
A'
~
R
~
No .8
Rules1
µ
min
min
0 20 20
3030
40
40
60
50 55 60
50
55
X2 =60, µ x2 = 0
X2 =55, µ x2 = ?
m = - 1/20
µ x2 = mx2+ c
0 = - 1/20 × 60 + c
c =3
µ x2 = mx2+ c
= -1/20 × 55 +3
= 0.25
µ y = 0.25
y1 =?, y2= ?
for y1,
y=0, µ y =0
c =0
m= 1/250
µ y = my1 +c
y1 = (µ y c)/ m
= (0.25-0) × 250
=62.5
For y2 =?
Y= 400, µ y=0
m = -1/150
µ y = my+c
0= -1/150 × 400 + c
C=2.67
µ y = my2+c
X2X2
y2= µy _2-+ c
= (0.25-2.67) × -150
=363
Area 1= ½ × (300.5 + 400 ) ×0.25= 87.56
max
max
50
50
2020
40
40
55
55
60
60
80
X2 =80, µ x2 = 0
X2 =55, µ x2 = ?
m = - 1/30
µ x2 = mx2+ c
0 = - 1/30 × 80 + c
C =2.67
µ x2 = mx2+ c
= -1/30 × 55 +2.67
= 0.84
µ x2=µ y = 0.84
y1 =?, y2= ?
for y1,
y=0, µ y =0
c =0
m= 1/250
µ y = my1 +c
y1 = (µ y c)/ m
= (0.84-0) × 250
=210
For y2 =?
Y = 500, µ y=0
m = -1/250
µ y = my+c
0= -1/250 × 500 + c
C=2
µ y = my2+c
X2
y2= µy _2-+ c
= (0.84-2) × -250
=290
Area 1= ½ × (80 + 500 ) ×0.84= 243.6
By center of sum method
y = (87.56 ×225) +( 243.6 × 250)
(87.56+243.6)
= 243.39
By weight average method
y = (0.25 ×225) +( 0.84 × 250)
(0.84+0.25)
= 244.3
N0.9 Low temperature = {
}
High temperature = {
High pressure
={
low pressure
={
(a)
}
}
i Temperature not very low = low
2
={
}
Temperature not very low= 1- very low temperature
={
}
(ii) Temperature not very high
Very high Temperature = high
2
={
Temperature not very high= 1- very high temperature
={
}
Temperature not very high and
={
Temperature not very high
}
(b)
( i ) Pressure slightly high= high 0.5
= {
(ii)Pressure fairly high= high
={
}
}
(iii) Pressure not very low or fairly low
very low pressure = low 2 ={
}
Pressure not very low= 1- very low pressure
={
Pressure fairly low= low
={
Pressure not very low or fairly low= {
}
}
}
10. Universe of discourse= {0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08,
0.09, 0}
Sensitive =
0
0 .9
0 .8
0 .7
0 .6
0.5
0 .4
0 .3
0.2
+
+
+
+
+
+
+
+
0.01
0.02
0.03
0.04 0.05
0.06 0.07
0.08
0
0 .1
+0
0.09
Insensitive =
0
0.1
0 .2
0 .4
0.5
0 .6
0 .7
0.8
0 .3
+
+
+
+
+
+
+
+
+
0 . 03 0.04 0.05 0.06 0.07 0.08
0
0.01
0.02
0.9
1
+
0.09 0.1
(a) Not very Sensitive
very Sensitive = Sensitive 2=
+
0 0.81 0.64 0.49 0.36 0.25 0.16 0.09
+
+
+
+
+
+
+
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07
0.04
0.01
+
0.08
0.09
Not very Sensitive
=
1 - very Sensitive
1
0.19
0.36
1
0 . 51 0.64 0.75 0.84 0.91 0.96 0.99
+
+
+
+
+
+
+
+
+
+
0
0 . 03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
0.01
0.02
(b) very, very Sensitive or
very, very Sensitive
=
Sensitive
Insensitive
2
0
1
0.01
0.04
0.16 0.25 0.36 0.49 0.64
0.81
0 . 09
+
+
+
+
+
+
+
+
+
+
0 . 03
0
0.01
0.02
0.04 0.05 0.06 0.07 0.08 0.09 0.1
very, very Sensitive or
=
4
0
0.66
0.41 0 . 24
0.13 0.06 0.03 0.01
0
0
0
+
+
+
+
+
+
+
+
+
+
0
0 . 03
0.01
0.02
0.04 0.05 0.06 0.07 0.08 0.09 0.1
very Insensitive
=
very Sensitive
very Insensitive
0
0.66
0.41 0 . 24
0.16 0.25 0.36 0.49 0.64 0.81
1
+
+
+
+
+
+
+
+
+
+
0
0 . 03
0.01
0.02
0.04 0.05 0.06 0.07 0.08 0.09 0.1
(c) Not highly insensitive and not very sensitive
minus very, very ( very, very)0.75
highly
highly insensitive = very very Insensitive
very very Insensitive - Insensitive 4
=
0.75
0
0
0
0 . 01 0.03 0.06 0.13 0.24 0.41 0.66
1
+
+
+
+
+
+
+
+
+
+
0 . 03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
0
0.01
0.02
highly insensitive =
0
0
0
0 . 03 0.07 0.12 0.22 0.24 0.51
+
+
+
+
+
+
+
+
+
0
0 . 03 0.04 0.05 0.06 0.07 0.08
0.01
0.02
0.73
1
+
0.09 0.1
Not highly insensitive = 1 - highly insensitive
1
1
1
0.93 0.88 0.78 0.66 0.49 0.27
0
0 . 97
+
+
+
+
+
+
+
+
+
+
0 . 03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
0
0.01
0.02
=
Not highly insensitive and Not very insensitive
=
1
0
0.19
0.36
0 . 51 0.64 0.75 0.78 0.66 0.49 0.27
+
+
+
+
+
+
+
+
+
+
0
0 . 03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
0.01
0.02
11.
Fast=
0
0.2
0 .4
0 .8
1
0 .6
+
+
+
+
+
1
100
200 300
400 500
Slow=
1
0.8
0 .6
0 .2
0
0 .4
+
+
+
+
+
1
100
200 300
400 500
(a)
Slightly Fast = Fast
=
very Fast
½
0
0.45
0.63 0 . 77
0.89
1
+
+
+
+
+
300
1
100
200
400
500
=
=
Fast
2
0
0.04
0.16
0.64
1
0 . 36
+
+
+
+
+
300
1
100
200
400
500
0
0.45
0.63 0 . 77
0.89
1
+
+
+
+
+
300
1
100
200
400
500
Slightly Fast or very Fast=
(b) Fairly slow = Slow
2/3
1
0.86
0 .7
0.34
0
0 . 54
+
+
+
+
+
1
300
500
100
200
400
=
(c) Slightly Fast and Fairly slow
=
(d) Not Slightly Fast
0.45
0.63 0 . 54
0.34
0
0
+
+
+
+
+
300
1
100
200
400
500
= 1- Slightly Fast
1
0.55
0.37
0
0 . 23 0.11
+
+
+
+
+
1
300
500
100
200
400
0.8
0 .6
0 .2
1
0
0 .4
Not Slightly Fast or Slow =
+
+
+
+
+
300
200
400 500
1 100
=
(e) Not very Fast = 1 very Fast
=
1
0.96
0.84
0.36
0
0 . 64
+
+
+
+
+
300
1
100
200
400
500
Not very Fast or Fairly slow =
1
0.96
0.84
0.36
0
0 . 64
+
+
+
+
+
300
1
100
200
400
500
12. Somewhat straight
=
1
0 .9
0 . 8 0 . 7 0 .6
0 . 5 0 . 4 0 . 3 0 .2 0 .1
+
+
+
+
+
+
+ +
+
3
6
0
1
2
4
5
7
8
9
Curved
=
0
0.1
0 .2
0 . 5 0 . 6 0 . 7 0 . 8 0 .9
0 . 3 0 .4
+
+
+
+
+
+
+
+
+
0
3
6
9
1
2
4
5
7
8
(a) Very curved = curved
=
2
0
0.01
0.04
0.16
0.25 0 . 36
0.49 0.64
0 . 09
+
+
+
+
+
+
+
+
+
0
3
6
1
2
4
5
7
8
0.81
9
(b) Fairly curved = curved
=
0.93
9
2/3
0
0.22
0.34
0.63 0 . 71 0.79 0.86
0 . 45 0.54
+
+
+
+
+
+
+
+
+
3
6
1
2
4
5
7
8
0
(c) very, very somewhat straight =
Somewhat straight
4
1
0.66
0.41 0 . 24
0.13
0.06
0 . 03 0.01 0 0
+
+
+
+
+
+
+
+ +
3
6
0
1
2
4
5
7
8 9
=
( d) Not Fairly curved = 1- Fairly curved
1
0.78
0.66
0.37
0.21 0.14
0 . 55 0.46
0 . 29
+
+
+
+
+
+
+
+
+
3
6
1
2
4
5
7
8
0
=
0.07
9
Not Fairly curved and very, very somewhat straight
1
0.66
0.41 0 . 24
0.13
0.06
0 . 03 0.01 0 0
+
+
+
+
+
+
+
+ +
3
6
0
1
2
4
5
7
8 9
=
0 .1
0 .2
0 .5 0 . 6 0 . 7
0 . 8 0 .9
0
1
0 . 3 0 .4
+
+
+
+
+
+
+
+
+
+
30
60
70
10
20
40
50
80 90 100
0
1
0 .9
0 . 8 0 . 7 0 .6
0.5 0 . 4 0 . 3
0 .2 0 . 1
0
Slow =
+
+
+
+
+
+
+
+
+ +
30
60
70
0
10
20
40
50
80 90 100
13. Fast =
(a) Very fast = (fast) 2
=
0
0.01
0.04
0.16
0.25 0 . 36
0.49 0.64
0 . 09
+
+
+
+
+
+
+
+
+
0
30
60
10
20
40
50
70
80
0.81
1
+
90 100
(b) Very, Very fast = (fast) 4
=
0
0
0
0.06
0 . 01 0.03
0 . 13 0.24 0.41 0.66
+
+
+
+
+
+
+
+
+
+
0
30
60
10
20
40
50
70
80
90
1
100
(c) Highly fast
= minus very, very fast
= ( very, very fast) 0.75
=
0
0
0.12
0.34 0.51 0.73
0
1
0 . 03 0.07
0 . 22
+
+
+
+
+
+
+
+
+
+
30
60
0
10
20
40
50
70
80
90 100
(d) Plus very fast
= ( very fast) 1.25
=
0
0
0.02
0.18 0 . 28 0.41 0.57 0.77
1
0 . 05 0.1
+
+
+
+
+
+
+
+
+
+
0
30
60
10
20
40
50
70
80
90 100
(e) Fairly fast
= (fast)
=
0
0.22
0.34
0.63 0 . 71 0.79 0.86 0.93
1
0 . 45 0.54
+
+
+
+
+
+
+
+
+
+
30
60
0
10
20
40
50
70
80
90 100
(f ) Not very slow and not very fast=?
very slow
= ( slow)2
=
1
0.81
0.64
0.36
0.25 0 . 16
0.09 0.04 0.01
0 . 49
+
+
+
+
+
+
+
+
+
+
0
30
60
10
20
40
50
70
80
90
0
100
Not very slow
= 1- very slow
=
0
0.19
0.36
0.75 0 . 84
0.91 0.96 0.99
1
0 . 51 0.64
+
+
+
+
+
+
+
+
+
+
30
60
10
20
40
50
70
80
90 100
0
Not very fast
= 1- very fast
=
0.99
0.96
0.75 0 . 64
0.51 0.36 0.19
1
0
0 . 91 0.84
+
+
+
+
+
+
+
+
+
+
30
60
0
10
20
40
50
70
80
90 100
(f ) Not very slow and not very fast
=
0.19
0.36
0.75 0 . 64
0.51 0.36 0.19
0
0 . 51 0.64
+
+
+
+
+
+
+
+
+
+
30
60
0
10
20
40
50
70
80
90
0
100
(g) slow or not very slow
=
0 .9
0.8 0 . 7 0.64
0.75 0 . 84
0.91 0.96 0.99
1
1
+
+
+
+
+
+
+
+
+
+
30
60
0
10
20
40
50
70
80
90 100
No 14
I1
~=
{
}
I2
~=
I3
~=
}
{
I1
T( ~
I2
~)
= max { min (
x1 x2
= max { min(
(x1) ,
(x2)) }
I1
~
I2
~
(7) ,
(4)), min(
I1
~
I2
~
(7) ,
(6))}
I1
~
I2
~
=max { min(0.8,0.7),min(0.8,1.0) }
=max { 0.7, 0.8}
= 0.8
I1
T( ~
I3
~)
= max { min (
x1 x3
= max { min(
(x1) ,
(x3)) }
I1
~
I2
~
(3) ,
I1
~
(2)), min(
(7) ,
(2)), min(
I3
~
I1
~
I3
~
(7) ,
I1
~
(4)),} }
I3
~
=max { min(1,0.8),min(0.8,0.8),min(0.8,1) }
=max { 0.8, 0.8,0.8}
=0.8
T(
I2
~
I3
~)
= max { min (
x2 x3
= max { min( (4) ,
I2
~
(4)} }
(x3)) }
(x1) ,
I3
~
I2
~
(2)), min(
(4) ,
I3
~
I2
~
(4)), min(
I3
~
(6) ,
I2
~
I3
~
=max { min(0.7,0.8),min(0.7,1),min(1,0.8) ,min(1,1)}
=max { 0.7, 0.7,0.8,1}
=1
T(
I2
~
I1
~)=
max { min (
(x3)) }
(x1) ,
I2
~
x2 x1
= max { min(
(4) ,
I2
~
I1
~
(3)), min( (6) ,
I1
~
=max { min(0.7,1),min(1,1) }
=max { 0.7, 1}
=1
I2
~
(3)), }
I1
~
(2)), min(
I3
~
(6) ,
I2
~
I3
T( ~
I1
~)
= max { min (
x3 x1
= max { min(
(x3) ,
(x1)) }
I3
~
I1
~
(4) ,
I3
~
(3)), min(
(8) ,
I3
~
I1
~
(3)), min(
I1
~
(7)),} }
(8) ,
I3
~
I1
~
=max { min(1,1),min(0.5,1),min(0.5,0.8) }
=max { 1, 0.5,0.5}
=1
I3
T( ~
I2
~
) = max { min (
x3 x2
= max { min(
(x2)) }
(x3) ,
I3
~
(4) ,
I3
~
I2
~
(4)), min(
(8) ,
I3
~
I2
~
(4)), min(
(8) ,
(6)),} }
I3
~
I2
~
I1
~
=max { min(1,0.7),min(0.5,0.7),min(0.5,1) }
=max { 0.7, 0.5,0.5}
=0.7
I1
T( ~
T(
T(
I2
~
I3
~
I 2 I3
~, ~)
I 3 I1
~, ~)
=0.8
=1
I1 I 2
~ , ~ )=0.7
No 15
f (x,y) =
f (x2| x1) =
f y(x)
max [ fy(x),fx (y) ]
f x1(x2)
=
max [f x1(x2),fx2(x1) ]
0.5
=
max[ 0.5,0.7 ]
f (x3 | x1) =
f x1(x3)
=
max [f x1(x3),fx3(x1) ]
0.3
max[ 0.3,0.5 ]
f (x4| x1) =
f x1(x4)
=
0.2
max [f x1(x4),fx4(x1) ] max[ 0.2,0.3 ]
0.5 = 0.71
0.7
=
=
0.3
0.5
0.2
0.3
= 0.6
= 0.67
f (x1| x2) =
f x2(x1)
=
0.7
max [f x2(x1),fx1(x2) ] max[ 0.7,0.5 ]
f (x3| x2) =
f x2(x3)
=
0.8
max [f x2(x3),fx3(x2) ]
max[ 0.8,0.3 ]
=
0.8
0.8
=1
f (x4| x2) =
f x2(x4)
=
0.9
max [f x2(x4),fx4(x2) ]
max[ 0.9,0.1 ]
=
0.9
0.9
=1
f (x1| x3) =
f x3(x1)
=
0.5
max [f x3(x1),fx1(x3) ]
max[ 0.5,0.3 ]
=
0.5
0.5
=1
f (x2| x3) =
f x3(x2)
=
0.3
max [f x3(x2),fx2(x3) ]
max[ 0.3,0.8 ]
=
0.3
0.8
=1
f (x4| x3) =
f x3(x4)
=
0.7
max [f x3(x4),fx4(x3) ]
max[ 0.7,0.3 ]
=
0.7
0.7
=1
f (x1| x4) =
f x4(x1)
=
0.3
max [f x4(x1),fx1(x4) ]
max[ 0.3,0.2]
=
0.3
0.3
=1
f (x2| x4) =
f x4(x2)
=
0.1
max [f x4(x2),fx2(x4) ]
max[ 0.1,0.9]
=
0.1
0.9
= 0.11
f (x3| x4) =
f x4(x3)
=
0.3
max [f x4(x3),fx3(x4) ]
max[ 0.3,0.7]
=
0.3
0.7
= 0.43
C=
The order from best to worst is x1, x4, x3, x2
=
0.7
0.7
=1
No .16
0.4
~1
MSE
O = 0.7
~2
MSE
O = 0.2
~3
MSE
O = 1
~4
MSE
O =
1
0. 1
+
Conc Gab
0. 4
0.8
+
+
Conc Gab
0.4
1
+
+
Conc Gab
0.5
0 .5
+
+
Conc Gab
+
P={0.5, 0.7, 0.8, 0.7}
b1= 0.5 , b2= 0.7 , b3= 0.8 , b4= 0.7
b1 = 0.5 , b 2 = 0.3 , b 3 = 0.2 , b 4 = 0.3
r
b1
D=
O1
i 1
D(a1) = D (MSE) = b1
=
O1
b2
0.5 0.4
O2
0.3 0.7
b3
O3
0.2 0.2
b4
0.3 1
= 0.5 0.7 0.2 1
= 0.2
D(a2) = D (Conc)
= 0.5 1
0.3 0.8
0.2 0.4
0.3 0.5
= 1 0.8 0.4 0.5
= 0.4
D(a3) = D (Gab)
= 0.5 0.1
0.3 0.4
0.2 1
0.3 0.5
= 0.5 0.4 1 0.5
= 0.4
D* = max { D(a1), D(a2), D(a3)} = max{0.2, 0.4, 0.4} = 0.4
But there is a tie between alternatives a2 and a3
D(a2) = D(a3) = 0.4
D ( a2) = D ( Conc) = 0.5 1
0.3 0.8
= 1 0.8 0.5
0.3 0.5
O4
= 0.5
D ( a3) = D ( Gab) = 0.5 0.1
0.2 1
0.3 0.5
= 0.5 1 0.5
= 0.5
D* = max { D ( a2), D ( a3)} = max{0.5, 0.5} = 0.5
there is still a tie between alternatives a2 and a3.
D ( a2) = D ( Conc) = 0.5 1
0.3 0.8
= 1 0.8
= 0.8
D ( a3) = D ( Gab) = 0.2 1
1
D* = max { D ( a2), D ( a3) } = max{0.8, 1} = 1
Under scenario II , a Gabion wall is the best for standard design
No.17
f x1 (x 1 ) 1
f x1 (x 2 ) 0.5
f x1 (x 3 ) 0.9
f x1 (x 4 ) 0.3
f x 2 (x 1 ) 0.6
f x 2 (x 2 ) 1
f x 2 (x 3 ) 0.8
f x 2 (x 4 ) 0.2
f x 4 (x 1 ) 0.9
f x 3 (x 2 ) 0.7
f x 3 (x 3 ) 1
f x 3 (x 4 ) 0.3
f x 3 (x 1 ) 0.5
f x 4 (x 2 ) 0.8
f x 4 (x 4 ) 0.5
f x 4 (x 4 ) 1
f (x | y) =
f y (x)
max f y (x), f x ( y)
f (x2 | x1) =
f (x3 | x1) =
f (x4 | x1) =
f (x1 | x2) =
f x1 (x 2 )
max f x1 (x 2 ), f x 2 ( x1 )
f x1 (x 3 )
max f x1 (x 3 ), f x 3 ( x1 )
f x1 (x 4 )
max f x1 (x 4 ), f x 4 ( x1 )
f x 2 (x 1 )
max f x 2 (x 1 ), f x1 ( x 2 )
=
0.5
0.5
=
= 0.83
max 0.5,0.6
0 .6
=
0.9
0.9
=
=1
max 0.9,0.5
0.9
=
0.3
0.3
=
=0.33
max 0.3,0.9
0 .9
=
0.6
0.6
=
=1
max 0.6,0.5
0 .6
f (x3 | x2) =
f (x4 | x2) =
f (x1 | x3) =
f (x2 | x3) =
f (x4 | x3) =
f (x1 | x4) =
f (x2 | x4) =
f (x3 | x4) =
C=
f x 2 (x 3 )
max f x 2 (x 3 ), f x 3 ( x 2 )
f x 2 (x 4 )
max f x 2 (x 4 ), f x 4 ( x 2 )
f x 3 (x 1 )
max f x 3 (x 1 ), f x1 ( x3 )
f x 3 (x 2 )
max f x 3 (x 2 ), f x 2 ( x3 )
f x 3 (x 4 )
max f x 3 (x 4 ), f x 4 ( x3 )
f x 4 (x 1 )
max f x 4 (x 1 ), f x1 ( x 4 )
f x 4 (x 2 )
max f x 4 (x 2 ), f x 2 ( x 4 )
f x 4 (x 3 )
max f x 4 (x 3 ), f x 3 ( x 4 )
=
0.8
0.8
=
=1
max 0.8,0.7
0 .8
=
0.2
0.2
=
= 0.25
max 0.2,0.8
0 .8
=
0.5
0.5
=
= 0.56
0.9
max 0.5,0.9
=
0.7
0.7
=
= 0.88
max 0.7,0.9
0 .8
=
0.3
0.3
=
= 0.6
max 0.3,0.5
0 .5
=
0.9
0.9
=
=1
max 0.9,0.3
0.9
=
0.8
0.8
=
=1
max 0.8,0.2
0 .8
=
0.5
0.5
=
=1
max 0.5,0.3
0.5
x1
x2
x3
x4
x1
1
1
0.56
1
0.56
x2
0.83 1
0.88 1
0.83
x3
1
1
1
1
x4
0.33 0.25 0.6
1
0.25
1
The order from best to worst is
No 18
0.9
0..7
0 .3
+
+
~1
PTA PTP BTA
O = 0.4 + 0.6 + 0.8
~2
PTA PTP BPTA
O =
x3
x2
x 1 x4
O = 0.7 + 0.3 + 0.6
~3
PTA PTA BPTA
O = 0.8 + 0.5 + 0.5
~4
PTA PTA BPTA
P={0.6, 0.8, 0.7, 0.5}
b1= 0.6 , b2= 0.8 , b3= 0.7 , b4= 0.5
b1 = 0.4, b 2 = 0.2 , b 3 = 0.3 , b 4 = 0.5
r
b1
D=
O1
i 1
D(a1) = D (PTA) = b1
O1
=
b2
O2
0.4 0.7
b3
0.2 0.4
O3
b4
0.3 0.7
= 0.7 0.4 0.7 0.8
= 0.4
D(a2) = D (PTP) = 0.4 0.9
0.2 0.6
0.3 0.3
0.5 0.5
= 0.9 0.6 0.3 0.5
= 0.3
D(a3) = D (BPTA) = 0.4 0.3
0.2 0.8
0.3 0.6
0.5 0.5
= 0.4 0.8 0.6 0.5
= 0.4
D* = max { D(a1), D(a2), D(a3)} = max{0.4, 0.3, 0.4} = 0.4
But there is a tie between alternatives a1 and a3
D(a1) = D(a3) = 0.4
D ( a1) = D ( PTA) = 0.4 0.7
0.3 0.7
0.5 0.8
= 0.7 0.7 0.8
= 0.7
D ( a3) = D ( BPTA) = 0.2 0.8
0.3 0.6
= 0.8 0.6 0.5
= 0.5
0.5 0.5
O4
0.5 0.8
D* = max { D ( a1), D ( a3)} = max{0.7, 0.5} = 0.7
The Optimum Choice of a remediation Alternative is PTA
No.19
Utility Matrix for Natural Gas
Uji
S1
S2
a1
4
-2
a2
-1
2
conditional probabilities for perfect information
x1
x2
x3
p(xk s1)
0
0
0
p(xk s2)
0.1
0.2
0.5
x4
x5
x6
0
0.2
0.5
0.2
0
0
u11=4, u12=-2 , P(s1)=0.5
u21=-1 u22=2 , P(s1)=0.5
p(si xk) = p(xk si)p(si)
p(xk)
n
p(xk) = p(xk si)p(si)
i=1
P(x1) = p(x1 s1)p(s1) + p(x1 s2)p(s2)
=0+0.1× 0.5
= 0.05
p(s1 x1) = p(x1 s1)p(s1) =0
p(x1)
P(x2) = p(x2 s1)p(s1) + p(x2 s2)p(s2)
=0+0.2× 0.5
= 0.1
p(s1 x2) = p(x2 s1)p(s1) =0
p(x2)
P(x3) = p(x3 s1)p(s1) + p(x3 s2)p(s2)
x7
x8
0.2
0.1
0
0
=0+0.5× 0.5
= 0.25
p(s1 x3) = p(x3 s1)p(s1) =0
p(x3)
P(x4) = p(x4 s1)p(s1) + p(x4 s2)p(s2)
=0+0.2× 0.5
= 0.1
p(s1 x4) = p(x4s1)p(s1) =0
p(x4)
P(x5) = p(x5 s1)p(s1) + p(x5 s2)p(s2)
=0.2×0.5+ 0
= 0.1
p(s1 x5) = p(x5s1)p(s1)
p(x5)
= 0.2 ×0.5=1
0.1
P(x6) = p(x6 s1)p(s1) + p(x4 s2)p(s2)
=0.5× 0.5+0
= 0.25
p(s1 x6) = p(x6s1)p(s1)
p(x6)
= 0.5 ×0.5=1
0.25
P(x7) = p(x7 s1)p(s1) + p(x7 s2)p(s2)
=0.2× 0.5+0
= 0.1
p(s1 x7) = p(x7s1)p(s1)
p(x7)
= 0.2 ×0.5=1
0.1
P(x8) = p(x8s1)p(s1) + p(x8 s2)p(s2)
=0.1× 0.5+0
= 0.05
p(s1 x8) = p(x8s1)p(s1)
p(x8)
= 0.1 ×0.5=1
0.05
P(s1)+ P(s2)=1
P(s2)=1-P(s1)
p(s2 x1) = p(x1s2)p(s2) =1
p(x1)
p(s2 x2) = p(x2s2)p(s2) =1
p(x2)
p(s2 x3) = p(x3s2)p(s2) =1
p(x3)
p(s2 x4) = p(x4s2)p(s2) =1
p(4)
p(s2 x5) = p(x5s2)p(s2) =0
p(x5)
p(s2 x6) = p(x6s2)p(s2) =0
p(x6)
p(s2 x7) = p(x7s2)p(s2) =0
p(x7)
p(s2 x8) = p(x8s2)p(s2) =0
p(x8)
n
E(uj xk )=
u ji p (si xk)
i=1
E(u1 x1 ) = u11p(s1 x1) + u12p(s2 x1)
=4×0+(-2)×1
= -2
E(u2 x1 ) = u21p(s1 x1) + u22p(s2 x1)
=0+(2)×1
=2
E(u xk )=maxj E(uj xk )
E(u x1)= max(-2,2)=2
a2
E(u1 x2) = u11p(s1 x2) + u12p(s2 x2)
=4×0+(-2)×1
= -2
E(u2 x2) = u21p(s1 x2) + u22p(s2 x2)
=-1×0+(2)×1
=2
E(u x2)= max(-2,2)=2
a2
E(u1 x3) = u11p(s1 x3) + u12p(s2 x3)
=4×0+(-2)×1
= -2
E(u2 x3) = u21p(s1 x3) + u22p(s2 x3)
=-1×0+(2)×1
=2
E(u x3)= max(-2,2)=2
a2
E(u1 x4) = u11p(s1 x4) + u12p(s2 x4)
=4×0+(-2)×1
= -2
E(u2 x4) = u21p(s1 x4) + u22p(s2 x4)
=-1×0+(2)×1
=2
E(u x4)= max(-2,2)=2
a2
E(u1 x5) = u11p(s1 x5) + u12p(s2 x5)
=4×1+(-2)×0
=4
E(u2 x5) = u21p(s1 x5) + u22p(s2 x5)
=-1×1+(2)×0
= -1
E(u x5)= max(4,-1)=4
a1
E(u1 x6) = u11p(s1 x6) + u12p(s2 x6)
=4×1+(-2)×0
=4
E(u2 x6) = u21p(s1 x6) + u22p(s2 x6)
=-1×1+(-2)×0
= -1
E(u x6)= max(4,-1)=4
a1
E(u1 x7) = u11p(s1 x7) + u12p(s2 x7)
=4×1+(-2)×0
=4
E(u2 x7) = u21p(s1 x7) + u22p(s2 x7)
=-1×1+(-2)×0
= -1
E(u x7)= max(4,-1)=4
a1
E(u1 x8) = u11p(s1 x8) + u12p(s2 x8)
=4×1+(-2)×0
=4
E(u2 x8) = u21p(s1 x8) + u22p(s2 x8)
=-1×1+(-2)×0
= -1
E(u x8)= max(4,-1)=4
a1
conditional probabilities for perfect information
p( s1 xk)
x1
x2
x3
x4
x5
x6
x7
x8
0
0
0
0
1
1
1
1
1
1
0
0
0
0
0.1
0.1
0.25
0.1
0.05
p(s2 xk)
1
1
p(xk)
0.05
0.01 0.25
E(u xk)
2
2
2
2
4
(aj xk)
a2
a2
a2
a2
a1
4
n
E(uj)= u ji
p (si)
i=1
E(a1)= u11p(s1 ) + u12p(s2 )
=(4×0.5)+(-2×0.5)
= 2-1=1
E(a2)= u21p(s1 ) + u22p(s2 )
=(-1×0.5)+( 2×0.5)
= -0.5+1=0.5
E(u )=1
We choose alternative( a1), drill for natural gas
a1
4
4
a1
a1