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.
What's inside knownNet
- A web server (or site server) provides document services to clients. Any network application following the HTTP design is considered a web server (equivalent to an HTTP server). Common examples include Nginx, Apache, and Tomcat.
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) andREAR(last element). - Initial state:
FRONT = -1,REAR = -1. - Circular increment is achieved using the modulo operator:
index = (index + 1) % SIZE.
Operations:
- Enqueue (Insert):
- Check if the queue is full.
- If it's the first element, set
FRONT = 0. - Increment
REARcircularly:REAR = (REAR + 1) % SIZE. - Add the element at the
REARposition.
- Dequeue (Remove):
- Check if the queue is empty.
- Retrieve the value at
FRONT. - Increment
FRONTcircularly:FRONT = (FRONT + 1) % SIZE. - If the last element is removed, reset
FRONTandREARto -1.
Full Queue Conditions:
- Case 1:
FRONT == 0andREAR == SIZE - 1 - Case 2:
FRONT == REAR + 1
- Uses two pointers:
Understand HTTP protocol characteristics
The HTTP protocol is characterized by being simple and fast, flexible, connectionless (the connection is closed after a single request/response cycle), and stateless (the server cannot distinguish between different connections from the same identity without additional mechanisms).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.Understand CSS Logical vs Physical Coordinate Systems
CSS uses two types of coordinate systems to define element positioning and sizing:
- 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.
- 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-modechanges, the mapping of logical properties to physical dimensions also changes.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.Understand why V8 uses bytecode instead of direct machine code
V8 converts JavaScript to bytecode before machine code for several architectural reasons:
- 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.
- 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.
- Faster Startup: Compiling source code to bytecode is significantly faster than compiling directly to machine code, allowing applications to start more quickly.
- Dynamic Nature: Since JavaScript is dynamic, bytecode is easier to interpret and modify at runtime compared to machine code, which would require full recompilation.
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
Understand Queue fundamentals and FIFO principle
A Queue is a linear data structure that follows the First-In-First-Out (FIFO) principle, meaning the first element added to the queue will be the first one to be removed. It is managed using two pointers: aFRONTpointer to track the first element and aREARpointer to track the last element. Both are typically initialized to -1.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.
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 differentwriting-modesettings (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.Understand the network request path from browser to server
A typical network request flows through the following sequence of components: Browser $\rightarrow$ Protocol Stack/Network Card $\rightarrow$ Hub/Switch/Router $\rightarrow$ Access Network/ISP $\rightarrow$ Firewall/Cache Server $\rightarrow$ Web Server.