knownNet Knowledge Base

website·Indexed 29 days ago

https://zack-xy.github.io/knownNet/

A technical knowledge repository covering computer science fundamentals, algorithms, and modern web development. Content includes detailed guides on data structures (heaps, linked lists, binary search), algorithm design (recursion, dynamic programming), database operations (SQL, PostgreSQL, cursors), and React hooks such as useReducer, useRef, and useImperativeHandle.

Tokens
123K
Snippets
538
Records
825
Agent score
74%

What's inside knownNet

  1. Understand Circular Queue logic and operations

    A Circular Queue is an extension of a standard queue where the last position is connected back to the first position to form a circle. This solves the limitation of linear queues where empty spaces at the front cannot be reused after dequeue operations.

    Key Logic:

    • Uses two pointers: FRONT (first element) and REAR (last element).
    • Initial state: FRONT = -1, REAR = -1.
    • Circular increment is achieved using the modulo operator: index = (index + 1) % SIZE.

    Operations:

    1. Enqueue (Insert):
      • Check if the queue is full.
      • If it's the first element, set FRONT = 0.
      • Increment REAR circularly: REAR = (REAR + 1) % SIZE.
      • Add the element at the REAR position.
    2. Dequeue (Remove):
      • Check if the queue is empty.
      • Retrieve the value at FRONT.
      • Increment FRONT circularly: FRONT = (FRONT + 1) % SIZE.
      • If the last element is removed, reset FRONT and REAR to -1.

    Full Queue Conditions:

    • Case 1: FRONT == 0 and REAR == SIZE - 1
    • Case 2: FRONT == REAR + 1
  2. Understand Asymptotic Analysis for Algorithm Efficiency

    Asymptotic analysis is the study of how an algorithm's performance (time and storage resources) changes as the input size increases. It provides a mathematical way to describe the running time of an algorithm as the input approaches a specific limit, allowing developers to evaluate efficiency regardless of specific hardware or input types.
  3. Understand CSS Logical vs Physical Coordinate Systems

    CSS uses two types of coordinate systems to define element positioning and sizing:

    1. Physical Coordinate System: Fixed axes where the X-axis extends right from the top-left corner and the Y-axis extends down from the top-left corner.
    2. Logical Coordinate System: Relative axes based on the writing mode (writing-mode).
      • Inline Axis: Follows the direction of text flow.
      • Block Axis: Follows the flow direction of blocks (perpendicular to the inline axis).

    If the writing-mode changes, the mapping of logical properties to physical dimensions also changes.

  4. Compare Client-Side Rendering (CSR) and Server-Side Rendering (SSR)

    Client-Side Rendering (CSR) involves the server sending static assets to the browser, which then executes JavaScript to generate the page content. Consequently, the final content is not present in the initial HTML source. Server-Side Rendering (SSR) involves the server sending a fully constructed HTML page to the browser, allowing the content to be found in the HTML source without requiring JavaScript execution first. Note that SSR increases server load by shifting rendering work from the client to the server.
  5. Understand why V8 uses bytecode instead of direct machine code

    V8 converts JavaScript to bytecode before machine code for several architectural reasons:

    1. Platform Independence: Bytecode is an intermediate representation that can be executed across different platforms (e.g., various browsers or Node.js) via a virtual machine.
    2. JIT Compilation: Bytecode allows the Just-in-Time (JIT) compiler to use runtime context (like type inference and static analysis) to generate more optimized machine code.
    3. Faster Startup: Compiling source code to bytecode is significantly faster than compiling directly to machine code, allowing applications to start more quickly.
    4. Dynamic Nature: Since JavaScript is dynamic, bytecode is easier to interpret and modify at runtime compared to machine code, which would require full recompilation.
  6. Understand Same-Origin Policy (SOP) restrictions

    The Same-Origin Policy is a critical security mechanism that isolates potentially malicious files by restricting how documents or scripts loaded from one origin (defined by the same protocol, domain, and port) interact with resources from a different origin. When a request is cross-origin, the following are restricted:

    • Access to Cookies, LocalStorage, and IndexedDB
    • Access to the DOM of the other origin
    • Sending Ajax requests
  7. Understand V8 Engine Memory Architecture and Limits

    The V8 engine manages memory using a generational strategy divided into the Young Generation and the Old Generation. Default memory limits are approximately 1.4GB for 64-bit systems and 700MB+ for 32-bit systems, though actual usage may vary.

    • Young Generation: Small (approx. 32MB), used for short-lived temporary data. It is split into 'from' and 'to' spaces. Garbage collection involves copying surviving variables from 'from' to 'to', then swapping the two spaces.
    • Old Generation: Used for long-lived data. Garbage collection involves marking dead variables, clearing them, and performing memory compaction (disk reorganization) to fill gaps left by cleared variables.
    • Promotion: Objects move from the Young Generation to the Old Generation if they survive one garbage collection cycle or if the surviving data occupies more than 25% of the 'to' space.
  8. Understand CSS Logical Properties vs Physical Properties

    CSS physical properties (e.g., width, height, left, right) are tied to the physical axes of the screen. Because different languages use different writing-mode settings (e.g., horizontal vs. vertical), physical properties can cause inconsistent layouts across different linguistic environments. CSS Logical Properties provide a way to define spacing and sizing relative to the flow of the content (inline and block axes) rather than the physical screen, ensuring consistent rendering regardless of the writing direction.