Sie sind auf Seite 1von 20

MODEL TEST-2 facebook.com/pumpkin.

buet
Digital Logic Design

1. Prove that NAND GATE and NOR GATE is universal gate

Realization of Basic logic Gates using NAND:

Realization of Basic logic Gates using NOR:

2. Convert the following logic diagram into NAND gates only.

Ans:

Page 1 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet
A

B Q

3. You are to design a circuit that takes a 4-bit number as input (I8, I4, I2, I1) and generates
an output which is 1 if the input number is one of the prime numbers between 0 and 15
inclusive. You may assume that the input is never 0, 1, or 2. The most significant bit of the
input is I8. Derive the truth table, boolean expression, then use K-Map to simlify it and
finally draw the final circuit

Ans:

4. Implement a 4 to 16 decoder using only 2 to 4 decoder

Page 2 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet

5. Simplify the followings using Boolean algebra:

Page 3 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet

Page 4 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet
Computer Network

1. Your company has been given the IP Address of 199.2.1.0 /24 to subnet. You
plan to put each of the 5 floors in your building on its own subnet. What is
the IP range of the LAST available network once you subnet.

Ans:

199.2.1.224 - 199.2.1.255

199.2.1.0 need 5 networks 128 64 32 16 8 4 2 10 0 0 0 0 0 1 0 1 = 5 in binaryneed to borrow 3


bits for of networksnew subnet mask = 255.255.255.11100000 (224) or /27^ increment =
322^3 = of networks = 82^5-2 = of hosts per network = 30all 8 ip ranges 199.2.1.0 - 199.2.1.31
1.32 1.63 1.64 1.95 1.96 1.127 1.128 1.159 1.160 1.191 1.192 1.223 1.224 1.255

2. What is the difference between TCP and UDP?

Key Differences between TCP and UDP

3. TCP stands for “Transmission Control Protocol” while UDP stands for “User datagram
Protocol”.
4. TCP is connection oriented protocol while UDP is connectionless protocol.
5. TCP is more reliable than UDP.
6. UDP is more faster for data sending than TCP.
7. UDP makes error checking but no reporting but TCP makes checks for errors and reporting.
8. TCP gives guarantee that the order of data at receiving end is same as on sending end
while UDP has no such guarantee.
9. Header size of TCP is 20 bytes while that of UDP is 8 bytes.
10. TCP is heavy weight as it needs three packets to setup a connection while UDP is light weight.
11. TCP has acknowledgement segments but UDP has no acknowledgement.
12. TCP is used for application that require high reliability but less time critical whereas UDP is
used for application that are time sensitive but require less reliability.

3. Write the advantage and disadvantage of star and bus topology

Ans:

Advantages of Bus Topology

1. It is cost effective.
2. Cable required is least compared to other network topology.
3. Used in small networks.
4. It is easy to understand.
5. Easy to expand joining two cables together.

Page 5 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet
Disadvantages of Bus Topology

1. Cables fails then whole network fails.


2. If network traffic is heavy or nodes are more the performance of the network
decreases.
3. Cable has a limited length.
4. It is slower than the ring topology.
Advantages of Star Topology

1. Fast performance with few nodes and low network traffic.


2. Hub can be upgraded easily.
3. Easy to troubleshoot.
4. Easy to setup and modify.
5. Only that node is affected which has failed, rest of the nodes can work smoothly.

Disadvantages of Star Topology

1. Cost of installation is high.


2. Expensive to use.
3. If the hub fails then the whole network is stopped because all the nodes
depend on the hub.
4. Performance is based on the hub that is it depends on its capacity

4. What is cell switching? What is the difference between circuit switching and packet switching?

Cell switching operates in a similar way to packet switching but uses small fixed length cells
for data transport. This technology is found within cell based integrated networks such as
Asynchronous Transfer Mode (ATM) networks. Cell switching can handle multiple data types,
i.e. voice, video and data

Circuit Switching Packet Switching(Datagram type)


Dedicated path No Dedicated path
Path is established for entire conversation Route is established for each packet
Call setup delay packet transmission delay
Overload may block call setup Overload increases packet delay
Fixed bandwidth Dynamic bandwidth
No overhead bits after call setup overhead bits in each packet

5. What are 10Base2, 10Base5 and 10BaseT Ethernet LANs ? Explain Collision Domain and
broadcast domain

Page 6 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet
10Base2—An Ethernet term meaning a maximum transfer rate of 10 Megabits per second
that uses baseband signaling, with a contiguous cable segment length of 100 meters and a
maximum of 2 segments.
10Base5—An Ethernet term meaning a maximum transfer rate of 10 Megabits per second
that uses baseband signaling, with 5 continuous segments not exceeding 100 meters per
segment.
10BaseT—An Ethernet term meaning a maximum transfer rate of 10 Megabits per second
that uses baseband signaling and twisted pair cabling.
Collision Domain:
A collision occurs when two devices send a packet at the same time on the shared network
segment. The packets collide and both devices must send the packets again, which reduces
network efficiency. Collisions are often in a hub environment, because each port on a hub is
in the same collision domain. By contrast, each port on a bridge, a switch or a router is in a
separate collision domain.
remember, each port on a hub is in the same collision domain. Each port on a bridge, a
switch or router is in a seperate collision domain.

A broadcast domain is a domain in which a broadcast is forwarded. A broadcast domain


contains all devices that can reach each other at the data link layer (OSI layer 2) by using
broadcast. All ports on a hub or a switch are by default in the same broadcast domain. All
ports on a router are in the different broadcast domains and routers don’t forward broadcasts
from one broadcast domain to another.
Remember all ports on a hub or a switch are in the same broadcast domain, and all ports on a
router are in a different broadcast domain.

Data Structure & Algorithm

1. Find the Time complexity of the following


program
for (int i = 1; i <=m; i += c) {
// some O(1) expressions
}
for (int i = 1; i <=n; i += c) {
// some O(1) expressions
}
Ans:

Page 7 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet

Time complexity of above code is O(m) + O(n) which is O(m+n)


If m == n, the time complexity becomes O(2n) which is O(n).

2. Insert “-2” into the following heap. Show each operation and also show the array condition
in each step.

3. Write a pseudo code for deleting a front/first node from doubly linked list. Also show the pictorial
view.

Ans: See the lecture sheet

4. Explain asymptotic lower bound, upper bound and tight bound.

O() - ("Big O")


As discussed in the previous lecture, often we are most concerned about the worst case
behavior of an algorithm. Thus we define an asymptotic upper bound (although not
necessarily tight) for a function f(n) denoted O() as follows: Given two functions f(n) and g(n)

Page 8 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet

Thus O() describes how bad our algorithm can grow, i.e. is no worse than. Note: Often it is
enough to find a loose upper bound to show that a given algorithm is better than (or at least no
worse than) another.

Ω() - ("Big Omega")


We can similarly define an asymptotic lower bound (again not necessarily tight and often not
particularly useful) for a function f(n) denoted Ω() as follows: Given two functions f(n) and
g(n)

Thus Ω() describes how good our algorithm can be, i.e. is no better than. For this bound to be
meaningful, it is often best to find a tight lower bound.

Θ() - ("Big Theta")


Finally we can define an asymptotically tight bound for a function f(n) denoted Θ() as follows:
Given two functions f(n) and g(n) both asymptotically non-negative

This notation indicates that g(n) is both a lower bound (best case) and upper bound (worst
case) for f(n), thus the algorithm has a consistent growth independent of the particular input
set.

5.Write an algorithm for binary search

binary_search()
{
A ← sorted array
n ← size of array
x ← value to be searched

Set lowerBound = 1
Set upperBound = n

while x not found


if upperBound < lowerBound
EXIT: x does not exists.

set midPoint = lowerBound + ( upperBound - lowerBound ) / 2

Page 9 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet
if A[midPoint] < x
set lowerBound = midPoint + 1

if A[midPoint] > x
set upperBound = midPoint - 1

if A[midPoint] = x
EXIT: x found at location midPoint

end while
}

Database

1. Explain full outer join and natural inner join? What is the difference between left and right
outer join?

A full outer join will return rows from both tables even if there are no matching rows in the other
table. A full join is like a right join and a left join at the same time.
An inner join will only return rows which have at least 1 partner in the other table. It Returns only
matched rows. Therefore, unmatched rows are not included.

LEFT JOIN or LEFT OUTER JOIN: The result set of a Left Outer Join includes all the rows from the left
table specified in the LEFT OUTER clause, not just the ones in which the joined columns match. When
a row in the left table has no matching rows in the right table, the associated result set row contains
null values for all select list columns coming from the right table.

RIGHT JOIN or RIGHT OUTER JOIN: A Right Outer Join is the reverse of a Left Outer Join. All rows from
the right table are returned. Null values are returned for the left table any time a right table row has
no matching row in the left table.

2. Instructor(ID, Name,dept_name,Salary)
Section (Course_id,sec_id,semester,year,building,room_no,time_slot)
Takes(stu_id,course_id,regi_date,payment)
a. Write SQL to find a. the enrollment of each section that was offered in Autmn 2009. b. Find
the maximum enrollment across all section in Spring 2010. C. Find all instructor earnings the
highest salary (There may be more than one with same salary)

Page 10 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet
a.

b.

c.

3. Salesperson(ID,Name, Age, Salary)


Customer(ID, Name, City, Industry Type)
Orders(Number,order_date, cust_id,salesperson_id,Amount)
Given the tables above, find the following:
a. The names of all salespeople that have an order with Samsonic.
b. The names of all salespeople that do not have any order with Samsonic.
c. The names of salespeople that have 2 or more orders.

a.
select Salesperson.Name from Salesperson where
Salesperson.ID = '{select Orders.salesperson_id from Orders,
Customer where Orders.cust_id = Customer.id
and Customer.name = 'Samsonic'}'
b.
select Salesperson.Name from Salesperson
where Salesperson.ID NOT IN(
select Orders.salesperson_id from Orders, Customer
where Orders.cust_id = Customer.ID
and Customer.Name = 'Samsonic')
c.
SELECT name
FROM Orders, Salesperson
WHERE Orders.salesperson_id = Salesperson.id
GROUP BY name, salesperson_id
HAVING COUNT( salesperson_id ) >1

4. What is dbms transaction? Explain ACID property in DBMS. 10

A transaction is a sequence of operations performed as a single logical unit of work. A logical unit of

Page 11 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet
work must exhibit four properties, called the atomicity, consistency, isolation, and durability (ACID)
properties, to qualify as a transaction.

Atomicity. In a transaction involving two or more discrete pieces of information, either all of
the pieces are committed or none are.

Consistency. A transaction either creates a new and valid state of data, or, if any failure
occurs, returns all data to its state before the transaction was started.

Isolation. A transaction in process and not yet committed must remain isolated from any other
transaction.

Durability. Committed data is saved by the system such that, even in the event of a failure
and system restart, the data is available in its correct state.

5. Suppose you are given the following requirements for a simple database for the
National Hockey League (NHL):

 the NHL has many teams,


 each team has a name, a city, a coach, a captain, and a set of players,
 each player belongs to only one team,
 each player has a name, a position (such as left wing or goalie), a skill level, and a
set of injury records,
 a team captain is also a player,
 a game is played between two teams (referred to as host_team and guest_team) and has
a date (such as May 11th, 1999) and a score (such as 4 to 2).

Construct a clean and concise ER diagram for the NHL database.

Answer :

Page 12 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet

Operating System

1. Distinguish between process and thread. What is Process control block (PCB)?
Describe the actions taken by a kernel to switch context between processes.

Ans:
The major differences between threads and processes are:
1. Threads share the address space of the process that created it; processes have their own
address space.
2. Threads have direct access to the data segment of its process; processes have their own
copy of the data segment of the parent process.
3. Threads can directly communicate with other threads of its process; processes must use
interprocess communication to communicate with sibling processes.
4. Threads have almost no overhead; processes have considerable overhead.
5. New threads are easily created; new processes require duplication of the parent
process.
PCB serves as the repository for any information that may vary from process to process.

The operating system must save the state of the currently running process and restore the
state of the process scheduled to be run next . Saving the state of a process typically includes
the values of all the CPU registers in addition to memory allocation. Context switches must
also perform many architecture- specific operations, including flushing data and instruction
caches.

2. What is page fault and when does it occurs? Describe the action taken by operating
system when page fault occurs.

A page fault is a trap to the software raised by the hardware when a program accesses a page that is
mapped in the virtual address space, but not loaded in physical memory. When the page (data)
requested by a program is not available in the memory, it is called as a page fault. This usually results
in the application being shut down.

A page is a fixed length memory block used as a transferring unit between physical memory
and an external storage. A page fault occurs when a program accesses a page that has been
mapped in address space, but has not been loaded in the physical memory.

Page 13 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet

3. What are the Advantages and disadvantages of having small page size in paging system?
Consider a logical address space of 64 pages of 1024 words each, mapped onto a
physical memory of 32 frames. a. How many bits are there in the logical address? b.
How many bits are there in the physical address?

Answer:

a. Logical address: 16 bits


b. Physical address: 15 bits

Page 14 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet
4. Explain the difference between preemptive and nonpreemptive schedul-ing.

Draw the gantt chart for SJF preemptive and calculate the average turn around time.

Answer:
Preemptive scheduling allows a process to be interrupted in the midst of its execution,
taking the CPU away and allocating it to another process. Nonpreemptive scheduling
ensures that a process relinquishes control of the CPU only when it finishes with its
current CPU burst.

5. What is deadlock and race condition? How deadlock can be prevented?


Ans:
A deadlock is a situation in which two computer programs sharing the same resource are effectively
preventing each other from accessing the resource, resulting in both programs ceasing to function.

Page 15 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet
 Race condition: The situation where several processes access – and manipulate shared
data concurrently. The final value of the shared data depends upon which process
finishes last.
 To prevent race conditions, concurrent processes must be synchronized.

Deadlock Prevention:
Restrain the ways request can be made.
 Mutual Exclusion – not required for sharable resources; must hold for non-sharable
resources.
 Hold and Wait – must guarantee that whenever a process requests a resource, it does
not hold any other resources.
 Require process to request and be allocated all its resources before it begins
execution, or allow process to request resources only when the process has
none.
 Low resource utilization; starvation possible.
 No Preemption –
 If a process that is holding some resources requests another resource that
cannot be immediately allocated to it, then all resources currently being held
are released.
 Preempted resources are added to the list of resources for which the process is
waiting.
 Process will be restarted only when it can regain its old resources, as well as
the new ones that it is requesting.
 Circular Wait – impose a total ordering of all resource types, and require that each
process requests resources in an increasing order of enumeration.

Programming Language

1. Write the output of the following program segments


void main ( ) int main() int a = 5, c;
{ char grade =
{ int n; 'B'; c = a;
for(n = 7; n!=0; n- printf("c =
char *P = "ayq -) switch(grade) %d \n", c);
m" ; printf("n = %d", {
n--); case 'A' : c += a; //
char c; getchar(); c = c+a
return 0; printf("Excellent printf("c =
c = ++*p ; } !\n" ); %d \n", c);
break;
printf ("%c", Output: case 'B' : c -= a; //

Page 16 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet
c); Above program goes in infinite case 'C' : c = c-a
loop because n is never zero printf("c =
} printf("Well %d \n", c);
when loop condition (n != 0) is done\n" );
Output: checked. case 'D' : c *= a; //
c = c*a
a printf("You printf("c =
passed\n" ); %d \n", c);
break;
case 'F' : c /= a; //
c = c/a
printf("Better printf("c =
try again\n" ); %d \n", c);
break;
default : c %= a; //
c = c%a
printf("Invalid printf("c =
grade\n" ); %d \n", c);
}
Output:
printf("Your
grade is %c\n", c = 5
grade ); c = 10
Output: c = 5
Well done c = 25
You passed c = 5
Your grade is B c = 0

2. What will be the output of the following program segment?


class Base
{
int w,x,y,z;
public: x=30;
y=40;
Base ( )
{ w=20;
cout << "Inside Base constructor" z=(w>x )?((w>y )?w:y ):((x>y
<< endl; )?x:y);
}

printf("\n %d ",z);
~Base ( )
{ Output:
cout << "Inside Base destructor" 40
<< endl;
}

};

class Derived : public Base


{

public:

Derived ( )
{
cout << "Inside Derived

Page 17 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet
constructor" << endl;
}

~Derived ( )
{
cout << "Inside Derived
destructor" << endl;
}

};

void main( )
{
Derived x;
}

Output:
Inside Base constructor
Inside Derived constructor
Inside Derived destructor
Inside Base destructor

3. Program to Swap two Numbers without using Third variable


#include<stdio.h>
#include<conio.h>

void main()
{
int x=10, y=15;
x = x+y-(y=x);
printf("x= %d and y= %d",x,y);
getch();
}

4. Write a program to sort an array using bubble sort algorithm.


5.
6. int main()
7. {
8. int array[100], n, c, d, swap;
9.
10. printf("Enter number of elements\n");
11. scanf("%d", &n);
12.
13. printf("Enter %d integers\n", n);
14.
15. for (c = 0; c < n; c++)
16. scanf("%d", &array[c]);
17.
18. for (c = 0 ; c < ( n - 1 ); c++)
19. {
20. for (d = 0 ; d < n - c - 1; d++)
21. {
22. if (array[d] > array[d+1]) /* For decreasing order use
< */
23. {

Page 18 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet
24. swap = array[d];
25. array[d] = array[d+1];
26. array[d+1] = swap;
27. }
28. }
29. }
30.
31. printf("Sorted list in ascending order:\n");
32.
33. for ( c = 0 ; c < n ; c++ )
34. printf("%d\n", array[c]);
35.
36. return 0;
37. }

5.Explain different type of access specifier in c++ with example.

Types of access specifiers in C++


1. public
2. private
3. protected

Public Specifier
Public class members and functions can be used from outside of a class by any function or
other classes. You can access public data members or function directly by using dot operator
(.) or (arrow operator-> with pointers).

Protected Specifier
Protected class members and functions can be used inside its class. Protected members and
functions cannot be accessed from other classes directly. Additionally protected access
specifier allows friend functions and classes to access these data members and functions.
Protected data members and functions can be used by the class derived from this class.

Private Specifier
Private class members and functions can be used only inside of class and by friend functions
and classes.

We can modify Person class by adding data members and function with different access
specifiers:

class Person
{
public://access control
string firstName;//these data members
string lastName;//can be accessed
tm dateOfBirth;//from anywhere
protected:

Page 19 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet
string phoneNumber;//these members can be accessed inside this
class,
int salary;// by friend functions/classes and derived classes
private:
string addres;//these members can be accessed inside the class
long int insuranceNumber;//and by friend classes/functions
};

Page 20 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538

Das könnte Ihnen auch gefallen