CSE357 WorKsheets
CSE357 WorKsheets
Worksheet 1
1. Which of the following statements about the kernel in an operating system is true?
A. The kernel is responsible for managing user interfaces and applications.
B. The kernel is a separate program that runs only when the user interacts with the system.
C. The kernel is the core component that manages hardware resources and provides essential services.
D. The kernel is primarily responsible for handling user-level processes and multitasking.
2. What is the primary purpose of an operating system?
A. Managing hardware resources
B. Running user applications
C. Providing a graphical user interface
D. All of the above
3. Which of the following is not a function of the operating system?
A. Process management
B. File management
C. Application development
D. Memory management
4. What does a system call provide in an operating system?
A. User interface
B. A way for programs to request services from the operating system
C. Hardware resources
D. File management
5. Which component of the operating system handles communication between hardware and software?
A. Scheduler
B. Kernel
C. File Manager
D. Shell
6. What is the significance of the bootstrap program in the boot process of an operating system?
A. Manages user interfaces
B. Loads the kernel into memory
C. Allocates memory to applications
D. Handles peripheral devices
7. What does the fork system call do in an operating system?
A. Allocates memory for a new process
B. Creates a new process by duplicating the calling process
C. Terminates the calling process
D. Reads data from a file
8. What is the return value of the fork system call in the parent process?
A. -1
B. 0
C. Process ID (PID) of the child process
D. Process ID (PID) of the parent process
9. In the context of operating systems, which statement accurately describes a characteristic of microkernels?
A. Microkernels generally have a larger kernel size compared to monolithic kernels.
B. Microkernels move most of the operating system services into kernel space.
C. Microkernels provide higher performance due to reduced inter-process communication.
D. Microkernels emphasize minimalism, with essential services implemented as user-level processes.
10. What is the primary goal of multiprogramming in operating systems?
A. To improve the performance of a single program
B. To execute multiple programs concurrently for better CPU utilization
C. To simplify the user interface
D. To reduce the size of the operating system
Subjective Questions
1. Compare and contrast the characteristics of real-time operating systems (RTOS) and general-purpose operating
systems.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Discuss the differences between microkernels and monolithic kernels. Evaluate the strengths and weaknesses of
each architecture and provide examples of operating systems that use each type of kernel.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Describe the booting process of an operating system. Include the role of the bootloader and the initialization of
the kernel.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Explain the role of device drivers in an operating system and how they facilitate communication between software
and hardware.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Describe the purpose and functionality of system calls in an operating system. Provide examples of common
system calls.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Explain the concept of interrupts in the context of computer systems.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
Worksheet 2
Subjective Questions
1. Explain the concept of a process in operating systems. Highlight the key components of a process and the role
they play in program execution.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Describe the life cycle of a process. Discuss the transitions between different states and the events triggering
these transitions.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Compare and contrast preemptive and non-preemptive CPU scheduling algorithms. Provide examples of sce-
narios where each type of algorithm is beneficial.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Define the term ”thread” in the context of multitasking. Explain the advantages of using threads over processes
and how they contribute to parallelism.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Explain the difference between user-level threads (ULTs) and kernel-level threads (KLTs). Discuss the advan-
tages and disadvantages of each type and scenarios where they are most suitable.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Consider a system with three processes scheduled using the Round Robin (RR) scheduling algorithm. The time
quantum is set to 4 milliseconds. The arrival time and burst time for each process are as follows:
Subjective Questions
1. Explain the concept of synchronization in operating systems. Why is it essential for concurrent program execu-
tion, and what challenges does it address?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Define the critical section problem and explain why it is a fundamental concern in concurrent programming.
Describe the requirements that a solution to the critical section problem must satisfy.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Define deadlock in the context of operating systems. Discuss the necessary conditions for deadlock occurrence
and how they contribute to the formation of a deadlock.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Explain the difference between deadlock prevention and deadlock avoidance strategies.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. A system has three processes with the following burst times (in milliseconds) and priorities:
Assuming Priority scheduling algorithm, calculate the average waiting time and average turnaround time.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Consider a system with five processes (P 1, P 2, P 3, P 4, and P 5) and three resource types (A, B, and C). The
current allocation matrix, maximum demand matrix, and available matrix are given as follows:
Current Allocation Matrix:
A B C
P1 1 2 2
P2 3 1 3
P3 1 3 5
P4 4 2 2
P5 2 4 2
Maximum Demand Matrix:
A B C
P1 3 4 3
P2 6 2 5
P3 3 6 8
P4 7 4 7
P5 5 8 3
Available Matrix: [ ]
A B C
2 1 3
Using Banker’s algorithm, determine if the system is in a safe state. If it is, provide a safe sequence; otherwise,
explain why the system is not safe.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
Worksheet 4
Subjective Questions
1. Explain the working principles of the Least Recently Used (LRU) page replacement algorithm. Discuss its
advantages and potential drawbacks. Can you suggest scenarios where LRU might perform exceptionally well
or poorly?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Explain the structure of a disk in detail, including the terms like tracks, sectors, and cylinders. How do these
components contribute to efficient data storage and retrieval on a disk?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Discuss the advantages and disadvantages of disk partitioning in terms of organization and performance. How
does partitioning contribute to disk management and data security in an operating system?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Consider the following scenario:
Page Reference String: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
Number of Page Frames: 3
Use the Least Recently Used (LRU) page replacement algorithm to calculate the number of page faults.
LRU Page Replacement Algorithm:
Initially, all page frames are empty.
When a page is referenced:
If the page is already in a frame, it becomes the most recently used.
If the page is not in any frame, a page fault occurs, and the least recently used page is replaced.
Question:
Calculate the number of page faults using the LRU page replacement algorithm for the given page reference
string and a total of 3 page frames.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Provide an overview of what RAID is and describe at least three common RAID levels (e.g., RAID 0, RAID 1,
RAID 5).
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3.10 Frequently Asked Interview Questions
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Consider a disk with 100 tracks numbered from 0 to 99. The current position of the disk arm is at track 50. The
following disk access requests are given:
Assuming the SSTF (Shortest Seek Time First) disk scheduling algorithm, calculate the total head movement
using the current disk arm position.
Solution Steps:
(a). Calculate the absolute seek time for each request by finding the absolute difference between the current
position and the requested track.
(b). Select the request with the shortest seek time and move the disk arm to that track.
(c). Repeat steps 1 and 2 until all requests are processed, and calculate the total head movement.
Provide the final total head movement as the answer.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
16
3.10 Frequently Asked Interview Questions
NETWORK WORKSHEET
Multiple Choice Questions Worksheet 1
1. 1. How many bits are in an IPv4 and IPv6 address?
A. 32 and 64 bits
B. 64 and 32 bits
C. 32 and 128 bits
D. 32 and 256 bits
2. What is the primary purpose of a computer network?
A. To enhance computer aesthetics
B. To facilitate communication and resource sharing
C. To replace standalone computers
D. To generate electricity
3. What is the OSI model used for in computer networks?
A. To design computer hardware
B. To standardize network protocols and communication
C. To analyze data signals
D. To create computer games
4. Which of the following is a network topology where each device is connected to a central hub?
A. Mesh
B. Bus
C. Star
D. Ring
5. What is the purpose of a router in a computer network?
A. To connect devices within the same local area network (LAN)
B. To connect different networks and manage data traffic between them
C. To display network statistics
D. To provide power to network devices
6. In digital communication, what is a bit?
A. A group of bytes
B. A binary digit, representing 0 or 1
C. A unit of time
D. A type of cable
7. Which modulation technique is commonly used in wireless communication?
A. Amplitude Modulation (AM)
B. Frequency Modulation (FM)
C. Binary Modulation (BM)
D. Phase Modulation (PM)
8. What is the purpose of a firewall in a computer network?
A. To protect against unauthorized access and malicious activities
B. To enhance network speed
C. To create a physical barrier between devices
17
D. To filter internet content 2.14 Worksheets
18
2.14 Worksheets
9. Which network type is characterized by limited geographical coverage, such as within a single building or cam-
pus?
A. Local Area Network (LAN)
B. Wide Area Network (WAN)
C. Metropolitan Area Network (MAN)
D. Personal Area Network (PAN)
10. What is the purpose of DNS (Domain Name System) in computer networks?
A. To encrypt data transmissions
B. To convert domain names to IP addresses
C. To manage network hardware
D. To monitor network performance
Subjective Questions
1. Explain the importance of the OSI model in the context of computer networks
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Compare and contrast the star and mesh network topologies, highlighting their advantages and disadvantages.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Describe the role of a router in a computer network and how it contributes to efficient data transmission.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
19
2.14 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Discuss the key functions of a firewall in ensuring network security.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Explain the concept of DNS (Domain Name System) and its significance in simplifying internet communication.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Differentiate between analog and digital signals, providing examples of each and discussing their applications
in communication systems.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
20
2.14 Worksheets
....................................................................................................
21
2.14 Worksheets
Worksheet 2
22
2.14 Worksheets
Subjective Questions
1. Explain the advantages and disadvantages of a star topology in computer networks.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Discuss the characteristics of a bus topology and elaborate on its suitability for specific network environments.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Compare and contrast the OSI model and the TCP/IP model, highlighting their similarities and differences.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
23
2.14 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Describe the role of the TCP (Transmission Control Protocol) in ensuring reliable communication within the
TCP/IP protocol suite.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Discuss the importance of the transmission medium in network communication, focusing on the differences
between wired and wireless transmission.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Explain the role of protocols in computer networks, providing examples and discussing their significance in
facilitating communication between devices.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
24
2.14 Worksheets
....................................................................................................
25
2.14 Worksheets
Worksheet 3
26
2.14 Worksheets
A. ICMP
B. DHCP
C. TCP
D. DNS
10: What is the primary advantage of the TCP/IP model over the OSI model in practical implementations?
A. Simplicity and widespread adoption
B. Robust security features
C. Better error detection mechanisms
D. Real-time data processing capabilities
Subjective Questions
1. Explain the key differences between the OSI model and the TCP/IP model, emphasizing their structures and
functionalities.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Describe the role of the Application Layer in the TCP/IP model, providing examples of protocols and applications
associated with this layer.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Discuss the functions of the Transport Layer in the TCP/IP model and how it ensures reliable communication
between devices.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
27
2.14 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Explain the significance of the Presentation Layer in the OSI model and its role in data exchange between different
systems.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Describe the working of the Internet Control Message Protocol (ICMP) and its role in the TCP/IP model.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Discuss the importance of the Dynamic Host Configuration Protocol (DHCP) in the context of the TCP/IP model
and network configuration.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
28
2.14 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
29
2.14 Worksheets
Worksheet 4
30
2.14 Worksheets
Subjective Questions
1. Explain the concept of subnetting and its advantages in managing large computer networks.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Describe the role of a subnet mask in IP addressing and how it influences the division of network and host
portions.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Discuss the functions of a router in a computer network, emphasizing its role in forwarding data packets between
different networks.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
31
2.14 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Compare and contrast distance-vector routing and link-state routing algorithms, highlighting their characteristics
and applications.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Explain the significance of a default gateway in a computer network and its role in facilitating communication
between networks.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Describe the benefits and challenges associated with Variable Length Subnet Masking (VLSM) in subnetting.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
32
2.14 Worksheets
....................................................................................................
33
2.14 Worksheets
Worksheet 5
34
2.14 Worksheets
A. HTTP
B. SMTP
C. POP
D. IMAP
10: What is the primary function of the DHCP (Dynamic Host Configuration Protocol) in a network?
A. Translating domain names to IP addresses
B. Assigning IP addresses dynamically to devices
C. Transferring files between clients and servers
D. Filtering web content
Subjective Questions
1. Explain the roles of SMTP, POP, and IMAP in the process of sending and receiving emails.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Describe the functions of DNS and how it contributes to the efficient functioning of the internet.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Discuss the key features and use cases of the FTP (File Transfer Protocol) in network communication.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
35
2.14 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Explain the purpose of DHCP and how it simplifies the management of IP addresses in a network.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Compare and contrast HTTP and FTP, highlighting their respective roles in web communication and file transfer.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Discuss the significance of DNS in the context of internet security and privacy.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
7. Describe the process of email retrieval using POP and IMAP, highlighting their differences and advantages.
....................................................................................................
36
2.14 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
8. Explain how DHCP dynamically assigns IP addresses to devices in a network and its role in preventing IP
conflicts.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
37
3.11 Worksheets
DBMS WORKSHEET
3.7 Worksheets
Worksheet 1
A. Data
B. Fields
C. Redundancy
D. Database
8. In addition to removing undesirable characteristics, normalization also eliminates anomalies.
A. Insert
B. Update
C. Delete
D. All of the above
9. To access the contents of the database,
A. Single B. Two
38
userperforms
transactions. 3.11 Worksheets
39
3.11 Worksheets
C. Three
D. Multiple
10. A common approach to normalization is to thelargertableintosmallertablesandlinkthemtogetherbyusingrelationships.
A. Add
B. Subtract
C. Multiply
D. Divide
Subjective Questions
1. Define SQL?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. List out the Numeric Data and character Data Types in MySQL?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. List out the commands under DML and their syntax.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
40
3.11 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
4. Based on the given table “SALE” answer the question (i) and (ii)
(i) Can we take QTY column of the above table as Primary Key? If no give reason?
(ii) Which column is best suitable for applying Primary Key?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. What is referential Integrity? How it is implemented in any table?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Table T1 contains 10 Rows and 4 Columns; Table T2 contains 20 Rows and 3 Columns. After performing
Cartesian product of T1 and T2, what will be the degree and cardinality of Resultant output?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
41
3.11 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
42
3.11 Worksheets
Worksheet 2
A. Read
B. Write
C. Commit
D. Rollback
8: In practical applications, how many types of Normal Forms are there?
A. 3
B. 4
C. 5
D. 6
9: In DBMS –
A. There is no relation between the tables
43
3.11 Worksheets
Subjective Questions
1. Write any 2 characteristics of a Relation.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. What is alternate Key?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. From the following Tables: Table 3.2 (EMP) AND Table 3.3 (JOB) answer the questions
44
3.11 Worksheets
4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Mr. Peter created a table in MySQL. later on, he found that there should have been another column in the table.
Which command should he use to add another column to the table.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
45
3.11 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Give 1 example for aggregate functions (count, max, min, sum).
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
46
3.11 Worksheets
Worksheet 3
47
3.11 Worksheets
Subjective Questions
1. Observe the following table and answer the questions TABLE 3.5 VISITOR and answer the question (i) , (ii)
and (iii)
(i) Write the name of most appropriate columns which can be considered as Candidate keys
(ii) Out of selected candidate keys, which one will be the best to choose as Primary Key?
(iii) What is the degree and cardinality of the table
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. What is the difference between Primary Key and Candidate Key?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
48
3.11 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
3. What are the differences between DELETE and DROP commands of SQL?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Write the SQL query to display price of products without duplicate values.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Write the SQL query to drop the table employee.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Write the SQL query to count the number of product with product code is PEN.
....................................................................................................
....................................................................................................
....................................................................................................
49
3.11 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
50
3.11 Worksheets
Worksheet 4
51
3.11 Worksheets
C. Isolation
D. Durability
9: In a database, prior to and after a transaction, properties are used to ensure .......
A. Consistency
B. Redundancy
C. Latency
D. Anonymity
10: Column names of any table must be:
A. Must be numeric type
B. Must be unique
C. Must be in sorted order
D. Must not be greater than 40 characters
Subjective Questions
1. Write the SQL query to update product code to PEC for product ID 1002.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Write short notes on following relational terms:
a. Tuple
b. Attribute
c. Relation
d. Domain
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Write the SQL query to display the maximum, minimum, average of price and total quantity of all products.
52
3.11 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Differentiate between DBMS and RDBMS. Discuss its different functions.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Observe the following Table 3.6 TEACHER and Table 3.7 TASK carefully and write the names of the RDBMS
operation out of (i) EQUI JOIN(ii) NATURAL JOIN(iii) SELECTION (iv)CARTESIAN PRODUCT, which
has been used to product the output as shown below. Also find the Degree and Cardinality of final RESULT.
53
3.11 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Write the SQL queries:
(a). Retrieve all tasks along with the respective teacher information.
(b). Find out the completion date and subject for each task.
(c). Get the teacher name, subject, and task name for tasks completed on 31-05-2020.
(d). List all tasks along with the teacher’s subject and the completion date.
(e). Find out the tasks completed by each teacher with their respective subjects.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
54
4.10 Frequently Asked Interview Questions
55
4.11 Worksheets
OOPS CONCEPT
WORKSHEET Worksheet 1
56
C. Inheritance 3.10 Frequently Asked Interview Questions
D. Polymorphism
57
3.10 Frequently Asked Interview Questions
Subjective Questions
1. Write down about the four pillars of OOP.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Write suitable example which one differentiate between logical and type errors.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. When is it appropriate to use typedef in code?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
58
3.10 Frequently Asked Interview Questions
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. What are functions and how do they work with arguments and return values?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. How classes and objects are used represent real-world entities?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Explain the role of seekg(),seekp(),tellg(),tellp() function in the process of random access in a file.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
59
3.10 Frequently Asked Interview Questions
Worksheet 2
60
3.10 Frequently Asked Interview Questions
Subjective Questions
1. What are templates and how do they work with generic programming?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. How do member functions and constructors work within a class?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. How do we manage memory allocation and deallocation in C++?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
61
3.10 Frequently Asked Interview Questions
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Write a program to add two complex numbers using object as arguments.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Discuss the benefits of returning objects from functions.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Write down the scenario where we require user defined exceptions.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
62
3.10 Frequently Asked Interview Questions
Worksheet 3
63
3.10 Frequently Asked Interview Questions
A. Overloading
B. Overriding
C. Polymorphism
D. Encapsulation
10: Which of the following is a correct syntax for implementing an interface in Java?
A. class MyClass implements MyInterface { }
B. class MyClass extends MyInterface { }
C. interface MyInterface implements MyClass { }
D. interface MyInterface extends MyClass { }
Subjective Questions
1. How overriding is different from the overloading?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Write a program to demonstrate friend function in C++.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Compare and contrast error, exception, warning and fault.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
64
3.10 Frequently Asked Interview Questions
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Write down a C++ program to implement function overloading.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Write down the role of abstract class in C++.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Write down the role and different manipulators in C++.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
65
3.10 Frequently Asked Interview Questions
Worksheet 4
66
3.10 Frequently Asked Interview Questions
Subjective Questions
1. How string is used in C++? How can we create string object?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Write a C++ program involving a virtual function.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Draw a neat and clean sketch to show the different streams available in C++.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
67
3.10 Frequently Asked Interview Questions
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Differentiate between formatted and unformatted I/O. Discuss its different functions.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Write a program in C++ to extract character from a string.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. When do we need multiple catch blocks for a single try block? Give an example.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
68
5.11 Worksheets
DS WORKSHEET
Worksheet 1
69
C. O(n2) 3.10 Frequently Asked Interview Questions
D. O(n logn)
70
3.10 Frequently Asked Interview Questions
Subjective Questions
1. Define data structure and various types of data structures.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. What are the various types of searching used in Data Structures? Explain with one example?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. What is algorithm and complexity? What are the types of algorithm analysis?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
71
3.10 Frequently Asked Interview Questions
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Explain about Linked List Data Structure. What is doubly linked list?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. What are the advantages of Binary search over linear search?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. What is a difference between graph and tree?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
72
3.10 Frequently Asked Interview Questions
Worksheet 2
B. O(2n)
C. O(n2)
D. O(n)
7: New nodes are added to the .............of the queue.
A. Front
B. Back
C. Middle
D. Both A and B
8: The term push and pop is related to
A. Array
B. Lists
73
3.10 Frequently Asked Interview Questions
C. Stacks
D. Trees
9: Which of the following is an application of stack?
A. finding factorial
B. tower of Hanoi
C. infix to postfix
D. all of the above
10: The situation when in a linked list START=NULL is .........
A. Underflow
B. Overflow
C. Houseful
D. Saturated
Subjective Questions
1. What are the types of queues in Data Structures?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Explain quick sort with an example.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. What do you understand by Tower of Hanoi? Explain with one example.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
74
5.11 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. What is the difference between PUSH and POP with example.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. In which condition linked list is better than array and vice versa?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. How can AVL Tree be useful in all the operations as compared to Binary search tree.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
75
5.11 Worksheets
....................................................................................................
76
5.11 Worksheets
Worksheet 3
77
5.11 Worksheets
B. O(log2 n)
C. O(n)
D. O(n log2 n)
10: Traversing a binary tree first root and then left and right subtrees called .......... traversal.
A. Postorder
B. Preorder
C. Inorder
D. None of these
Subjective Questions
1. What is the prefix and post fix notation of (a + b) * (c + d) ?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. How insertion sort and selection sorts are different?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Explain the types of algorithm with examples.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
78
5.11 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Explain the rate of growth. Which is commonly used with the help of table?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Which data structure is used to perform recursion?.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. What is merge sort and how it works?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
79
5.11 Worksheets
Worksheet 4
80
5.11 Worksheets
A. Insertion sort
B. Merge sort
C. Quick sort
D. Bubble sort
10: A search begins the search with the element that is located in the middle of the array
A. serial
B. random
C. parallel
D. binary
Subjective Questions
1. What is hashing? Explain different hashing techniques in detail.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. What is a postfix expression?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. What is Graph? What are the types of graph?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
81
5.11 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Which data structures are used in BFS and DFS algorithm?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Explain the terms: null tree, left and right successor, terminal nodes, similar and copy tree.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. What are the differences between BST and AVL tree?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
82
5.11 Worksheets
Worksheet 5
83
5.11 Worksheets
D. 1
7: Following are pass outputs of a program for an algorithm: 22, 14, 56, 7, 25, 8
Pass 1: 7, 14, 56, 22, 25, 8
Pass 2: 7, 8, 56, 22, 25, 14
And so on...
Final: 7, 8, 14, 22, 25, 56
Choose the name of the associated algorithm for the above results.
A. Selection sort
B. Insertion sort
C. Bubble Sort
D. Merge Sort
8: Following are the pass outputs of a program for an algorithm: 22, 14, 56, 7, 25, 8
Pass 1: 14, 22, 56, 7, 25, 8
Pass 2: 14, 22, 56, 7, 25, 8
Pass 3: 7, 14, 22, 56, 25, 8
And so on...
Final: 7, 8, 14, 22, 25, 56
Choose the name of the associated algorithm for the above results.
A. Selection sort
B. Insertion sort
C. Bubble Sort
D. Merge Sort
9: Following are the pass outputs of a program for an algorithm: 22, 14, 56, 7, 25, 8
Pass 1: 14, 22, 7, 25, 8, 56
Pass 2: 14, 7, 22, 8, 25, 56
And so on...
Final: 7, 8, 14, 22, 25, 56
Choose the name of the associated algorithm for the above results.
(A) Selection sort
(B) Insertion sort
(C) Bubble Sort
(D) Merge Sort
10: Array representation of Binary tree
0 1 2 3 4 5 6
A. 7 11 2 7 1 11 9
84
5.11 Worksheets
0 1 2 3 4 5 6
B. 7 11 7 1 2 11 9
0 1 2 3 4 5 6
C. 7 1 11 11 9 2 7
D. Any of the above
Subjective Questions
1. Define the properties of recursion. Explain factorial.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Explain the all-possible complexities (best, worst and average case) in a table.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. What are records? Explain record structure with one example.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
85
5.11 Worksheets
....................................................................................................
4. Create a BST tree with the following data by inserting the elements in order of their occurrence: 200, 150, 350,
100, 70, 110, 250, 500, 400, 550, 450
Delete the following nodes in sequential order: 150, 500, 450, 200, 110
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Consider the graph given below. Find out its Breadth-First Traversal and show each steps.
86
5.11 Worksheets
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
87
6.12 Worksheets
ALGORITHM
WORKSHEET
Worksheet 1
89
3.10 Frequently Asked Interview Questions
B. n/2
C. (n + 1)/2
D. (n − 1)/2
9. If we have 11 sorted elements in an array and we apply Binary search to find the element and each time it is a
successful search. What will be the average number of comparisons we need to do?
A. 3.46
B. 3.0
C. 3.33
D. 2.81
10. Average case complexity of Linear Search occurs when:
A. Item is available exactly in the mid of the list.
B. Item is available somewhere in between the list.
C. Item is at the end of the list.
D. Item is not available in the list.
Subjective Questions
1. What do you mean by “Sort in Place”?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. What are the conditions for ideal sorting Algorithm?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Write Recursive function of Binary Search.
....................................................................................................
....................................................................................................
90
3.10 Frequently Asked Interview Questions
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Write iterative algorithm of Quick Sort.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Write a code to check whether given two strings are Anagram. (Anagram means the strings are of equal length
and have same characters, but order may be different).
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
6. Consider we have 1000 sorted elements in an array and we are trying to find an element which is not available
in this array using binary search. Find how many comparisons will be required to find that the element is not
available. Write all the indices with which you are going to compare.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
91
3.10 Frequently Asked Interview Questions
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
92
3.10 Frequently Asked Interview Questions
Worksheet 2
2: Hash Table T has 25 slots which are going to store 2000 elements. What will be the load factor?
A. 0.0125
B. 50000
C. 1.25
D. 80
3: Let a Hash Function distributes keys uniformly in the hash table. The hash table has size 50. After how many
keys are added will the probability of collision become 0.5?
A. 20
B. 25
C. 10
D. 30
4: Benefit of chaining over open addressing is:
A. Deletion is easier
B. Space used is less
C. Complexity of the search operation is less
D. None of these
5: Insert the characters of the string KRPY SNJM into a hash table of size 10. Use the hash function h(x) =
(ord(x) − ord(”A”) + 1) mod 10. If linear probing is used to resolve collisions, then the following insertion
causes a collision. ord(x) is a function that returns the alphabetical order of the letter.
A. P
B. M
C. C
D. K
6: Which is the most efficient algorithm to find a cycle in a graph?
A. BFS
B. DFS
C. Prim’s Algorithm
D. Kruskal Algorithm
7: How is traversal of a graph different from a tree?
A. BFS of a graph uses a queue, but a time-efficient BFS of a tree is recursive.
B. DFS of a graph uses a stack, but inorder traversal of a tree is recursive.
C. There can be a loop in a graph so we must maintain a visited flag for every vertex.
D. All of the above.
8: To implement Dijkstra’s shortest path algorithm on unweighted graphs so that it runs in linear time, the data
structure to be used is:
A. Queue
B. Stack
93
3.10 Frequently Asked Interview Questions
C. Heap
D. Binary Tree
9: Which of the following algorithms can be used to efficiently calculate single source shortest paths in a Directed
Acyclic Graph?
A. Topological Sort
B. Bellman-Ford
C. Dijkstra
D. Prim’s
10: Given a directed graph where the weight of every edge is the same, we can efficiently find the shortest path from
a given source to destination using:
A. DFS
B. BFS
C. Dijkstra
D. Kruskal
Subjective Questions
1. How can I pair socks from a pile efficiently
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. The keys 12, 18, 13, 2, 3, 23, 5 and 15 are inserted into an initially empty hash table of length 10 using open
addressing with hash function h(k) = k mod 10 and linear probing. What is the resultant hash table?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Write any five applications of BFS.
....................................................................................................
94
3.10 Frequently Asked Interview Questions
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Given a connected undirected graph, check if it contains any cycle or not. Write algorithm for it.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Why Dijkstra Algorithm get fail for graphs containing negative weights?
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
95
3.10 Frequently Asked Interview Questions
Worksheet 3
96
3.10 Frequently Asked Interview Questions
C. 26
D. 24
9: What is the time complexity of the greedy algorithm for job scheduling with deadlines?
A. O(n)
B. O(n log n)
C. O(n2)
D. O(log n)
10: For a given graph with weighted edges, if Kruskal’s algorithm is applied to find the minimum spanning tree,
what is the time complexity for a graph with V vertices and E edges?
A. O(V )
B. O(E)
C. O(V log V )
D. O(E log E)
Subjective Questions
1. 1. Consider the following tasks with their deadlines and profits. Schedule the tasks in such a way that they
produce maximum profit after being executed
Job J1 J2 J3 J4
Profit 50 15 10 25
Deadline 2 1 2 1
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Construct a minimum spanning tree of the graph given in Figure 6.5 Start the Prim’s algorithm from vertex D.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
97
3.10 Frequently Asked Interview Questions
Figure 6.5
Figure 6.6
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Consider the graph G given in Figure 6.7 Taking S as the initial node, execute the Dijkstra’s algorithm on it.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
98
3.10 Frequently Asked Interview Questions
Figure 6.7
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Create a Huffman tree with the following nodes arranged in a priority queue in Figure 6.8.
Figure 6.8
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
99
3.10 Frequently Asked Interview Questions
Worksheet 4
100
3.10 Frequently Asked Interview Questions
9: Consider a recursive algorithm with a time complexity given by the recurrence relation T (n) = 3T (n/4) + n2.
What is the time complexity of this algorithm using the Master Theorem?
A. O(n)
B. O(n log n)
C. O(n2 log n)
D. O(n2)
10: The time complexity of an algorithm is given by T (n) = T (n/2) + T (n/4) + n. What is the time complexity
of the algorithm?
A. O(n log n)
B. O(n2)
C. O(n2 log n)
D. O(n3)
Subjective Questions
1. For each of the following recurrences, give an expression for the runtime T (n) if the recurrence can be solved
with the Master Theorem. Otherwise, indicate that the Master Theorem does not apply.
(a). T (n) = 3T (n/2) + n2
(b). T (n) = 4T (n/2) + n2
(c). T (n) = T (n/2) + 2n
(d). T (n) = 2nT (n/2) + nn
(e). T (n) = 16T (n/4) + n
(f). T (n) = 2T (n/2) + n log n
(g). T (n) = 2T (n/2) + n/ log n
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Apply QuickSort algorithm on the given array. Input: [2, 8, 7, 1, 3, 5, 6, 4]
Output: [1, 2, 3, 4, 5, 6, 7, 8]
....................................................................................................
101
3.10 Frequently Asked Interview Questions
Algorithm 6 Partition
1: procedure PARTITION(A, low, high)
2: pivot → A[high]
3: i → low − 1
4: for j → low to high − 1 do
5: if A[j] ≤ pivot then
6: i→i+1
7: swap A[i] and A[j]
8: swap A[i + 1] and A[high]
9: return i + 1
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Apply Merge Sort algorithm on following array Input: [2, 8, 7, 1, 3, 5, 6, 4]
Output: [1, 2, 3, 4, 5, 6, 7, 8]
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Solve the following recurrence relation using the substitution method:
( n)
T (n) = 2T + n, T (1) = 2
2
102
3.10 Frequently Asked Interview Questions
Algorithm 8 Merge
1: procedure MERGE(A, low, mid, high)
2: n1 → mid − low + 1
3: n2 → high − mid
4: create arrays L[1..n1 + 1] and R[1..n2 + 1]
5: for i → 1 to n1 do
6: L[i] → A[low + i − 1]
7: for j → 1 to n2 do
8: R[j] → A[mid + j]
9: L[n1 + 1] → ∞
10: R[n2 + 1] → ∞
11: i→1
12: j→1
13: for k → low to high do
14: if L[i] ≤ R[j] then
15: A[k] → L[i]
16: i→i+1
17: else
18: A[k] → R[j]
19: j →j +1
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Solve the following recurrence relation using the tree method:
( n)
T (n) = 2T +n
2
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
103
3.10 Frequently Asked Interview Questions
....................................................................................................
104
3.10 Frequently Asked Interview Questions
Worksheet 5
105
3.10 Frequently Asked Interview Questions
D. 3
9: If a dynamic programming algorithm has a recurrence relation T (n) = T (n − 1) + T (n − 2) and base cases
T (0) = 1, T (1) = 1, what is the time complexity of the algorithm in terms of n?
A. O(n)
B. O(2n)
C. O(n2)
D. O(log n)
10: For the Knapsack problem, if the maximum capacity is 10 and there are items with weights [2, 4, 5] and values
[6, 8, 7], what is the maximum value that can be achieved using dynamic programming?
A. 13
B. 14
C. 15
D. 16
Subjective Questions
1. Find an optimal parenthesization of a matrix-chain product whose sequence of dimensions is (5,4,6,2,7).
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
2. Determine an LCS of (1,0,0,1,0,1,0,1) and (0,1,0,1,1,0,1,1,0).
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
3. Consider the problem having weights and profits are:
Weights: 2,3,4,5
Profits: 1,2,5,6
106
3.10 Frequently Asked Interview Questions
The weight of the knapsack is 8 kg. Solve the 0/1 knapsack using Dynamic Programming.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
4. Discuss difference between Tabulation vs Memoization in Dynamic Programming.
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
5. Consider the following Graph given in Figure 6.9. Solve it for All Pair Shortest Path using Dynamic Program-
ming.
....................................................................................................
Figure 6.9
....................................................................................................
....................................................................................................
....................................................................................................
107
3.10 Frequently Asked Interview Questions
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
. . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
108
A.13 Minimum Spanning Tree (MST) Algorithms
109