0% found this document useful (0 votes)
193 views

Free Sample UGC NET Computer Science & Application

This document provides an overview of propositional logic and discrete structures and optimization unit 1 from Diwakar Education Hub. It defines key concepts such as propositions, logical connectives like negation, conjunction, disjunction, conditional, and biconditional. It provides truth tables for each connective and examples. The document also discusses converse, contrapositive, and inverse relationships between conditional statements, bit operations, tautologies, contradictions, and logical equivalences.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
193 views

Free Sample UGC NET Computer Science & Application

This document provides an overview of propositional logic and discrete structures and optimization unit 1 from Diwakar Education Hub. It defines key concepts such as propositions, logical connectives like negation, conjunction, disjunction, conditional, and biconditional. It provides truth tables for each connective and examples. The document also discusses converse, contrapositive, and inverse relationships between conditional statements, bit operations, tautologies, contradictions, and logical equivalences.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

DIWAKAR EDUCATION HUB

DISCRETE STRUCTURES AND


OPTIMIZATION UNIT - 1
As per updated syllabus
DIWAKAR EDUCATION HUB

THE LEARN WITH EXPERTIES


DISCRETE STRUCTURES AND OPTIMIZATION UNIT - 1
Propositional Logic
The rules of logic give precise meaning to mathematical statements. These rules are
used to distinguish between valid and invalid mathematical arguments.
Propositions
A proposition is a declarative sentence that is either true or false, but not both.
 Propositional logic the area of logic that deals with propositions.
 Propositional variables that represent propositions: p, q, r, s.
 Truth values T, F
 Proposition is a declarative statement that is either true or false but not both.
 Connectives are used to combine the propositions.

About Connectives in Propositional logic-


Logical Connectives-
Connectives are the operators that are used to combine one or more
propositions.
In propositional logic, there are 5 basic connectives-

Name of Connective Connective Word Symbol


Negation Not ⌉ or ∼ or ‘ or –
Conjunction And ∧
Disjunction Or ∨
Conditional If-then →
Bi-conditional If and only if ↔

DIWAKAR EDUCATION HUB Page 2


DISCRETE STRUCTURES AND OPTIMIZATION UNIT - 1
Negation-
If p is a proposition, then negation of p is a proposition which is-
 True when p is false
 False when p is true.
Truth Table-

p ∼p
F T
T F
Example-
If p : It is raining outside.
Then, Negation of p is-
∼p : It is not raining outside.
Conjunction-
If p and q are two propositions, then conjunction of p and q is a proposition which is-
 True when both p and q are true
 False when both p and q are false
Truth Table-
p q p∧q
F F F
F T F
T F F
T T T
Example-
If p and q are two propositions where-
 p:2+4=6
 q : It is raining outside.
Then, conjunction of p and q is-
p ∧ q : 2 + 4 = 6 and it is raining outside
3. Disjunction-
If p and q are two propositions, then disjunction of p and q is a proposition which is-
 True when either one of p or q or both are true
 False when both p and q are false
Truth Table-

p q p∨q
F F F

DIWAKAR EDUCATION HUB Page 3


DISCRETE STRUCTURES AND OPTIMIZATION UNIT - 1
F T T
T F T
T T T
Example-
If p and q are two propositions where-
 p:2+4=6
 q : It is raining outside
Then, disjunction of p and q is-
p ∨ q : 2 + 4 = 6 or it is raining outside
Conditional-
If p and q are two propositions, then-
 Proposition of the type “If p then q” is called a conditional or implication proposition.
 It is true when both p and q are true or when p is false.
 It is false when p is true and q is false.
Truth Table-
p q p→q
F F T
F T T
T F F
T T T

Examples-
If a = b and b = c then a = c.
 If I will go to Australia, then I will earn more money.
Biconditional-
If p and q are two propositions, then-
 Proposition of the type “p if and only if q” is called a biconditional or bi-implication
proposition.
 It is true when either both p and q are true or both p and q are false.
 It is false in all other cases.
Truth Table-
p q p↔q
F F T
F T F
T F F
T T T
Examples-

DIWAKAR EDUCATION HUB Page 4


DISCRETE STRUCTURES AND OPTIMIZATION UNIT - 1
 He goes to play a match if and only if it does not rain.
 Birds fly if and only if sky is clear.
The common binary connectives are:
p∧q Conjunction p and q
p∨q Disjunction p or q
p→q Implication if p then q
p↔q Bi-conditional p if and only if q
p⊕q Exclusive or p x-or q
p↓q not or p nor q
p | q or p ↑ q not and p n-and q
In the conditional p → q, p is the antecedent and q is the consequent. The conditional p → q is
often read informally as “p implies q”.
Converse, Contra-positive and Inverse
 The proposition q → p is called the converse of p →q. The contra-positive of p → q is
the proposition ¬q → ¬p. The proposition ¬p → ¬q is called the inverse of p → q.
 We will see that of these three conditional statements formed from p → q, only the
contra-positive always has the same truth value as p → q.
EXAMPLE: What are the contra-positive, the converse, and the inverse of the conditional-
statement? “The home team wins whenever it is raining?”
Solution:
“If it is raining, then the home team wins.”
The contra-positive of this conditional statement is
“If the home team does not win, then it is not raining.”
The converse is - “If the home team wins, then it is raining.”
The inverse is - “If it is not raining, then the home team does not win.”
Bi-conditionals
DEFINITION 4
Let p and q be propositions. The bi-conditional statement p ↔ q is the proposition “p if and
only if q.” The bi-conditional statement p ↔ q is true when p and q have the same truth
values, and is false otherwise. Bi-conditional statements are also called bi-implications.
The Truth Table for the Bi-conditional p ↔ q
Truth Table for the Bi-conditional p ↔ q
p q p↔q
T T T
T F F
F T F
F F T
The statement p ↔ q is true when both the conditional statements are p → q and q → p are
true and is false otherwise.

DIWAKAR EDUCATION HUB Page 5


DISCRETE STRUCTURES AND OPTIMIZATION UNIT - 1
Example: Let p be the statement “You can take the flight,” and let q be the statement “You
buy a ticket.” Then p ↔ q is the statement
Answer “You can take the flight if and only if you buy a ticket.”
Precedence of Logical Operator
Operator precedence is an ordering of logical operators designed to allow the dropping of
parenthesis in logical expression.
Precedence of Logical Operators
Operator Precedence
¬ 1
∧ 2
∨ 3
→ 4
↔ 5

Logic and Bit Operations


 A bit is a symbol with two possible values, 0 (zero) and 1 (one).
 A bit can be used to represent a truth value, because there are two truth values, true
and false.
 A variable is called a Boolean variable if its value is either true or false.
Truth Bit Bit Operators OR, AND, and XOR
Value x y x∨y x∧y x⊕y
T 1 0 0 0 0 0
F 0 0 1 1 0 1
1 0 1 0 1
DEFINITION 1 1 1 1 0
A bit string is a sequence of zero or more bits.
The length of this string is the number of bits in the string.
EXAMPLE Find the bitwise OR, bitwise AND, and bitwise XOR of the bit strings 01 1011 0110
and 11 0001 1101.
Solution: The bitwise OR, bitwise AND, and bitwise XOR are:
01 1011 0110
11 0001 1101
11 1011 1111 Bitwise OR
01 0001 0100 Bitwise AND
10 1010 1011 Bitwise XOR
Propositional Equivalences
Tautologies and contradictions
A compound proposition that is always true, regardless of the truth values of the individual
propositions involved, is called a tautology.

DIWAKAR EDUCATION HUB Page 6


DISCRETE STRUCTURES AND OPTIMIZATION UNIT - 1
Example: 𝑝 ∨ ¬𝑝 is a tautology.
A compound proposition that is always false, regardless of the truth values of the individual
propositions involved, is called a contradiction.
Example: 𝑝 ∧ ¬𝑝 is a contradiction.
A compound statement that is neither a tautology nor a contradiction is called a contingency.
Logical Equivalences
 Compound propositions that have the same truth values in all possible cases are called
logically equivalent.
 The compound propositions p and q are called logically equivalent if p ↔ q is a
tautology. The notation p ≡ q denotes that p and q are logically equivalent.

Examples of Tautology & De Morgan’s Laws.


Contradiction.
p ¬p p ∨ ¬p p ∧ ¬p ¬(p ∧ q) ≡ ¬p ∨ ¬q
Logical T F T F
equivalence F T T F ¬(p ∨ q) ≡ ¬p ∧ ¬q
 The two
algebraic expressions equal if they have the same value for each possible value of the
input variables.
 For example, for all real numbers 𝑥, the left side and the right side have the same value.
 The two compound statements 𝑥 2 −𝑝1and
= (𝑥𝑞+“equal” if they always share the same truth
1) (𝑥 − 1)
value. 𝑝 ≡ 𝑞 means that 𝑝 ↔ 𝑞 is a tautology.
 In these equivalences, T denotes the compound proposition that is always true and F
denotes the compound proposition that is always false.
Logical Equivalences
Equivalence Name
p∧T≡p Identity laws
p∨F≡p
p∨T≡T Domination laws
p∧F≡F
p∨p≡p Idempotent laws
p∧p≡p
¬(¬p) ≡ p Double negation law
p∨q≡q∨p Commutative laws
p∧q≡q∧p
(p ∨ q) ∨ r ≡ p ∨ (q ∨ r) Associative laws
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)
p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p Distributive laws
∨ r)

DIWAKAR EDUCATION HUB Page 7


DISCRETE STRUCTURES AND OPTIMIZATION UNIT - 1
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p
∧ r)
¬(p ∧ q) ≡ ¬p ∨ ¬q De Morgan’s laws
¬(p ∨ q) ≡ ¬p ∧ ¬q
p ∨ (p ∧ q) ≡ p Absorption laws
p ∧ (p ∨ q) ≡ p
p ∨ ¬p ≡ T Negation laws
p ∧ ¬p ≡ F

Logical Equivalences involving Logical Equivalences Involving


Conditional Statements. Bi-conditional Statements.
p → q ≡ ¬p ∨ q p ↔ q ≡ (p → q) ∧ (q → p)
p → q ≡ ¬q → ¬p p ↔ q ≡ ¬p ↔ ¬q
p ∨ q ≡ ¬p → q p ↔ q ≡ (p ∧ q) ∨ (¬p ∧ ¬q)
p ∧ q ≡ ¬(p → ¬q) ¬(p ↔ q) ≡ p ↔ ¬q
¬(p → q) ≡ p ∧ ¬q
(p → q) ∧ (p → r) ≡ p → (q ∧ r) Using De Morgan’s Laws
(p → r) ∧ (q → r) ≡ (p ∨ q) → r The two logical equivalences known as De Morgan’s laws
(p → q) ∨ (p → r) ≡ p → (q ∨ r) are particularly important. In particular, the equivalence ¬
(p → r) ∨ (q → r) ≡ (p ∧ q) →r (p ∨ q) ≡ ¬p ∧ ¬q tells us that the negation of a disjunction
is formed by taking the conjunction of the negations of the
component propositions.
Example Show that ¬ (p ∨ (¬p ∧ q)) and ¬p ∧ ¬q are logically equivalent by developing a series
of logical equivalences.
Sol ¬ (p ∨ (¬p ∧ q)) ≡ ¬p ∧ ¬ (¬p ∧ q) 2nd De Morgan law
≡ ¬p ∧ [¬ (¬p) ∨ ¬q] 1st De Morgan law
≡ ¬p ∧ (p ∨ ¬q) double negation law
≡ (¬p ∧ p) ∨ (¬p ∧ ¬q) 2nd distributive law
≡ F ∨ (¬p ∧ ¬q) because ¬p ∧ p ≡ F
≡ (¬p ∧ ¬q) ∨ F commutative law for disjunction
≡ ¬p ∧ ¬q identity law for F
Normal Form
 Suppose, A (P1, P2, ... , P n) is a statements formula where P1, P2, ..., P6 are the atomic
variables if we consider all possible assignments of the truth value to P1, P2, ..., P n and
obtain the resulting truth values of the formula A then we get the truth table for A, such
a truth table contains 2^6 rows.
 The formula may have the truth value T for all possible assignments of the truth values
to the variables P1, P2... P n. In this case, A is called identically true or tautology.
 If A has the truth value T for at least one combination of truth values assigned to P1, P2...
P n then A is called Satisfiable.
DIWAKAR EDUCATION HUB Page 8
DIWAKAR EDUCATION HUB

DISCRETE STRUCTURES AND


OPTIMIZATION UNIT – 1 MCQS
As per updated syllabus
DIWAKAR EDUCATION HUB

THE LEARN WITH EXPERTIES


DISCRETE STRUCTURES AND OPTIMIZATION UNIT – 1 MCQS
1. Which of the following statement is a b) If I am in Bangalore then I love cricket
proposition? c) I am not in Bangalore
a) Get me a glass of milkshake. d) I love cricket
b) God bless you! Answer: a
c) What is the time now? Explanation: Q is hypothesis and P is
d) The only odd prime number is 2 conclusion. So the compound statement
Answer: d will be if hypothesis then conclusion.
Explanation: Only this statement has got 6. Which of the following bits is the
the truth value which is false. negation of the bits “010110”?
2. The truth value of ‘4+3=7 or 5 is not 111001
prime’. 001001
a) False 101001
b) True 111111
Answer: b Answer: c
Explanation: Compound statement with ‘or’ Explanation: Flip each of the bits to get the
is true when either of the statement is true. negation of the required string.
Here the first part of the statement is true, 7. Which of the following option is suitable,
hence the whole is true. if A is “10110110”, B is”11100000” and C
3. Which of the following option is true? is”10100000”?
a) If the Sun is a planet, elephants will a) C=A or B
fly b) C=~A
b) 3 +2 = 8 if 5-2 = 7 c) C=~B
c) 1 > 3 and 3 is a positive integer d) C=A and B
d) -2 > 3 or 3 is a negative integer Answer: d
Answer: a Explanation: Output of and is 1 when both
Explanation: Hypothesis is false, thus the other inputs are one.
whole statement is true. 8. How many bits string of length 4 are
4. What is the value of x after this possible such that they contain 2 ones and
statement, assuming the initial value of x 2 zeroes?
are 5? a) 4
‘If x equals to one then x=x+2 else x=0’. b) 2
a) 1 c) 5
b) 3 d) 6
c) 0 Answer: d
d) 2 Explanation: The strings are {0011, 0110,
Answer: c 1001, 1100, 1010 and 0101}.
Explanation: If condition is false so value 9. If a bit string contains {0, 1} only, having
decided according to else condition. length 5 has no more than 2 ones in it. Then
5. Let P: I am in Bangalore; Q: I love cricket; how many such bit strings are possible?
then q -> p(q implies p) is? a) 14
a) If I love cricket then I am in Bangalore b) 12

DIWAKAR EDUCATION HUB Page 2


DISCRETE STRUCTURES AND OPTIMIZATION UNIT – 1 MCQS
c) 15 Explanation: For implications to be false
d) 16 hypothesis should be true and conclusion
Answer: d should be false
Explanation: The total strings are 1(having 14. The statement which is logically
no one in it) +5(having 1 one in it) +10 equivalent to A∧ (and) B is?
(having 2 ones in it) = 16. a) A->B
10. If A is “001100” and B is “010101” then b) ~A ∧ ~ B
what is the value of A (Ex-or) B? c) A ∧ ~B
a) 000000 d) ~(A->~B)
b) 111111 Answer: d
c) 001101 Explanation: The truth table of both
d) 011001 statements is same.
Answer: d 15. Let P, Q, R be true, false true,
Explanation: In Ex-or if both the inputs are respectively, which of the following is true?
same then output is 0 otherwise 1. a) P∧Q∧R
11. Let P and Q be statements, then P<->Q b) P∧~Q∧~R
is logically equivalent to __________ c) Q->(P∧R)
a) P<->~Q d) P->(Q∧R)
b) ~P<->Q Answer: c
c) ~P<->~Q Explanation: Hypothesis is false, hence
d) None of the mentioned statement is true.
Answer: c 16. If there are ‘M’ switches in series
Explanation: Both of them have same truth numbered from 1, 2, …, M. For circuit to be
table, hence they are equal. complete and bulb to glow which of the
12. What is the negation of the statement following is necessary?
A-> (B v (or) C)? a) 1∧ 2∧ 3 ∧ … ∧M should be on.
a) A ∧ ~B ∧ ~C b) 1∧ 2∧ 3 ∧ … ∧M should be off.
b) A->B->C c) 1 v 2 v 3 v … v M should be on.
c) ~A ∧ B v C d) None of the mentioned.
d) None of the mentioned Answer: a
Answer: a Explanation: All should be on in-order to
Explanation: A->P is logically equivalent to ~ complete the circuit.
A v P. 17. Which of the following statements is the
13. The compound statement A-> (A->B) is negation of the statements “4 is odd or -9 is
false, then the truth values of A, B are positive”?
respectively _________ a) 4 is even or -9 is not negative.
a) T, T b) 4 is odd or -9 is not negative.
b) F, T c) 4 is even and -9 is negative.
c) T, F d) 4 is odd and -9 is not negative.
d) F, F Answer: c
Answer: c Explanation: Using De Morgan’s Law ~ (A V
B) ↔ ~A ∧ ~B

DIWAKAR EDUCATION HUB Page 3


DISCRETE STRUCTURES AND OPTIMIZATION UNIT – 1 MCQS
18. Which of the following represents: ~A a) Contingency
(negation of A) if A stands for “I like b) Equivalence
badminton but hate math’s”? c) Condition
a) I hate badminton and math’s d) Inference
b) I do not like badminton or math’s Answer: a
c) I dislike badminton but love math’s Explanation: Definition of contingency.
d) I hate badminton or like math’s 24. ¬ (A ∨ q) ∧ (A ∧ q) is a ___________
Answer: d a) Tautology
Explanation: De Morgan’s Law ~ (A ∧ B) ↔ b) Contradiction
~A V ~B. c) Contingency
19. The compound statement A v ~(A ∧ B). d) None of the mentioned
a) True Answer: b
b) False Explanation: ≡ (¬A ∧ ¬q) ∧ (A ∧ q)
Answer: a ≡ (¬A ∧ A) ∧ (¬q ∧ q)
Explanation: Applying De-Morgan’s law we ≡ F ∧ F ≡ F.
get A v ~ A Ξ Tautology. 25. The contra positive of p → q is the
20. Which of the following is De-Morgan’s proposition of ____________
law? a) ¬p → ¬q
a) P ∧ (Q v R) Ξ (P ∧ Q) v (P ∧ R) b) ¬q → ¬p
b) ~(P ∧ R) Ξ ~P v ~R, ~(P v R) Ξ ~P ∧ ~R c) q → p
c) P v ~P Ξ True, P ∧ ~P Ξ False d) ¬q → p
d) None of the mentioned Answer: b
Answer: b Explanation: Definition of contra positive.
Explanation: Definition of De–Morgan’s 26. The inverse of p → q is the proposition
Law. of ____________
21. A compound proposition that is always a) ¬p → ¬q
___________ is called a tautology. b) ¬q → ¬p
a) True c) q → p
b) False d) ¬q → p
Answer: a Answer: a
Explanation: Tautology is always true. Explanation: Definition of inverse.
22. If A is any statement, then which of the 27. The converse of p → q is the proposition
following is a tautology? of _______________
a) A ∧ F a) ¬p → ¬q
b) A ∨ F b) ¬q → ¬p
c) A ∨ ¬A c) q → p
d) A ∧ T d) ¬q → p
Answer: c Answer: c
Explanation: A ∨ ¬A is always true. Explanation: Definition of converse.
23. A compound proposition that is neither 28. What is the contra positive of the
a tautology nor a contradiction is called a conditional statement? “The home team
___________ misses whenever it is drizzling?”
DIWAKAR EDUCATION HUB Page 4
DIWAKAR EDUCATION HUB

COMPUTER SYSTEM
ARCHITECTURE UNIT - 2
As per updated syllabus
DIWAKAR EDUCATION HUB

THE LEARN WITH EXPERTIES


COMPUTER SYSTEM ARCHITECTURE UNIT - 2
Digital Logic Circuits
The digital logic circuits are basic building blocks of the digital systems (digital computers).
These digital logic circuits can be classified into two categories such as combinational logic
circuits and sequential logic circuits. Before studying about the difference between
combinational and sequential logic circuits, primarily, we must know what is combinational
logic circuit and what are sequential logic circuits.
Digital Computers
A Digital computer can be considered as a digital system that performs various computational
tasks.
The first electronic digital computer was developed in the late 1940s and was used primarily
for numerical computations.
By convention, the digital computers use the binary number system, which has two digits: 0
and 1. A binary digit is called a bit.
A computer system is subdivided into two functional entities: Hardware and Software.
The hardware consists of all the electronic components and electromechanical devices that
comprise the physical entity of the device.
The software of the computer consists of the instructions and data that the computer
manipulates to perform various data-processing tasks.

o The Central Processing Unit (CPU) contains an arithmetic and logic unit for manipulating
data, a number of registers for storing data, and a control circuit for fetching and
executing instructions.
o The memory unit of a digital computer contains storage for instructions and data.
o The Random Access Memory (RAM) for real-time processing of the data.
o The Input-Output devices for generating inputs from the user and displaying the final
results to the user.

DIWAKAR EDUCATION HUB Page 2


COMPUTER SYSTEM ARCHITECTURE UNIT - 2
o The Input-Output devices connected to the computer include the keyboard, mouse,
terminals, magnetic disk drives, and other communication devices.
Logic Gates
o The logic gates are the main structural part of a digital system.
o Logic Gates are a block of hardware that produces signals of binary 1 or 0 when input
logic requirements are satisfied.
o Each gate has a distinct graphic symbol, and its operation can be described by means of
algebraic expressions.
o The seven basic logic gates includes: AND, OR, XOR, NOT, NAND, NOR, and XNOR.
o The relationship between the input-output binary variables for each gate can be
represented in tabular form by a truth table.
o Each gate has one or two binary input variables designated by A and B and one binary
output variable designated by x.
AND GATE:
The AND gate is an electronic circuit which gives a high output only if all its inputs are high.
The AND operation is represented by a dot (.) sign.

OR GATE:
The OR gate is an electronic circuit which gives a high output if one or more of its inputs are
high. The operation performed by an OR gate is represented by a plus (+) sign.

DIWAKAR EDUCATION HUB Page 3


COMPUTER SYSTEM ARCHITECTURE UNIT - 2
NOT GATE:
The NOT gate is an electronic circuit which produces an inverted version of the input at its
output. It is also known as an Inverter.
NAND GATE:
The NOT-AND (NAND) gate which is equal to an AND gate followed by a NOT gate. The NAND
gate gives a high output if any of the inputs are low. The NAND gate is represented by a AND
gate with a small circle on the output. The small circle represents inversion.

NOR GATE:
The NOT-OR (NOR) gate which is equal to an OR gate followed by a NOT gate. The NOR gate
gives a low output if any of the inputs are high. The NOR gate is represented by an OR gate
with a small circle on the output. The small circle represents inversion.

Exclusive-OR/ XOR GATE:


The 'Exclusive-OR' gate is a circuit which will give a high output if one of its inputs is high but
not both of them. The XOR operation is represented by an encircled plus sign.

DIWAKAR EDUCATION HUB Page 4


COMPUTER SYSTEM ARCHITECTURE UNIT - 2

EXCLUSIVE-NOR/Equivalence GATE:
The 'Exclusive-NOR' gate is a circuit that does the inverse operation to the XOR gate. It will give
a low output if one of its inputs is high but not both of them. The small circle represents
inversion.

Boolean Algebra
Boolean algebra can be considered as an algebra that deals with binary variables and logic
operations. Boolean algebraic variables are designated by letters such as A, B, x, and y. The
basic operations performed are AND, OR, and complement.
The Boolean algebraic functions are mostly expressed with binary variables, logic operation
symbols, parentheses, and equal sign. For a given value of variables, the Boolean function can
be either 1 or 0. For instance, consider the Boolean function:
F = x + y'z
The logic diagram for the Boolean function F = x + y'z can be represented as:

DIWAKAR EDUCATION HUB Page 5


COMPUTER SYSTEM ARCHITECTURE UNIT - 2

o The Boolean function F = x + y'z is transformed from an algebraic expression into a logic
diagram composed of AND, OR, and inverter gates.
o Inverter at input 'y' generates its complement y'.
o There is an AND gate for the term y'z, and an OR gate is used to combine the two terms
(x and y'z).
o The variables of the function are taken to be the inputs of the circuit, and the variable
symbol of the function is taken as the output of the circuit.
Note: A truth table can represent the relationship between a function and its binary variables.
To represent a function in a truth table, we need a list of the 2^n combinations of n binary
variables.
The truth table for the Boolean function F = x + y'z can be represented as:

Laws of Boolean algebra


The basic Laws of Boolean Algebra can be stated as follows:

DIWAKAR EDUCATION HUB Page 6


COMPUTER SYSTEM ARCHITECTURE UNIT - 2
o Commutative Law states that the interchanging of the order of operands in a Boolean
equation does not change its result. For example:
1. OR operator → A + B = B + A
2. AND operator → A * B = B * A
o Associative Law of multiplication states that the AND operation are done on two or
more than two variables. For example:
A * (B * C) = (A * B) * C
o Distributive Law states that the multiplication of two variables and adding the result
with a variable will result in the same value as multiplication of addition of the variable
with individual variables. For example:
A + BC = (A + B) (A + C).
o Annulment law:
A.0 = 0
A+1=1
o Identity law:
A.1 = A
A+0=A
o Idempotent law:
A+A=A
A.A = A
o Complement law:
A + A' = 1
A.A'= 0
o Double negation law:
((A)')' = A
o Absorption law:
A.(A+B) = A
A + AB = A
De Morgan's Law is also known as De Morgan's theorem, works depending on the concept of
Duality. Duality states that interchanging the operators and variables in a function, such as
replacing 0 with 1 and 1 with 0, AND operator with OR operator and OR operator with AND
operator.
De Morgan stated 2 theorems, which will help us in solving the algebraic problems in digital
electronics. The De Morgan's statements are:
1. "The negation of a conjunction is the disjunction of the negations", which means that
the complement of the product of 2 variables is equal to the sum of the compliments of
individual variables. For example, (A.B)' = A' + B'.
2. "The negation of disjunction is the conjunction of the negations", which means that
compliment of the sum of two variables is equal to the product of the complement of
each variable. For example, (A + B)' = A'B'.
Map Simplification

DIWAKAR EDUCATION HUB Page 7


COMPUTER SYSTEM ARCHITECTURE UNIT - 2
The Map method involves a simple, straightforward procedure for simplifying Boolean
expressions.
Map simplification may be regarded as a pictorial arrangement of the truth table which allows
an easy interpretation for choosing the minimum number of terms needed to express the
function algebraically. The map method is also known as Karnaugh map or K-map.
Each combination of the variables in a truth table is called a mid-term.
Note: When expressed in a truth table a function of n variables will have 2^n min-terms,
equivalent to the 2^n binary numbers obtained from n bits.
There are four min-terms in a two variable map. Therefore, the map consists of four squares,
one for each min-term. The 0's and 1's marked for each row, and each column designates the
values of variable x and y, respectively.
Two-variable map:

Representation of functions in the two-variable map:

Three variable map


There are eight min-terms in a three-variable map. Therefore, the map consists of eight
squares.
Three variable map:

DIWAKAR EDUCATION HUB Page 8


DIWAKAR EDUCATION HUB

COMPUTER SYSTEM
ARCHITECTURE UNIT – 2 MCQs
As per updated syllabus
DIWAKAR EDUCATION HUB

THE LEARN WITH EXPERTIES

DIWAKAR EDUCATION HUB Page 1


COMPUTER SYSTEM ARCHITECTURE UNIT – 2 MCQs
1. Any signed negative binary number is b) (532.864)10
recognised by its ________ c) (340.67)10
a) MSB d) (531.668)10
b) LSB Answer: a
c) Byte Explanation: Octal to Decimal conversion is
d) Nibble obtained by multiplying 8 to the power of
Answer: a base index along with the value at that
Explanation: Any negative number is index position.
recognized by its MSB (Most Significant Bit). (532.2)8 = 5 * 82 + 3 * 81 + 2 * 80 + 2 * 8-1 =
If it’s 1, then ít’s negative, else if it’s 0, then (346.25)10
positive. 5. Which of the following is not a data type?
2. The parameter through which 16 distinct a) Symbolic Data
values can be represented is known as b) Alphanumeric Data
________ c) Numeric Data
a) Bit d) Alphabetic Data
b) Byte Answer: a
c) Word Explanation: Data types are of three basic
d) Nibble types: Numeric, Alphabetic and
Answer: c Alphanumeric. Numeric Data consists of
Explanation: It can be represented up to 16 only numbers.
different values with the help of a Word. Alphabetic Data consists of only letters and
Nibble is a combination of four bits and a blank character and alphanumeric data
Byte is a combination of 8 bits. It is “word” consists of symbols.
which is said to be a collection of 16-bits on 6. ____________ is the raw material used
most of the systems. as input and __________ is the processed
3. If the decimal number is a fraction then data obtained as output of data processing.
its binary equivalent is obtained by a) Data, Instructions
________ the number continuously by 2. b) Instructions, Program
a) Dividing c) Data, Program
b) Multiplying d) Program, Code
c) Adding Answer: a
d) Subtracting Explanation: Data can be assumed as a raw
Answer: b material which, in turns after processing
Explanation: On multiplying the decimal gives the desired output in the form of
number continuously by 2, the binary instructions. Further, a set of ordered and
equivalent is obtained by the collection of meaningful instructions is known as a
the integer part. However, if it’s an integer, program.
then it’s binary equivalent is determined by 7. Which of the following is not a
dividing the number by 2 and collecting the characteristic of a computer?
remainders. a) Diligence
4. The representation of octal number b) I.Q.
(532.2)8 in decimal is ________ c) Accuracy
a) (346.25)10 d) Versatility
DIWAKAR EDUCATION HUB Page 2
COMPUTER SYSTEM ARCHITECTURE UNIT – 2 MCQs
Answer: b b) Controller
Explanation: The Computer system has no c) Registers
I.Q. of its own. It does only what it is d) Cache
programmed to do. It cannot take decisions Answer: a
of its own. Explanation: A processor is a part of the
A computer is diligent because it can work computer which does all the data
continuously for hours without getting any manipulation and decision making. A
errors or without getting grumbled. processor comprises of:
The accuracy of a computer is consistently A data path which contains the hardware
high and its level of accuracy depends on its necessary to perform all the operations. A
design. A computer can perform any task if, controller tells the data path what needs to
it can be broken down into a series of be done.
logical steps. Therefore, a computer is The registers act as intermediate storage
versatile. for the data.
8. Fill in the blank in the diagram. 10. What does MAR stand for?
a) Main Address Register
b) Memory Access Register
c) Main Accessible Register
d) Memory Address Register
Answer: d
Explanation: MAR is a type of register
which is responsible for the fetch operation.
MAR is connected to the address bus and it
specifies the address for the read and write
operations.
11. If the control signals are generated by
combinational logic, then they are
a) Input Unit
generated by a type of _______________
b) Memory Unit
controlled unit.
c) Control Unit
a) Micro programmed
d) I/O Unit
b) Software
Answer: c c) Logic
Explanation: The control unit manages and d) Hardwired
coordinates the operations of a computer
Answer: d
system. The ALU is responsible for
Explanation: The main task of a control unit
performing all the arithmetic and bitwise
is to generate control signals. There are two
operations . Therefore, both these units
main types of control units:
combine to form the brain of the computer
A hardwired control unit generates control
,which is the central processing unit.
signals by using combinational logic circuits
9. The part of a processor which contains and the Micro programmed control unit
hardware necessary to perform all the generates control signals by using some
operations required by a computer: softwares.
a) Data path

DIWAKAR EDUCATION HUB Page 3


COMPUTER SYSTEM ARCHITECTURE UNIT – 2 MCQs
12. Which is the simplest method of the micro-program corresponds to one
implementing hardwired control unit? control signal.
a) State Table Method 15. A decoder is required in case of a
b) Delay Element Method ______________
c) Sequence Counter Method a) Vertical Microinstruction
d) Using Circuits b) Horizontal Microinstruction
Answer: a c) Multilevel Microinstruction
Explanation: There are 3 ways of d) All types of microinstructions
implementing hardwired control unit: Answer: a
A state table is the simplest method in Explanation: There are two types of
which a number of circuits are designed microinstructions: Horizontal and Vertical.
based on the cells in the table. In a horizontal microinstruction, each bit
A delay element method consists of a represents a signal to be activated whereas,
flowchart drawn for the circuit. A D-flip flop in case of vertical microinstruction bits are
is used as a delay element. decoded and, the decoder then produces
A sequence counter method used k-modulo signals.
counter as a replacement for k delay 16. In boolean algebra, the OR operation is
elements. performed by which properties?
13. A set of microinstructions for a single a) Associative properties
machine instruction is called ___________ b) Commutative properties
a) Program c) Distributive properties
b) Command d) All of the Mentioned
c) Micro program Answer: d
d) Micro command Explanation: The expression for Associative
Answer: c property is given by A+(B+C) = (A+B)+C &
Explanation: For every micro-operation, a A*(B*C) = (A*B)*C.
set of microinstructions are written which The expression for Commutative property is
indicate the control signals to be activated. given by A+B = B+A & A*B = B*A.
A set of microinstructions is a micro The expression for Distributive property is
program. The address of the next given by A+BC=(A+B)(A+C) & A(B+C) =
microinstruction is given by a Micro- AB+AC.
program counter. 17. The expression for Absorption law is
14. Micro-program consists of a set of given by _________
microinstructions which are strings of 0s a) A + AB = A
and 1s. b) A + AB = B
a) True c) AB + AA’ = A
b) False d) A + B = B + A
Answer: a Answer: a
Explanation: The computer understands Explanation: The expression for Absorption
only binary language. So, the micro- Law is given by: A+AB = A.
program should have instructions which are Proof: A + AB = A(1+B) = A (Since 1 + B = 1
in the form of 0s and 1s. Each output line of as per 1’s Property).

DIWAKAR EDUCATION HUB Page 4


DIWAKAR EDUCATION HUB

PROGRAMMING LANGUAGES AND


COMPUTER GRAPHICS UNIT - 3
As per updated syllabus
DIWAKAR EDUCATION HUB

THE LEARN WITH EXPERTIES


PROGRAMMING LANGUAGES AND COMPUTER GRAPHICS UNIT - 3
Language Design
Language design techniques are the most important topic to design the Programming
Language and to solve various types of problems in the discipline of Comp. Science and IT. The
following are the major topics covered in Language Design.
1. Programming Language Concepts
2. PL-Paradigms and Models
3. Programming Environments
4. Translation process
Programming Language Concepts
Computer programming language, any of various languages for expressing a set of detailed
instructions for a digital computer. Such instructions can be executed directly when they are in
the computer manufacturer-specific numerical form known as machine language, after a
simple substitution process when expressed in a corresponding assembly language, or after
translation from some “higher-level” language. Although there are many computer languages,
relatively few are widely used.
Machine and assembly languages are “low-level,” requiring a programmer to manage explicitly
all of a computer’s idiosyncratic features of data storage and operation. In contrast, high-level
languages shield a programmer from worrying about such considerations and provide a
notation that is more easily written and read by programmers.
Language Types
Machine and assembly languages
A machine language consists of the numeric codes for the operations that a particular
computer can execute directly. The codes are strings of 0s and 1s, or binary digits (“bits”),
which are frequently converted both from and to hexadecimal (base 16) for human viewing
and modification. Machine language instructions typically use some bits to represent
operations, such as addition, and some to represent operands, or perhaps the location of the
next instruction. Machine language is difficult to read and write, since it does not resemble
conventional mathematical notation or human language, and its codes vary from computer to
computer.
Assembly language is one level above machine language. It uses short mnemonic codes for
instructions and allows the programmer to introduce names for blocks of memory that hold
data. One might thus write “add pay, total” instead of “0110101100101000” for an instruction
that adds two numbers.
Assembly language is designed to be easily translated into machine language. Although blocks
of data may be referred to by name instead of by their machine addresses, assembly language
does not provide more sophisticated means of organizing complex information. Like machine
language, assembly language requires detailed knowledge of internal computer architecture. It
is useful when such details are important, as in programming a computer to interact
with input/output devices (printers, scanners, storage devices, and so forth).
The built-in competence and defects of the various programming languages like FORTRAN,
ALGOL, COBOL, C, C++, and JAVA. List of Differences between higher and lower/machine level
languages.

DIWAKAR EDUCATION HUB Page 2


PROGRAMMING LANGUAGES AND COMPUTER GRAPHICS UNIT - 3

Basic theories like abstract syntax, interpretation, stack, heap organization, compilation
techniques, different types of 'type checking' and 'error checking' various for each
Programming language.

Algorithmic languages
Algorithmic languages are designed to express mathematical or symbolic computations. They
can express algebraic operations in notation similar to mathematics and allow the use of
subprograms that package commonly used operations for reuse. They were the first high-level
languages.
FORTRAN
The first important algorithmic language was FORTRAN (formula translation), designed in 1957
by an IBM team led by John Backus. It was intended for scientific computations with real
numbers and collections of them organized as one- or multidimensional arrays. Its control
DIWAKAR EDUCATION HUB Page 3
PROGRAMMING LANGUAGES AND COMPUTER GRAPHICS UNIT - 3
structures included conditional IF statements, repetitive loops (so-called DO loops), and a
GOTO statement that allowed nonsequential execution of program code. FORTRAN made it
convenient to have subprograms for common mathematical operations, and built libraries of
them.
FORTRAN was also designed to translate into efficient machine language. It was immediately
successful and continues to evolve.
ALGOL
ALGOL (algorithmic language) was designed by a committee of American and European
computer scientists during 1958–60 for publishing algorithms, as well as for doing
computations. Like LISP (described in the next section), ALGOL had recursive subprograms—
procedures that could invoke themselves to solve a problem by reducing it to a smaller
problem of the same kind. ALGOL introduced block structure, in which a program is composed
of blocks that might contain both data and instructions and have the same structure as an
entire program. Block structure became a powerful tool for building large programs out of
small components.
ALGOL contributed a notation for describing the structure of a programming language,
Backus–Naur Form, which in some variation became the standard tool for stating
the syntax (grammar) of programming languages. ALGOL was widely used in Europe, and for
many years it remained the language in which computer algorithms were published. Many
important languages, such as Pascal and Ada (both described later), are its descendants.
LISP
LISP (list processing) was developed about 1960 by John McCarthy at the Massachusetts
Institute of Technology (MIT) and was founded on the mathematical theory of
recursive functions (in which a function appears in its own definition). A LISP program is a
function applied to data, rather than being a sequence of procedural steps as in FORTRAN and
ALGOL. LISP uses a very simple notation in which operations and their operands are given in a
parenthesized list. For example, (+ a (* b c)) stands for a + b*c. Although this appears
awkward, the notation works well for computers. LISP also uses the list structure to represent
data, and, because programs and data use the same structure, it is easy for a LISP program to
operate on other programs as data.
LISP became a common language for artificial intelligence (AI) programming, partly owing to
the confluence of LISP and AI work at MIT and partly because AI programs capable of
“learning” could be written in LISP as self-modifying programs. LISP has evolved through
numerous dialects, such as Scheme and Common LISP.
C
The C programming language was developed in 1972 by Dennis Ritchie and Brian Kernighan at
the AT&T Corporation for programming computer operating systems. Its capacity to structure
data and programs through the composition of smaller units is comparable to that of ALGOL. It
uses a compact notation and provides the programmer with the ability to operate with the
addresses of data as well as with their values. This ability is important in systems
programming, and C shares with assembly language the power to exploit all the features of a

DIWAKAR EDUCATION HUB Page 4


PROGRAMMING LANGUAGES AND COMPUTER GRAPHICS UNIT - 3
computer’s internal architecture. C, along with its descendant C++, remains one of the most
common languages.
Business-oriented languages
COBOL
COBOL (common business oriented language) has been heavily used by businesses since its
inception in 1959. A committee of computer manufacturers and users and U.S. government
organizations established CODASYL (Committee on Data Systems and Languages) to develop
and oversee the language standard in order to ensure its portability across diverse systems.
COBOL uses an English-like notation—novel when introduced. Business computations organize
and manipulate large quantities of data, and COBOL introduced the record data structure for
such tasks. A record clusters heterogeneous data such as a name, ID number, age, and address
into a single unit. This contrasts with scientific languages, in which homogeneous arrays of
numbers are common. Records are an important example of “chunking” data into a single
object, and they appear in nearly all modern languages.
SQL
SQL (structured query language) is a language for specifying the organization of databases
(collections of records). Databases organized with SQL are called relational because SQL
provides the ability to query a database for information that falls in a given relation. For
example, a query might be “find all records with both last_name Smith and city New York.”
Commercial database programs commonly use a SQL-like language for their queries.
Education-oriented languages
BASIC
BASIC (beginner’s all-purpose symbolic instruction code) was designed at Dartmouth College in
the mid-1960s by John Kemeny and Thomas Kurtz. It was intended to be easy to learn by
novices, particularly non-computer science majors, and to run well on a time-sharing
computer with many users. It had simple data structures and notation and it was interpreted:
a BASIC program was translated line-by-line and executed as it was translated, which made it
easy to locate programming errors.
Its small size and simplicity also made BASIC a popular language for early personal computers.
Its recent forms have adopted many of the data and control structures of other contemporary
languages, which makes it more powerful but less convenient for beginners.
Pascal
About 1970 Niklaus Wirth of Switzerland designed Pascal to teach structured programming,
which emphasized the orderly use of conditional and loop control structures without GOTO
statements. Although Pascal resembled ALGOL in notation, it provided the ability to define
data types with which to organize complex information, a feature beyond the capabilities of
ALGOL as well as FORTRAN and COBOL. User-defined data types allowed the programmer to
introduce names for complex data, which the language translator could then check for correct
usage before running a program.
During the late 1970s and ’80s, Pascal was one of the most widely used languages for
programming instruction. It was available on nearly all computers, and, because of its
familiarity, clarity, and security, it was used for production software as well as for education.
DIWAKAR EDUCATION HUB Page 5
PROGRAMMING LANGUAGES AND COMPUTER GRAPHICS UNIT - 3
Logo
Logo originated in the late 1960s as a simplified LISP dialect for education; Seymour
Papert and others used it at MIT to teach mathematical thinking to schoolchildren. It had a
more conventional syntax than LISP and featured “turtle graphics,” a simple method for
generating computer graphics. (The name came from an early project to program a turtlelike
robot.) Turtle graphics used body-centred instructions, in which an object was moved around a
screen by commands, such as “left 90” and “forward,” that specified actions relative to the
current position and orientation of the object rather than in terms of a fixed framework.
Together with recursive routines, this technique made it easy to program intricate and
attractive patterns.
Hypertalk
Hypertalk was designed as “programming for the rest of us” by Bill Atkinson for Apple’s
Macintosh. Using a simple English-like syntax, Hypertalk enabled anyone to combine text,
graphics, and audio quickly into “linked stacks” that could be navigated by clicking with
a mouse on standard buttons supplied by the program. Hypertalk was particularly popular
among educators in the 1980s and early ’90s for classroom multimedia presentations.
Although Hypertalk had many features of object-oriented languages (described in the next
section), Apple did not develop it for other computer platforms and let it languish; as Apple’s
market share declined in the 1990s, a new cross-platform way of displaying multimedia left
Hypertalk all but obsolete (see the section World Wide Web display languages).
Object-oriented languages
Object-oriented languages help to manage complexity in large programs. Objects package data
and the operations on them so that only the operations are publicly accessible and internal
details of the data structures are hidden. This information hiding made large-scale
programming easier by allowing a programmer to think about each part of the program in
isolation. In addition, objects may be derived from more general ones, “inheriting” their
capabilities. Such an object hierarchy made it possible to define specialized objects without
repeating all that is in the more general ones.
Object-oriented programming began with the Simula language (1967), which added
information hiding to ALGOL. Another influential object-oriented language was Smalltalk
(1980), in which a program was a set of objects that interacted by sending messages to one
another.
C++
The C++ language, developed by Bjarne Stroustrup at AT&T in the mid-1980s, extended C by
adding objects to it while preserving the efficiency of C programs. It has been one of the most
important languages for both education and industrial programming. Large parts of many
operating systems, such as the Microsoft Corporation’s Windows 98, were written in C++.
Ada
Ada was named for Augusta Ada King, countess of Lovelace, who was an assistant to the 19th-
century English inventor Charles Babbage, and is sometimes called the first computer
programmer. Ada, the language, was developed in the early 1980s for the U.S. Department of
Defense for large-scale programming. It combined Pascal-like notation with the ability to

DIWAKAR EDUCATION HUB Page 6


PROGRAMMING LANGUAGES AND COMPUTER GRAPHICS UNIT - 3
package operations and data into independent modules. Its first form, Ada 83, was not fully
object-oriented, but the subsequent Ada 95 provided objects and the ability to
construct hierarchies of them. While no longer mandated for use in work for the Department
of Defense, Ada remains an effective language for engineering large programs.
Java
In the early 1990s, Java was designed by Sun Microsystems, Inc., as a programming language
for the World Wide Web (WWW). Although it resembled C++ in appearance, it was fully
object-oriented. In particular, Java dispensed with lower-level features, including the ability to
manipulate data addresses, a capability that is neither desirable nor useful in programs for
distributed systems. In order to be portable, Java programs are translated by a Java Virtual
Machine specific to each computer platform, which then executes the Java program. In
addition to adding interactive capabilities to the Internet through Web “applets,” Java has
been widely used for programming small and portable devices, such as mobile telephones.
PL-Paradigms and Models
A programming paradigm is a various system design of ideas that have been used to
guide/implement the programming.
Paradigm can also be termed as method to solve some problem or do some task.
Programming paradigm is an approach to solve problem using some programming language or
also we can say it is a method to solve a problem using tools and techniques that are available
to us following some approach. There are lots for programming language that are known but
all of them need to follow some strategy when they are implemented and this
methodology/strategy is paradigms. Apart from varieties of programming language there are
lots of paradigms to fulfil each and every demand.

Following list of paradigms

Imperative: Explicit sequence [such as assignment statements] of statements that change the
state of the computer.
It is one of the oldest programming paradigm. It features close relation relation to machine
architecture. It is based on Von Neumann architecture. It works by changing the program state
through assignment statements. It performs step by step task by changing state. The main

DIWAKAR EDUCATION HUB Page 7


PROGRAMMING LANGUAGES AND COMPUTER GRAPHICS UNIT - 3
focus is on how to achieve the goal. The paradigm consist of several statements and after
execution of all the result is stored.
Advantage:
1. Very simple to implement
2. It contains loops, variables etc.
Disadvantage:
1. Complex problem cannot be solved
2. Less efficient and less productive
3. Parallel programming is not possible
Examples of Imperative programming paradigm:
C : developed by Dennis Ritchie and Ken Thompson
Fortan : developed by John Backus for IBM
Basic : developed by John G Kemeny and Thomas E Kurtz

// average of five number in C


int marks[5] = { 12, 32, 45, 13, 19 } int sum = 0;
float average = 0.0;
for (int i = 0; i < 5; i++) {
sum = sum + marks[i];
}
average = sum / 5;
Imperative programming is divided into three broad categories: Procedural, OOP and parallel
processing. These paradigms are as follows:
Procedural: Imperative programming with procedure calls something like the re-use of code.
This paradigm emphasizes on procedure in terms of under lying machine model. There is no
difference in between procedural and imperative approach. It has the ability to reuse the code
and it was boon at that time when it was in use because of its reusability.
Examples of Procedural programming paradigm:

C : developed by Dennis Ritchie and Ken Thompson


C++ : developed by Bjarne Stroustrup
Java : developed by James Gosling at Sun Microsystems
ColdFusion : developed by J J Allaire
Pascal : developed by Niklaus Wirth
Object-Oriented: By defining the objects that transfers messages to each objects or program.
Objects have their own internal state with public interface calls [encapsulation].
The program is written as a collection of classes and object which are meant for
communication. The smallest and basic entity is object and all kind of computation is
performed on the objects only. More emphasis is on data rather procedure. It can handle
almost all kind of real life problems which are today in scenario.
DIWAKAR EDUCATION HUB Page 8
DIWAKAR EDUCATION HUB

PROGRAMMING LANGUAGES AND


COMPUTER GRAPHICS UNIT – 3 MCQS

As per updated syllabus


DIWAKAR EDUCATION HUB

THE LEARN WITH EXPERTIES


PROGRAMMING LANGUAGES AND COMPUTER GRAPHICS UNIT – 3 MCQS
1) What is the 16-bit compiler allowable programs can specify additional functions. A
range for integer constants? function is a piece of code. In other words,
a) -3.4e38 to 3.4e38 it works like a sub-program.
b) -32767 to 32768 4) What will this program print?
c) -32668 to 32667 main()
d) -32768 to 32767 {
Answer: (d) -32768 to 32767 int i = 2;
Explanation: In a 16-bit C compiler, we have {
2 bytes to store the value. int i = 4, j = 5;
o The range for signed integers is -
printf("%d %d", i, j);
32768 to 32767.
}
o The range for unsigned integers is 0
printf("%d %d", i, j);
to 65535.
}
o The range for unsigned character is 0
a. 4525
to 255.
b. 2525
2) Study the following program:
c. 4545
main()
d. None of the these
{printf("javatpoint");
Answer: (a) 4525
main();}
Explanation: In this program, it will first
What will be the output of this program?
print the inner value of the function and
a. Wrong statement
then print the outer value of the function.
b. It will keep on printing javatpoint
5) Which of the following comment is
c. It will Print javatpoint once correct when a macro definition includes
d. None of the these arguments?
Answer: (b) It will keep on printing a. The opening parenthesis should
javatpoint immediately follow the macro name.
Explanation: In this program, the main b. There should be at least one blank
function will call itself again and again. between the macro name and the opening
Therefore, it will continue to print parenthesis.
javatpoint. c. There should be only one blank
3) What is required in each C program? between the macro name and the opening
a. The program must have at least one parenthesis.
function. d. All the above comments are correct.
b. The program does not require any Answer: (a) The opening parenthesis should
function. immediately follow the macro name.
c. Input data 6) What is a lint?
d. Output data a. C compiler
Answer: (a) The program must have at least b. Interactive debugger
one function. c. Analyzing tool
Explanation: Any C program has at least d. C interpreter
one function, and even the most trivial
DIWAKAR EDUCATION HUB Page 2
PROGRAMMING LANGUAGES AND COMPUTER GRAPHICS UNIT – 3 MCQS
Answer: (c) Analyzing tool What will be the output of this program?
Explanation: Lint is an analyzing tool that a. 6
analyzes the source code by suspicious b. 9
constructions, stylistic errors, bugs, and flag c. 12
programming errors. Lint is a compiler-like d. 8
tool in which it parses the source files of C
Answer: (d) 8
programming. It checks the syntactic
Explanation: It is an effect of the comma
accuracy of these files.
operator.
7) What is the output of this statement
a + = (a + = 3, 5, a)
"printf("%d", (a++))"?
It first evaluates to "a + = 3" i.e. a = a + 3
a. The value of (a + 1)
then evaluate 5 and then evaluate "a".
b. The current value of a
Therefore, we will get the output is 4.
c. Error message
Then,
d. Garbage
a+=4
Answer: (b) The current value of "a".
It gives 8 as the output.
10) What does this declaration mean?
8) Study the following program:
int x : 4;
main()
a. X is a four-digit integer.
{
b. X cannot be greater than a four-digit
char x [10], *ptr = x;
integer.
scanf ("%s", x);
c. X is a four-bit integer.
change(&x[4]);
d. None of the these
}
change(char a[])
Answer: (c) X is a four-bit integer.
{
Explanation: This means, "X" is a four bit
puts(a); integer.
} 11) Why is a macro used in place of a
If abcdefg is the input, the output will be function?
a. abcd a. It reduces execution time.
b. abc b. It reduces code size.
c. efg c. It increases execution time.
d. Garbage d. It increases code size.
Answer: (c) efg Answer: (d) It reduces code size.
Explanation: Macro is used in place of a
9) Study the following program: function because it reduces code size, and
main() very efficient.
{ 12) In the C language, the constant is
int a = 1, b = 2, c = 3: defined _______.
printf("%d", a + = (a + = 3, 5, a)) a. Before main
} b. After main
DIWAKAR EDUCATION HUB Page 3
PROGRAMMING LANGUAGES AND COMPUTER GRAPHICS UNIT – 3 MCQS
c. Anywhere, but starting on a new line. b. while
d. None of the these. c. switch
Answer: (c) Anywhere, but starting on a d. do while
new line. Answer: (d) do while
Explanation: In the C language, the Explanation: The body of a loop is often
constant is defined anywhere, but starting executed at least once during the do-while
on a new line. loop. Once the body is performed, the
13) How many times will the following loop condition is tested. If the condition is valid,
execute? it will execute the body of a loop;
for(j = 1; j <= 10; j = j-1) otherwise, control is transferred out of the
a. Forever loop.
b. Never 17) Which of the following best describes
c. 0 the ordering of destructor calls for stack-
resident objects in a routine?
d. 1
a. The first object created is the first
Answer: (a) Forever
object destroyed; last created is last
14) A pointer is a memory address. Suppose
destroyed.
the pointer variable has p address 1000,
b. The first object destroyed is the last
and that p is declared to have type int*, and
object destroyed; last created is first
an int is 4 bytes long. What address is
destroyed.
represented by expression p + 2?
c. Objects are destroyed in the order
a. 1002
they appear in memory, the object with the
b. 1004
lowest memory address is destroyed first.
c. 1006
d. The order is undefined and may vary
d. 1008 from compiler to compiler.
Answer: (d) 1008 Answer: (b) The first object destroyed is the
15) What is the result after execution of the last object destroyed; last created is first
following code if a is 10, b is 5, and c is 10? destroyed.
If ((a > b) && (a <= c))
a = a + 1; 18) How many characters can a string hold
else when declared as follows?
c = c+1; char name[20]:
a. a = 10, c = 10 a. 18
b. a = 11, c = 10 b. 19
c. a = 10, c = 11 c. 20
d. a = 11, c = 11 d. None of the these
Answer: (b) a = 11, c = 10 Answer: (b) 20
16) Which one of the following is a loop 19) Directives are translated by the
construct that will always be executed a. Pre-processor
once? b. Compiler
a. for c. Linker
DIWAKAR EDUCATION HUB Page 4
DIWAKAR EDUCATION HUB

DATABASE MANAGEMENT
SYSTEMS UNIT – 4
AS PER UPDATED SYLLABUS
DIWAKAR EDUCATION HUB

THE LEARN WITH EXPERTIES


DATABASE MANAGEMENT SYSTEMS UNIT – 4
Database Management System
Database Management System or DBMS in short refers to the technology of storing and
retrieving usersí data with utmost efficiency along with appropriate security measures.
Database is a collection of related data and data is a collection of facts and figures that can be
processed to produce information.
Mostly data represents recordable facts. Data aids in producing information, which is based on
facts. For example, if we have data about marks obtained by all students, we can then
conclude about toppers and average marks.
A database management system stores data in such a way that it becomes easier to retrieve,
manipulate, and produce information.
Database Management System or DBMS in short refers to the technology of storing and
retrieving usersí data with utmost efficiency along with appropriate security measures.
Characteristics
Traditionally, data was organized in file formats. DBMS was a new concept then, and all the
research was done to make it overcome the deficiencies in traditional style of data
management. A modern DBMS has the following characteristics −
 Real-world entity − A modern DBMS is more realistic and uses real-world entities to
design its architecture. It uses the behavior and attributes too. For example, a school
database may use students as an entity and their age as an attribute.
 Relation-based tables − DBMS allows entities and relations among them to form tables.
A user can understand the architecture of a database just by looking at the table names.
 Isolation of data and application − A database system is entirely different than its data.
A database is an active entity, whereas data is said to be passive, on which the database
works and organizes. DBMS also stores metadata, which is data about data, to ease its
own process.
 Less redundancy − DBMS follows the rules of normalization, which splits a relation when
any of its attributes is having redundancy in values. Normalization is a mathematically
rich and scientific process that reduces data redundancy.
 Consistency − Consistency is a state where every relation in a database remains
consistent. There exist methods and techniques, which can detect attempt of leaving
database in inconsistent state. A DBMS can provide greater consistency as compared to
earlier forms of data storing applications like file-processing systems.
 Query Language − DBMS is equipped with query language, which makes it more
efficient to retrieve and manipulate data. A user can apply as many and as different
filtering options as required to retrieve a set of data. Traditionally it was not possible
where file-processing system was used.
 ACID Properties − DBMS follows the concepts of Atomicity, Consistency, Isolation,
and Durability (normally shortened as ACID). These concepts are applied on
transactions, which manipulate data in a database. ACID properties help the database
stay healthy in multi-transactional environments and in case of failure.
 Multiuser and Concurrent Access − DBMS supports multi-user environment and allows
them to access and manipulate data in parallel. Though there are restrictions on
DIWAKAR EDUCATION HUB Page 2
DATABASE MANAGEMENT SYSTEMS UNIT – 4
transactions when users attempt to handle the same data item, but users are always
unaware of them.
 Multiple views − DBMS offers multiple views for different users. A user who is in the
Sales department will have a different view of database than a person working in the
Production department. This feature enables the users to have a concentrate view of
the database according to their requirements.
 Security − Features like multiple views offer security to some extent where users are
unable to access data of other users and departments. DBMS offers methods to impose
constraints while entering data into the database and retrieving the same at a later
stage. DBMS offers many different levels of security features, which enables multiple
users to have different views with different features. For example, a user in the Sales
department cannot see the data that belongs to the Purchase department. Additionally,
it can also be managed how much data of the Sales department should be displayed to
the user. Since a DBMS is not saved on the disk as traditional file systems, it is very hard
for miscreants to break the code.
Users
A typical DBMS has users with different rights and permissions who use it for different
purposes. Some users retrieve data and some back it up. The users of a DBMS can be broadly
categorized as follows −

 Administrators − Administrators maintain the DBMS and are responsible for


administrating the database. They are responsible to look after its usage and by whom it
should be used. They create access profiles for users and apply limitations to maintain
isolation and force security. Administrators also look after DBMS resources like system
license, required tools, and other software and hardware related maintenance.
 Designers − Designers are the group of people who actually work on the designing part
of the database. They keep a close watch on what data should be kept and in what
format. They identify and design the whole set of entities, relations, constraints, and
views.
 End Users − End users are those who actually reap the benefits of having a DBMS. End
users can range from simple viewers who pay attention to the logs or market rates to
sophisticated users such as business analysts.
Applications of DBMS
Database is a collection of related data and data is a collection of facts and figures that can be
processed to produce information.

DIWAKAR EDUCATION HUB Page 3


DATABASE MANAGEMENT SYSTEMS UNIT – 4
Mostly data represents recordable facts. Data aids in producing information, which is based on
facts. For example, if we have data about marks obtained by all students, we can then
conclude about toppers and average marks.
A database management system stores data in such a way that it becomes easier to retrieve,
manipulate, and produce information. Following are the important characteristics and
applications of DBMS.
 ACID Properties − DBMS follows the concepts of Atomicity, Consistency, Isolation,
and Durability (normally shortened as ACID). These concepts are applied on
transactions, which manipulate data in a database. ACID properties help the database
stay healthy in multi-transactional environments and in case of failure.
 Multiuser and Concurrent Access − DBMS supports multi-user environment and allows
them to access and manipulate data in parallel. Though there are restrictions on
transactions when users attempt to handle the same data item, but users are always
unaware of them.
 Multiple views − DBMS offers multiple views for different users. A user who is in the
Sales department will have a different view of database than a person working in the
Production department. This feature enables the users to have a concentrate view of
the database according to their requirements.
 Security − Features like multiple views offer security to some extent where users are
unable to access data of other users and departments. DBMS offers methods to impose
constraints while entering data into the database and retrieving the same at a later
stage. DBMS offers many different levels of security features, which enables multiple
users to have different views with different features. For example, a user in the Sales
department cannot see the data that belongs to the Purchase department. Additionally,
it can also be managed how much data of the Sales department should be displayed to
the user. Since a DBMS is not saved on the disk as traditional file systems, it is very hard
for miscreants to break the code.
DBMS - Architecture
The design of a DBMS depends on its architecture. It can be centralized or decentralized or
hierarchical. The architecture of a DBMS can be seen as either single tier or multi-tier. An n-
tier architecture divides the whole system into related but independent n modules, which can
be independently modified, altered, changed, or replaced.
In 1-tier architecture, the DBMS is the only entity where the user directly sits on the DBMS and
uses it. Any changes done here will directly be done on the DBMS itself. It does not provide
handy tools for end-users. Database designers and programmers normally prefer to use single-
tier architecture.
If the architecture of DBMS is 2-tier, then it must have an application through which the DBMS
can be accessed. Programmers use 2-tier architecture where they access the DBMS by means
of an application. Here the application tier is entirely independent of the database in terms of
operation, design, and programming.
3-tier Architecture

DIWAKAR EDUCATION HUB Page 4


DATABASE MANAGEMENT SYSTEMS UNIT – 4
A 3-tier architecture separates its tiers from each other based on the complexity of the users
and how they use the data present in the database. It is the most widely used architecture to
design a DBMS.

 Database (Data) Tier − At this tier, the database resides along with its query processing
languages. We also have the relations that define the data and their constraints at this
level.
 Application (Middle) Tier − At this tier reside the application server and the programs
that access the database. For a user, this application tier presents an abstracted view of
the database. End-users are unaware of any existence of the database beyond the
application. At the other end, the database tier is not aware of any other user beyond
the application tier. Hence, the application layer sits in the middle and acts as a
mediator between the end-user and the database.
 User (Presentation) Tier − End-users operate on this tier and they know nothing about
any existence of the database beyond this layer. At this layer, multiple views of the
database can be provided by the application. All views are generated by applications
that reside in the application tier.
Multiple-tier database architecture is highly modifiable, as almost all its components are
independent and can be changed independently.
Data Models
Data models define how the logical structure of a database is modeled. Data Models are
fundamental entities to introduce abstraction in a DBMS. Data models define how data is
connected to each other and how they are processed and stored inside the system.
The very first data model could be flat data-models, where all the data used are to be kept in
the same plane. Earlier data models were not so scientific, hence they were prone to
introduce lots of duplication and update anomalies.
Entity-Relationship Model
Entity-Relationship (ER) Model is based on the notion of real-world entities and relationships
among them. While formulating real-world scenario into the database model, the ER Model
creates entity set, relationship set, general attributes and constraints.
ER Model is best used for the conceptual design of a database.
DIWAKAR EDUCATION HUB Page 5
DATABASE MANAGEMENT SYSTEMS UNIT – 4
ER Model is based on −
 Entities and their attributes.
 Relationships among entities.
These concepts are explained below.

 Entity − An entity in an ER Model is a real-world entity having properties


called attributes. Every attribute is defined by its set of values called domain. For
example, in a school database, a student is considered as an entity. Student has various
attributes like name, age, class, etc.
 Relationship − The logical association among entities is called relationship.
Relationships are mapped with entities in various ways. Mapping cardinalities define the
number of association between two entities.
Mapping cardinalities −
o one to one
o one to many
o many to one
o many to many
Relational Model
The most popular data model in DBMS is the Relational Model. It is more scientific a model
than others. This model is based on first-order predicate logic and defines a table as an n-ary
relation.

DIWAKAR EDUCATION HUB Page 6


DATABASE MANAGEMENT SYSTEMS UNIT – 4
The main highlights of this model are −
 Data is stored in tables called relations.
 Relations can be normalized.
 In normalized relations, values saved are atomic values.
 Each row in a relation contains a unique value.
 Each column in a relation contains values from a same domain.
Data Schemas
A database schema is the skeleton structure that represents the logical view of the entire
database. It defines how the data is organized and how the relations among them are
associated. It formulates all the constraints that are to be applied on the data.
A database schema defines its entities and the relationship among them. It contains a
descriptive detail of the database, which can be depicted by means of schema diagrams. It’s
the database designers who design the schema to help programmers understand the database
and make it useful.

A database schema can be divided broadly into two categories −


 Physical Database Schema − This schema pertains to the actual storage of data and its
form of storage like files, indices, etc. It defines how the data will be stored in a
secondary storage.
 Logical Database Schema − This schema defines all the logical constraints that need to
be applied on the data stored. It defines tables, views, and integrity constraints.
Database Instance
It is important that we distinguish these two terms individually. Database schema is the
skeleton of database. It is designed when the database doesn't exist at all. Once the database
is operational, it is very difficult to make any changes to it. A database schema does not
contain any data or information.
A database instance is a state of operational database with data at any given time. It contains
a snapshot of the database. Database instances tend to change with time. A DBMS ensures

DIWAKAR EDUCATION HUB Page 7


DATABASE MANAGEMENT SYSTEMS UNIT – 4
that its every instance (state) is in a valid state, by diligently following all the validations,
constraints, and conditions that the database designers have imposed.
Three schema Architecture
 The three schema architecture is also called ANSI/SPARC architecture or three-level
architecture.
 This framework is used to describe the structure of a specific database system.
 The three schema architecture is also used to separate the user applications and
physical database.
 The three schema architecture contains three-levels. It breaks the database down
into three different categories.
The three-schema architecture is as follows:

In the above diagram:


o It shows the DBMS architecture.
o Mapping is used to transform the request and response between various database
levels of architecture.
o Mapping is not good for small DBMS because it takes more time.
o In External / Conceptual mapping, it is necessary to transform the request from external
level to conceptual schema.
o In Conceptual / Internal mapping, DBMS transform the request from the conceptual to
internal level.
1. Internal Level
o The internal level has an internal schema which describes the physical storage structure
of the database.

DIWAKAR EDUCATION HUB Page 8


DIWAKAR EDUCATION HUB

DATABASE MANAGEMENT
SYSTEMS UNIT – 4 MCQs
AS PER UPDATED SYLLABUS
DIWAKAR EDUCATION HUB

THE LEARN WITH EXPERTIES


DATABASE MANAGEMENT SYSTEMS UNIT – 4 MCQs
1. A relational database consists of a 5. For each attribute of a relation, there is a
collection of set of permitted values, called the
a) Tables ________ of that attribute.
b) Fields a) Domain
c) Records b) Relation
d) Keys c) Set
Answer: a d) Schema
Explanation: Fields are the column of the Answer: a
relation or tables. Records are each row in a Explanation: The values of the attribute
relation. Keys are the constraints in a should be present in the domain. Domain is
relation. a set of values permitted.
2. A ________ in a table represents a 6. Database __________ which is the logical
relationship among a set of values. design of the database, and the database
a) Column _______ which is a snapshot of the data in
b) Key the database at a given instant in time.
c) Row a) Instance, Schema
d) Entry b) Relation, Schema
Answer: c c) Relation, Domain
Explanation: Column has only one set of d) Schema, Instance
values. Keys are constraints and row is one Answer: d
whole set of attributes. Entry is just a piece Explanation: Instance is an instance of time
of data. and schema is a representation.
3. The term _______ is used to refer to a 7. Course(course_id,sec_id,semester)
row. Here the course_id,sec_id and semester are
a) Attribute __________ and course is a _________
b) Tuple a) Relations, Attribute
c) Field b) Attributes, Relation
d) Instance c) Tuple, Relation
Answer: b d) Tuple, Attributes
Explanation: Tuple is one entry of the Answer: b
relation with several attributes which are Explanation: The relation course has a set
fields. of attributes course_id,sec_id,semester .
4. The term attribute refers to a 8. Department (dept name, building,
___________ of a table. budget) and Employee (employee_id,
a) Record name, dept name, salary)
b) Column Here the dept_name attribute appears in
c) Tuple both the relations. Here using common
d) Key attributes in relation schema is one way of
Answer: b relating ___________ relations.
Explanation: Attribute is a specific domain a) Attributes of common
in the relation which has entries of all b) Tuple of common
tuples. c) Tuple of distinct
d) Attributes of distinct
DIWAKAR EDUCATION HUB Page 2
DATABASE MANAGEMENT SYSTEMS UNIT – 4 MCQs
Answer: c 13. The subset of a super key is a candidate
Explanation: Here the relations are key under what condition?
connected by the common attributes. a) No proper subset is a super key
9. A domain is atomic if elements of the b) All subsets are super keys
domain are considered to be ____________ c) Subset is a super key
units. d) Each subset is a super key
a) Different Answer: a
b) Indivisbile Explanation: The subset of a set cannot be
c) Constant the same set. Candidate key is a set from a
d) Divisible super key which cannot be the whole of the
Answer: b super set.
10. The tuples of the relations can be of 14. A _____ is a property of the entire
________ order. relation, rather than of the individual tuples
a) Any in which each tuple is unique.
b) Same a) Rows
c) Sorted b) Key
d) Constant c) Attribute
Answer: a d) Fields
Explanation: The values only count. The Answer: b
order of the tuples does not matter. Explanation: Key is the constraint which
11. Which one of the following is a set of specifies uniqueness.
one or more attributes taken collectively to 15. Which one of the following attribute can
uniquely identify a record? be taken as a primary key?
a) Candidate key a) Name
b) Sub key b) Street
c) Super key c) Id
d) Foreign key d) Department
Answer: c Answer: c
Explanation: Super key is the superset of all Explanation: The attributes name, street
the keys in a relation. and department can repeat for some
12. Consider attributes ID, CITY and NAME. tuples. But the id attribute has to be
Which one of this can be considered as a unique. So it forms a primary key.
super key? 16. Which one of the following cannot be
a) NAME taken as a primary key?
b) ID a) Id
c) CITY b) Register number
d) CITY, ID c) Dept_id
Answer: b d) Street
Explanation: Here the id is the only Answer: d
attribute which can be taken as a key. Other Explanation: Street is the only attribute
attributes are not uniquely identified. which can occur more than once.

DIWAKAR EDUCATION HUB Page 3


DATABASE MANAGEMENT SYSTEMS UNIT – 4 MCQs
17. An attribute in a relation is a foreign key The relation r1 is also called the referencing
if the _______ key from one relation is used relation of the foreign key dependency, and
as an attribute in that relation. r2 is called the referenced relation of the
a) Candidate foreign key.
b) Primary 21. Using which language can a user request
c) Super information from a database?
d) Sub a) Query
Answer: b b) Relational
Explanation: The primary key has to be c) Structural
referred in the other relation to form a d) Compiler
foreign key in that relation. Answer: a
18. The relation with the attribute which is Explanation: Query language is a method
the primary key is referenced in another through which the database entries can be
relation. The relation which has the accessed.
attribute as a primary key is called 22. Student(ID, name, dept name, tot_cred)
a) Referential relation In this query which attributes form the
b) Referencing relation primary key?
c) Referenced relation a) Name
d) Referred relation b) Dept
Answer: b c) Tot_cred
19. The ______ is the one in which the d) ID
primary key of one relation is used as a Answer: d
normal attribute in another relation. Explanation: The attributes name, dept and
a) Referential relation tot_cred can have same values unlike ID.
b) Referencing relation 23. Which one of the following is a
c) Referenced relation procedural language?
d) Referred relation a) Domain relational calculus
Answer: c b) Tuple relational calculus
20. A _________ integrity constraint c) Relational algebra
requires that the values appearing in d) Query language
specified attributes of any tuple in the Answer: c
referencing relation also appear in specified Explanation: Domain and Tuple relational
attributes of at least one tuple in the calculus are non-procedural language.
referenced relation. Query language is a method through which
a) Referential database entries can be accessed.
b) Referencing 24. The_____ operation allows the
c) Specific combining of two relations by merging pairs
d) Primary of tuples, one from each relation, into a
Answer: a single tuple.
Explanation: A relation, say r1, may include a) Select
among its attributes the primary key of b) Join
another relation, say r2. This attribute is c) Union
called a foreign key from r1, referencing r2. d) Intersection
DIWAKAR EDUCATION HUB Page 4

You might also like