Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 23

Computer Science

Assignment - 1

1) Use the truth table to show that: (A.B+C)+(A.B)’=1

2) State the two absorption laws. Verify one of them using truth table

3) Convert the given function to its equivalent POS form F(A,B,C)=∑(0,3,5,7)

4) Simplify using laws of Boolean- (P+Q).(P’+Q’).(P’+Q)+P

5) Draw the truth table to prove the propositional logic expression: a<=>b=(a =>b).(b =>a)

6) Simplify using Boolean algebra. At each step state clearly the law used: X.Y. (X.Y+Y.Z)

7) State the De Morgan’s laws. Verify any one of them using truth table.

8) Find the complement of F(a,b,c,d)=[a+{(b+c).(b’+d’)}]

9) Draw the logic gate diagram and truth table for XOR gate.

10) What do you mean by idempotence law? Explain giving example.

11) Convert the given function to its equivalent POS form F(A,B,C)=(2,6,7)

12) Convert the following SOP into its corresponding POS: F(O,V,W,)=O’.V’.W’+O’.VV’.W+O’.V.W+O.V’.W

13) Find the complement of F(m,n,o)=m’.n.o’+m’.n’.o

14) Write the product of sum form for the Boolean function F(A,B,C) whose output is 0 only when: A=1,B=0,C=0

A=0,B=1,C=0 A=0,B=0,C=1 A=1,B=1,C=1

15) Simplify a.b+a’.c+b.c using the laws of Boolean Algebra.

16) Reduce the following into its simplest form using laws of Boooean Algebra. At each step state clearly the law

used for simplications. C.D+A+A+C.D+A.B

17) State the principle of duality. Give an example.

18) Simplify the given expression using laws of Boolean algebra. A.(B.C)’+(A.B.C)’

19) Find the complement of: F(a,b,c,d)=[A+(A’+A.B.C)]

20) If K=A+B.C, then prove that K.K’=0 and K+K’=1

21) Write the canonical POS for the Boolean function denoted by the expression F(A,B,C)=∑(1,2,3,6,7)

22) Prove that ((p’+q)(q’+r))’ + (p’+r) = 1

23) If x=>y,Then write its converse, inverse, contrapositive

24) Define Maxterms and minterms. Find the maxterm and minterm when P=0,Q=1,R=1,S=0

25) Convert the following cardinal form of expression to its canonical form

F= (P,Q,R)=𝜋(1,3)
Computer Science

Assignment - 2

Reduce the below expression by using 4-variable Karnaugh map, showing the various groups (i.e.

octal, quads and pairs).

Draw the logic gate diagram for the reduced expression. Assume that the variables and their

complements are available as inputs.

1) Given F(P,Q,R,S) = π ( 5, 7, 8, 10, 12, 14, 15 ) 2) Given F(A,B,C,D) = ( 0, 2, 3, 6, 8, 10, 11, 14, 15 )

3) Given F (A,B,C,D) =Σ( 0, 1, 2, 5, 8, 9, 10 )

4) Given F (A,B,C,D) =π ( 3, 4, 6, 7, 11, 12, 13, 14, 15 )

5) Given F(a,b,c,d)= π(1,2,4,5,7,10,15)

6) Given F(a,b,c,d)= ∑(0,7,8,9,10)

7) A passenger is alloted a window seat in an aircraft, if he/she satisfies the criteria given

below:

• The passenger is below 15 years and is accompanied by an adult.

OR

• The passenger is a lady and is not accompanied by an adult.

OR

• The passenger is not below 15 years, but is travelling for the first time.

The inputs are:

A The passenger is below 15 years of age

C The passenger is accompanied by an adult

L The passenger is a lady

F The passenger is travelling for the first time

( In allthe above cases 1 indicates yes and 0 indicates no).

Output: W- Denotes the passenger is alloted a window seat(1 indicates yes and 0 indicates

no). Draw the truth table for the inputs and outputs given above and write the SOP

expression for W(A,C,L,F).

8) A person is allowed to travel in a reserved coach of the train, if he / she satisfies the criteria given below:- •
The person has a valid reservation ticket and a valid ID proof. OR

• The person does not have a valid reservation ticket, but holds a valid pass issued by the Railway department
with a valid ID proof. OR • The person is a disabled person and holds a valid pass issued by the Railway
department along with a valid ID proof.
The inputs are: R The person has a valid reservation ticket P The person holds a valid pass issued by the Railway
department D The person has a valid ID proof H The person is a disabled person ( In all the above cases 1
indicates yes and 0 indicates no ). Output :- T - Denotes allowed to travel ( 1 indicates yes and 0 indicates no in
all the cases)

a) Draw the truth table for the inputs and outputs given above and write the POS

expression for T(R,P,D.H). b) Reduce T(R,P,D,H) using Karnaugh map. Draw the logic gate

diagram for the reduced POS expression for T(R,P,D,H) using NOR gates. You may use

gates with more than 2 inputs. Assume that the variables and their complements are

available as inputs. 9) A school intends to select students for the Inter – school athletic meet, as per the criteria

given below: • The candidate is from the Senior school and has participated in an inter

school athletic meet earlier. OR

• The candidate is not from the Senior School, but the height is between 5 ft. and 6ft.

And weight is between 50 kg and 60 kg.

OR

• The candidate is from the senior school and has height between 5ft. And 6ft., but the

weight is not between 50 and 60 kg.

The inputs are :

S Student is from the senior school

W Weight is between 50 kg and 60 kg

H Height is between 5 ft. And 6 ft.

A Taken part in Inter school athletic meet

OUTPUT:X Denotes the selection criteria [ 1 indicates selected and 0 indicates rejected

in all cases.] a) for X(S,W,H,A).

b) Reduce X(S,W,H,A) using Karnaugh map. Draw the logic gate diagram for the reduced

SOP expression for X(S,W,H,A) using AND and OR gate. You may use gates with two or

more inputs. Assume that the variable and their complements are available as inputs.
Assignment No. 3
BOOLEAN ALGEBRA & COMPUTER HARDWARE

1. Draw the circuit diagram for the given equation using basic logic gates:
a. [(p+q)’+(p’(q+r’))]’+(pq+r’)
b. (A+B+C’)+(A’+B’)’+(A’(B’C’)+A’+C)
c. [( p  q)( q  r ' )( p.q)].r
d. [( p.q)(q  r ')].( p  q  r )
e. p[( q.r ).( p.r )]  r
2. Draw the circuit diagram for the given expression:
(X Y) (X’ Y’) (Y Z)
3. Draw the circuit diagram using universal gates:
[[(A+B)’+(B’.C’)’]’+(A’B’)’]’
4. Draw the circuit diagram using only NAND gate:
a. P’Q’R’+P’(Q+Q’)R+QR+P’
b. A’B’+A’B+B
5. Draw the circuit diagram using only NOR gate:
a. (A+B+C’)(A’A+B+C)(A+BB’+C)
b. (P+Q) R (P+R’)
6. Check Which of the Statements are tautology, contradiction or contingency :-
a. [( p  q)( q  r )]  ( p  r )
b. [( p' q)( q  r )]  ( p' r )
c. ( p & q)  ( p & q)'
d. ( p  q)( p.q )
e. ( p' q)  r  s  (r 'q)
7. Give the output of the diagrams given below: -
1.

2.
3.

4.

5.

8. Simplify the output of the following diagram: -


1.
2.

9. Mention the gate represented by the following circuit diagram and prove it: -
1.

2.

3.

4.

10. Mention the law represented by the following circuit diagram: -


a.
b.

------------------------------ END OF THE ASSIGNMENT 3 ---------------------------------------


Assignment No. 4
BOOLEAN ALGEBRA & COMPUTER HARDWARE

1. Define :
a. Proposition
b. Simple proposition
c. Compound proposition
d. Truth table
e. Truth value
f. Syllogism
g. Premises
h. Well Formed Formulae
i. Logic gate
j. Contingencies
k. Tautologies
l. Contradictions
m. Consistent Statements
n. Converse
o. Inverse.
p. Contrapositive
q. Gate
r. Minterm
s. Maxterm
t. Canonical SOP and POS expression
2. Write a note on operators.
3. Write a note on Basic logic gate.
4. Differentiate between Basic and Universal logic gates.
5. Differentiate between XOR and XNOR gate.
6. Differentiate between NOR and NAND gate.
7. Differentiate between OR, AND and NOT gate.
8. Draw the circuit diagram and prove AND, OR, NAND and NOT using only NOR gate.
9. Draw the circuit diagram and prove AND, OR, NOR and NOT using only NAND gate only.
10. Prove properties of 0 using truth table and draw logic circuit diagram.
11. Prove properties of 1 using truth table and draw logic circuit diagram.
12. Prove Absorption law using truth table and draw logic circuit diagram.
13. Prove Involution law using truth table and draw logic circuit diagram.
14. Prove Idempotence law using truth table and draw logic circuit diagram.
15. Prove Complementarity law using truth table and draw logic circuit diagram.
16. Prove Commutative law using truth table and draw logic circuit diagram.
17. Prove Associative law using truth table and draw logic circuit diagram.
18. Prove Distributive law using truth table and draw logic circuit diagram.
19. Prove De Morgan's law using truth table and draw logic circuit diagram.
20. Prove Conditional elimination law using truth table.
21. Prove Bi-conditional law using truth table.

Computer Science

Assignment – 5

What prefix and postfix expression is equivalent to the following infix expression?

1. infix: (A + B) * C + D / (E + F * G) - H
2. infix: A + ((B - C * D) / E ) + F - G / H
3. infix: (A * B + C) / D - E / (F + G)
4. infix: A - B - C * (D + E / F - G) - H
5. infix: A * B / C + (D + E - (F * (G / H)))
6. infix: A + B / C* ( D / E * F)
7. infix: X+Y (Y-Z) + ((W+E) * F) / J
8. infix: (A/B +C) * (D/(E-F))
9. infix: P*Q/R+(S+T)
10. infix: A + (B – C * (D / E) * F)
(b) Answer the following questions from the diagram of a Binary Tree given below:

(i) Write the Inorder, postorder and preorder traversal of the above tree structure.
(ii) State the height of the tree, if the root is at level 0 (zero).
(iii) List the leaf nodes of the tree.
I) Name the leaf nodes of the right sub tree.

II) Write Inorder,postorder and preorder traversal of the left sub tree of node B including itself.

III) State the level number of nodes R and M when the root is at level 0.

IV) Name the internal and external nodes of the tree.

I) Root of the tree.

II) Left subtree

III) Inorder,postorder and preorder traversal of the tree

IV) Size of the tree


i)Write the inorder ,postorder and preorder tree traversal

ii) Name the leaves of the tree

iii) Height of the tree

iv) Root of the tree and name the internal and external nodes

Computer Science

Assignment – 6

1. A character array B[7][6] has a base address 1046 at 0,0. Calculate the address at B[2][3] if the array is
stored Column Major wise. Each character requires 2 bytes of storage.
2. Each element of an array A[20][10] requires 2 bytes of storage. If the address of A[6][8] is 4000, find the
base address at A[0][0] when the array is stored row major wise.
3. A two dimensional array defined as x[3…6, -2…2] requires 2 bytes of storage space for each element. If
the array is stored in row major order, determine the address of X[5,1], given the base address as 1200.
4. Each element of an array X[-15…10,15…40] requires one byte od storage. If the array is stored in column
major order with the beginning location 1500, determine the location of X[5,20].
5. In an array of real numbers ARR[25][25], ARR[1][1] is stored in location 1000. Find the address of
ARR[12][12] when the array is stored row major wise. Assume each real number requires 4 bytes.
6. An array ARR[10][5] is stored in memory with each element requiring 2 bytes of storage. If the first
element ARR[0][0] is stored at the location 1250, calculate the location of ARR[5][6] when the array is
stored row major wise.
7. A square matrix A[m x m] is stored in the memory with each element requiring 2 bytes of storage. If the
base address A[1][1] is 1098 and the address at A[4][5] is 1144, determine the order of the matrix
A[mxm] when the matrix is stored column majorwise.
8. A matrix B[10][7] is stored in the memory with each element requiring 2 bytes of storage. If the Base
address at B[x][1] is 1012 and the address B[7][3] is 1060, determine the value x where the matrix is
stored in column major wise.
9. A square matrix M[][] of size 10 is stored in the memory with each element requiring 4 bytes of storage.
If the base address at M[0][0] is 1840, determine the address at M[4][8] when the matrix is stored in row
major wise.
10. For an array of real numbers x[-6…8, -12…. 20], find the address of x[5][4] , if x[1][1] is stored in location
100 in the column major order. Assume that each element requires 4 bytes.

11.What is Big O Notation?

12 i) What is the worst-case complexity of the following code segment :


for(int i=0;i<N;i++)

Sequence of statements

for(int j=0;j<M;j++)

Sequence of statements

ii) How would the complexity change if the second loop went to N instead of M?

13. i)Define computational complexity. Calculate the complexity using Big ‘O’ notation for the following code
segment:-

for(int k=0;k<n;k++)

s+=k;

14. i)What is the worst case complexity of the following code segment

For(int x=1;x<=a;x++)

Statement;}

For(int y=1;y<=b;y++)

For (int z=1;z<=c;z++)

Statement;

ii) How would the complexity change if the second loop went to N instead of a,b,c?
Assignment No. 7

CONCEPT OF INHERITANCE

1. A library issues books on a rental basis at a 2% charge on the cost price of the book per day.
As per the rules of the library, a book can be retained for 7 days without any fine. If the book
is returned after 7 days, a fine will also be charged for the excess days as per the

chart given below:

Number of excess days Fine per day

1 to 5 2.00

6 to 10 3.00

Above 10 days 5.00

Design a class Library and another class Compute to perform the task. The details of the

2 classes are given below:

Class name : Library


Data members

name : name of the book

author : author of the book

p : price of the book in decimals

Member functions
Library(…) : parameterized constructor to assign values to data

members.

void show() : display the book details

class name : Compute


Data members

d : number of days taken in returning the book.

f : to store the fine.

Member functions
Compute(…) : parameterized constructor to assign values to data

Members of both classes.


void fine() : calculate the fine for excess days.

void display() : displays the book details along with the number of

days, fine and total amount to be paid. Total amount is

calculated as:

(2% of price of book * total no. of days) + fine

Specify the class Library giving details of the constructors and void show(). Using the
concept of inheritance, specify the class Compute giving details of the constructor, void
fine() and the void display() function. You need not write the main function.

2. A super class Worker has been defined to store the details of a worker. Define a sub class
Wages to compute the monthly wages for the worker. The details of both the classes are

given below:

Class name : Worker


Data members :
Name : to store the name of the worker
Basic

Member functions : to store the basic pay in decimal


Worker(….)

class name : parameterized constructor to assign values to


Data members the instance variables
hrs
rate
void display() : display worker details
wage
: Wages
Member functions
Wages(….)
: stores the hours worked
double overtime( )
: stores rate per hour
void display()
: stores the overall wage of the worker

: parameterized constructor to assign values to


the instance variables of both classes

: calculates and returns the overtime amount as


(hours * rate )

: calculates the wage using the formula


wage=overtime amount +basic pay and
displays it along with other details

Specify the class Worker giving details of the constructor() and void display(). Using the
concept of inheritance, specify the class Wages giving details of the constructor(),
double overtime()and void display(). The main function need not be written.

3. A super class Record has been defined to store the names and ranks of 50 students.
Define a sub class Rank to find the highest rank along with the name. The details of both
classes are given below:

Class name : Record


Data members
name[] : to store the names of students

rnk[] : to store the ranks of students

Member functions:
Record() : constructor to initialize data members

void readvalues() : to store names and ranks

void display() : displays the names and the corresponding ranks

class name : Rank


Data members

index : integer to store the index of the topmost rank

Member functions
Rank() : constructor to invoke the base class constructor and to

initialize index to 0.

void highest() : finds the index location of the topmost rank and stores

it in index without sorting the array


void display() : displays the name and ranks along with the name

having the topmost rank.

Specify the class Record giving details of the constructor(), void readvalues(), void
display(). Using the concept of inheritance, specify the class Rank giving details of
constructor(), void highest() and void display(). The main function and algorithm
need not be written.

4. A super class Record has been defined to store the names and ranks of 50 students.
Define a sub class Rank to find the highest rank along with the name. The details of both
classes are given below:

Class name : Record


Data members

name[] : to store the names of students

rnk[] : to store the ranks of students

Member functions:
Record() : constructor to initialize data members

void readvalues() : to store names and ranks

void display() : displays the names and the corresponding ranks

class name : Rank


Data members

index : integer to store the index of the topmost rank

Member functions
Rank() : constructor to invoke the base class constructor and to

initialize index to 0.

void highest() : finds the index location of the topmost rank and stores
it in index without sorting the array

void display() : displays the name and ranks along with the name

having the topmost rank.

Specify the class Record giving details of the constructor(), void readvalues(), void
display(). Using the concept of inheritance, specify the class Rank giving details of
constructor(), void highest() and void display(). The main function and algorithm
need not be written

5. A super class Perimeter has been defined to calculate the perimeter of a parallelogram.
Define a sub class Area to compute the area of the parallelogram by using the required

data members of the super class. The details are given below:

Class name : Perimeter


Data Members

a : to store the length in decimal

b : to store the breadth in decimal

Member functions:
Perimeter(…) : parameterized constructor to assign values to data

Members

double Calculate() : calculate and return the perimeter of a

parallelogram as 2 *(length +breadth)


void show() : to display the data members along with the

perimeter of the parallelogram.

Class name : Area


Data Members

h : to store the height in decimal

b : to store the area of the parallologram

Member functions:
Area(…) : parameterized constructor to assign values to data

Members of both classes.

void doarea() : computes the area( breadth * height)

void show() : to display the data members of both the classes

along with the area and perimeter of the

parallelogram.

Specify the class Perimeter giving details of the constructor(…), double Calculate() and
void show(). Using the concept of inheritance, specify the class Area giving details of
he constructor(…), void doarea() and void show(). The main function and algorithm
need not be written.

6. A super class Stock has been defined to store the details of the stock of a retail store.
Define a subclass Purchase to store the details of the items purchased with the new rate
and updates the stock. Some of the members of the classes are given below:

Class name : Stock


Data members:

item : to store the name of the item

qty : to store the quantity of an item in stock

rate : to store the unit price of an item

amt : to store the net value of the item in stock

Member functions:
Stock(......) : parameterized constructor to assign values to the data

members
void display() : to display the stock details

Class name : Purchase


Data members

pqty : to store the purchased quantity

prate : to store the unit price of the purchased item

Member functions
Purchase(.....) : parameterized constructor to assign values to the data

members of both classes

void update() : to update stock by adding the previous quantity by the


purchased quantity and replace the rate of item if there

is a difference in the purchase rate of the item if there

is a difference in the purchase rate. Also update the

current stock value as: (quantity * unit price)

void display() : to display the stock details before and updation


Specify the class Stock, giving details of the constructor() and void display(). Using
concept of inheritance, specify the class Purchase, giving details of the constructor(),
void update() and void display(). The main function and algorithm need not be written

7.

You might also like