Notes, summaries, assignments, exams, and problems for Computers

Sort by
Subject
Level

Blockchain Cryptography: ECC, Hashing, and Consensus

Posted by Anonymous and classified in Computers

Written on in English with a size of 19.16 KB

Elliptic Curve Cryptography (ECC) in Blockchain

Elliptic Curve Cryptography (ECC) is a public-key cryptography technique based on the mathematics of elliptic curves over finite fields. It is widely used in blockchain systems such as Bitcoin and Ethereum for generating secure public-private key pairs and digital signatures. The main advantage of ECC is that it provides high security with smaller key sizes, making it faster and more efficient.

The Mathematical Equation of ECC

The general equation of an elliptic curve is:

y2 = x3 + ax + b

  • a and b are constants that define the shape of the curve.
  • The curve is defined over a finite field Fₚ (where p is a prime number) for cryptographic applications.
  • To be a valid elliptic curve, it must satisfy the condition:
... Continue reading "Blockchain Cryptography: ECC, Hashing, and Consensus" »

Operating System Memory Management and Deadlock Prevention

Posted by Anonymous and classified in Computers

Written on in English with a size of 6.41 KB

Operating System Memory Management Fundamentals

The Operating System (OS) is responsible for crucial memory decisions: determining which programs reside in memory, where they are placed, how memory is protected, and what actions to take when memory resources are exhausted.

Parkinson's Law Applied to Computing

Parkinson’s Law states that programs expand to fill the memory available to hold them.

Models for Organizing Memory

Three primary models exist for structuring memory:

  • Model A (User on Top, RAM on Bottom):
    • Pros: Fast execution.
    • Cons: No protection (e.g., used in MS-DOS).
  • Model B (ROM on Top, User on Bottom):
    • Pros: OS protected.
    • Cons: Slow and not flexible.
  • Model C (Drivers at Top, User in Middle, RAM at Bottom):
    • Pros: Fast and secure.
    • Cons: Complex
... Continue reading "Operating System Memory Management and Deadlock Prevention" »

Memory Management and File System Architecture

Posted by Anonymous and classified in Computers

Written on in English with a size of 12.9 KB

1. Demand Paging

In a standard virtual memory system, the operating system does not load an entire program into physical memory (RAM) at once. Instead, it uses Demand Paging—a strategy where pages are loaded into memory only when they are needed (on demand).

How It Works: The Page Fault Mechanism

  1. CPU Reference: The CPU tries to access a specific virtual address.
  2. Page Table Check: The Hardware (MMU) checks the page table entry for that page. Each entry has a Valid/Invalid (V/I) Bit:
    • Valid (1): The page is already in RAM. The address is translated, and execution continues.
    • Invalid (0): The page is currently on the disk (hard drive/SSD). This triggers a Page Fault interrupt.
  3. OS Trap: The operating system takes control to handle the page fault.
  4. Disk
... Continue reading "Memory Management and File System Architecture" »

Software Engineering Principles and System Design

Classified in Computers

Written on in English with a size of 301.21 KB

Software Engineering and Processes

Agile Manifesto

  • Individuals/Interactions over Processes
  • Working software over documentation
  • Collaboration over negotiation
  • Responding to change over following a plan

Requirements Engineering

Descriptions of the services that a system should provide and the constraints on its operation.

Functional

What the system should do.

Non-functional

Not directly concerned with the specific services delivered by the system to its users.

Quality Attributes

A scenario describing quality attributes typically involves these elements:

  1. Source: Origin of the stimulus.
  2. Stimulus: The event arriving.
  3. Artifact: Where the event arrives.
  4. Environment: Conditions in which the scenario takes place.
  5. Response: The result of the event.
  6. Response Measure: Must
... Continue reading "Software Engineering Principles and System Design" »

JavaScript Regular Expressions and Type Conversion

Posted by Anonymous and classified in Computers

Written on in English with a size of 7.08 KB

Introduction to Regular Expressions

A Regular Expression (often abbreviated as RegExp or regex) is a sequence of characters that forms a search pattern. This pattern can be used for text search, text replace, and data validation operations.

In JavaScript, regular expressions are objects. You can create a RegExp object in two ways:

  • Using a RegExp Literal (Recommended): The pattern is enclosed between forward slashes.
    const regex = /pattern/modifiers;
  • Using the RegExp Constructor:
    const regex = new RegExp('pattern', 'modifiers');
    

RegExp Modifiers and Flags

Modifiers change how a regular expression searches text. They are appended to the end of the regex literal (e.g., /abc/g) or passed as the second argument to the constructor.

ModifierDescription
iCase-
... Continue reading "JavaScript Regular Expressions and Type Conversion" »

Operating System Concepts: Hardware Interaction and Scheduling

Posted by Anonymous and classified in Computers

Written on in English with a size of 1.45 MB

Operating System Fundamentals

The Operating System (OS) serves several critical roles:

  • It acts as a resource manager, controlling access to the hardware.
  • It provides an abstraction layer, allowing user processes to call functions that access hardware via system calls.

User Mode vs. Supervisor Mode (Kernel Mode)

The CPU enforces separation between user processes and the OS kernel:

  • User Mode: Prohibits privileged instructions.
  • Kernel Mode (Supervisor Mode): Allows access to all hardware and privileged operations.

Program Status Word (PSW)

The PSW is a special register holding vital information, such as:

  • Access privilege mode.
  • Runtime execution conditions (e.g., condition codes).
  • Program Counter (PC) and Stack Pointer (SP).

Simplified Interrupt Handling Flow

  1. A
... Continue reading "Operating System Concepts: Hardware Interaction and Scheduling" »

Processor and Memory Interface: CPU Datapath, Registers & ALU

Posted by Anonymous and classified in Computers

Written on in English with a size of 967.85 KB

Processor & Memory Interface

Processor & Memory Interface: The maximum size of the memory that can be used in any computer is determined by the addressing scheme. For example, a computer that generates 16-bit addresses is capable of addressing up to 216 = 65,536 (≈ 64K) memory locations. Machines whose instructions generate 32-bit addresses can utilize a memory that contains up to 232 = 4,294,967,296 (≈ 4G) locations, whereas machines with 64-bit addresses can access up to 264 ≈ 1.84 × 1019 locations. The number of locations represents the size of the address space of the computer.

The connection between the processor and its memory consists of address, data, and control lines. The processor uses the address lines to specify the... Continue reading "Processor and Memory Interface: CPU Datapath, Registers & ALU" »

Java Programming: Classes, Objects, and Key Concepts

Classified in Computers

Written on in English with a size of 5.28 KB

Classes (الصفوف)

  • A class consists of variables (fields) and methods.
  • Variables are data members of a class.
  • Methods are functions that define the class's behavior.

Variables (المتغيرات)

  • Declared with a data type and a name.
  • Can be public or private.
  • Examples: int age, String name.

Methods (الأساليب)

  • Functions that perform specific tasks.
  • Can have parameters and return values.
  • Types:
    • Void methods: Don't return a value.
    • Return type methods: Return a value.
    • Static methods: Can be called without creating an object.
    • Instance methods: Require an object to be called.
    • Abstract methods: Declared without a body; used in abstract classes.
    • Overloaded methods: Multiple methods with the same name but different parameters.

Constructors (البناؤون)

... Continue reading "Java Programming: Classes, Objects, and Key Concepts" »

Deadlock Prevention and Banker's Algorithm in C

Posted by Anonymous and classified in Computers

Written on in English with a size of 2.93 KB

Dining Philosophers Deadlock Prevention

The following implementation addresses the Dining Philosophers problem using POSIX threads and semaphores. To prevent deadlock, the logic ensures that the last philosopher picks up the forks in a different order than the others.

#include <stdio.h>
#include <pthread.h>
#include <semaphore.h>
#include <unistd.h>
#include <stdlib.h>

#define N 5

sem_t forkS[N];

void *philosopher(void *n)
{
    int id = *(int *)n;
    int left = id;
    int right = (id + 1) % N;

    while (1)
    {
        printf("P%d Thinking\n", id);

        fflush(stdout); // Force print immediately
        sleep(1);

        // Deadlock prevention: last philosopher picks right fork first
        if (id ==
... Continue reading "Deadlock Prevention and Banker's Algorithm in C" »

Vector Databases & RAG for Semantic Search and Retrieval

Posted by Anonymous and classified in Computers

Written on in English with a size of 206.28 KB

1. Vector Databases — High-Dimensional Embeddings

Store and search high-dimensional vector embeddings. Used in semantic search, similarity search, and RAG pipelines.

Indexing Techniques

  • Flat Index (Brute Force) → accurate but slow.
  • Approximate Nearest Neighbor (ANN) → fast and scalable.
    • Algorithms: HNSW, FAISS, Annoy.
    • f3Q1622KC84AAAAASUVORK5CYII= 8pk5+AsHqPHAAAAAElFTkSuQmCC

3. Retrieval-Augmented Generation (RAG)

Overview

Enhances LLM output by integrating retrieved external knowledge.

  • Reduces hallucination and outdated responses.
  • Improves factual grounding.

RAG Workflow

  1. Indexing: Convert raw data (PDF, HTML, Word) → embeddings.
  2. Retrieval: Retrieve relevant document chunks using similarity search.
  3. Generation: LLM synthesizes results with the query to produce the final answer.

Retrieval Types

TypeDescriptionExample
Sparse
... Continue reading "Vector Databases & RAG for Semantic Search and Retrieval" »