• On WALs (Write Ahead Logs) and fsync()

    This post will discuss CWal: A Write Ahead log (WAL) implementation I wrote in C++ (tested on Ubuntu 22.04). Here is a direct link: https://github.com/sjay05/cwal.

    In a database system, write ahead logs store operations in a sequential order within a log file which are flushed to the disk before any expensive database-wide commits are performed.

    This preserves the durability of the data, as it is recoverable in the case of a power failure/system crash.

    Log Entries:

    Log entries consist of a byte_len representing the size of data in bytes, and a 4 byte CRC Checksum value (CRC_CHECKSUM).

    struct LogEntry {
      uint64_t byte_length;
      std::string data;
    };
    
    ----|-------------------|--------------------|-----------------------|-----
    ... | uint64_t byte_len | const string* data | uint32_t CRC_CHECKSUM | ... 
        | (8 bytes)         | (byte_len bytes)   | (4 bytes)             |
    ----|-------------------|--------------------|-----------------------|-----
    

    Read on →

  • My Articles

    Investigating the RSA Cipher & Diffe-Hellman Key Exchange

    • Covered and proved Modular Arithmetic & Number Theory Essentials (FLT, CRT) to introduce the RSA Cipher and provide a proof of correctness.
    • My Mathematics Extended Essay that I completed for the IB Diploma

    The relationship of Temperature (˚T) on the spring constant of Polymer molecules

    • Investigated an extension into Young’s modulus (by comparing stress/strain under varying temperatures)
    • Outlined the limitations of Hooke’s law in the real-world by considering the elasticity of rubber-like materials
    • My Phyics Internal Assessment that I completed for the IB Diploma (SL Physics)
  • Prefix Digits - An Outline

    Problem Link: https://dmoj.ca/problem/pdigit

    This post will dicuss the solution for the problem linked above, that I created for a mini-contest in DMOJ.

    Statement

    You are given two integers ~n~ and ~k~, and can perform operations to ~n~.

    Each operation allows you to prepend a digit ~d~ ~(0 \le 0 \le 9)~ to ~n~, and it is your task to determine if there exists a sequence of operations such that ~n~ will end up being divisible by ~k~.

    Note: ~n~ and ~k~ can be fairly large with bounds ~(1 \le n, k \le 10^9)~, and you are required to answer ~t~ test cases.

    Read on →

  • AAC1 P5 - Odd Alpacas

    Problem Link: dmoj.ca/problem/aac1p5

    This post will discuss the solution for the problem linked above. I created this problem along with Sam Liu for Animal Contest 1 on DMOJ.

    Statistics:

    • Served as P5 of a 6-problem set.
    • ~9~ correct submissions during contest.
    • ~29.33\%~ AC rate (including subtasks).

    Statement

    You are given an tree of ~N~ nodes and ~N - 1~ weighted edges connecting ~u_i~ and ~v_i~ with weight ~w_i~ for ~1 \le i \le N - 1~.

    Read on →