Essential Recursive Algorithms and Backtracking Techniques
1) Factorial of n
Question
Compute n!.
Explain question
Return the product 1 * 2 * ... * n. The problem is naturally defined in terms of a smaller n.
Approach (in-depth)
If n is 0 (or 1) the answer is 1. Otherwise the factorial of n = n * factorial(n-1). The recursion reduces n by 1 on every call until the base case. No branching — just a single recursive call. This is linear recursion.
Recurrence relation
fact(n) = n * fact(n-1), with fact(0)=1.
Pseudocode
function fact(n):
if n == 0: return 1return Read More
Understanding Computer Bus Architecture and Performance
Introduction to the Concept of the Computer Bus
Computers require a large amount of information to be managed and processed. To facilitate the flow of this data between various components, specific paths are needed. These “paths” are called buses. They are internal circuitry of the motherboard that allows the sending of data between components. The bus largely defines the speed of the computer itself, because the faster the data is sent, the more operations can be performed per second.
A bus, in computing,
Read MoreOperating System Fundamentals: Memory, Scheduling, and Concurrency
Linux Memory Management Components
There are two primary components to memory management under Linux:
- The physical memory management system, which deals with allocating and freeing pages, groups of pages, and small blocks of memory.
- The virtual memory system, which handles memory mapped into the address space of running processes.
Physical Memory Management
The primary physical memory manager in the Linux kernel is the page allocator. This allocator is responsible for allocating and freeing all physical
Read MoreOperating System Memory Management: Single vs. Multiuser Techniques
Memory Management Fundamentals
Memory management is a function of an operating system (OS) that handles the allocation and deallocation of memory to programs and processes.
Single User Operating Systems (OS)
In a Single User OS, only one user can use the system at a time. Consequently, memory is managed in a simple way.
Key Features of Single User OS Memory
- Single Program in Memory: Only one program is loaded in memory at a time. No multitasking is supported.
- Contiguous Memory Allocation: The program
Data Link Layer Protocols: Services, Framing, and Error Control
Data-Link Layer Service Categories
Describe the three possible categories of services provided by the data-link layer:
Unacknowledged Connectionless Service
- This service is appropriate when the error rate is very low, so recovery is left to higher layers.
- It is also appropriate for real-time traffic, such as voice, where late data are worse than bad data.
Acknowledged Connectionless Service
- No logical connections are used, but each frame sent is individually acknowledged.
- Thus, the sender knows whether
Input/Output Systems, Storage, and CPU Security Mechanisms
Types of I/O Devices
Block Devices
Store data in fixed-size blocks. Data transfer happens in blocks (e.g., SSD).
Character Devices
Handle a stream of characters with no block structure (e.g., Keyboard, Mouse). They do not support seek operations.
Block vs. Character Devices
Block devices support random access and block-level operations, while character devices operate in a stream and cannot seek.
I/O Communication Methods
Separate I/O and Memory Space
Provides easier separation but is less flexible.
