Beruflich Dokumente
Kultur Dokumente
buet
Digital Logic Design
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:
Page 2 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet
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
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.
Ans:
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
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
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.
Page 7 of 20
khan.mamun.buet@gmail.com Phone: +88 01884530538
MODEL TEST-2 facebook.com/pumpkin.buet
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.
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.
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.
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.
binary_search()
{
A ← sorted array
n ← size of array
x ← value to be searched
Set lowerBound = 1
Set upperBound = n
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.
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
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):
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:
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.
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
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
printf("\n %d ",z);
~Base ( )
{ Output:
cout << "Inside Base destructor" 40
<< endl;
}
};
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
void main()
{
int x=10, y=15;
x = x+y-(y=x);
printf("x= %d and y= %d",x,y);
getch();
}
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. }
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