Fading Coder

One Final Commit for the Last Sprint

Linked List Operations: Swapping Adjacent Nodes, Removal, Intersection, and Cycle Detection

Swapping Adjacent Nodes in a Linked List The core idea involves using a dummy head node to simplify edge cases and ensure consistent operations on the first node. When swapping node pairs, careful attention must be paid to preserving references before reassigning pointers. Key considerations: Use a...

Binary Tree: Structure and Algorithm Problems

Binary Tree Depth (Recursion/Level Traversal) Tree structures represent hierarchical data with recurisve properties. For practical use, a struct with left and right pointers (or indices) to track child nodes suffices. Problem: Binary Tree Depth This problem focuses on binary tree storage and depth c...

Competitive Programming Core Algorithm Reference with Implementations

Number Theory Min-Max Inclusion-Exclusion The core identities for min-max inclusion-exclusion over finite sets are: $$\max(S) = \sum_{T \subseteq S} (-1)^{|T|+1} \min(T)$$ $$\min(S) = \sum_{T \subseteq S} (-1)^{|T|+1} \max(T)$$ Expanding the summation shows all non-extremal values cancel out. The id...

Analyzing CSP-J Preliminary Round Exam Questions from 2017

Multiple Choice Questions Question 1 In 8-bit two's complement representation, the binary number 10101011 corresponds to which decimal value? Options: A. 43 B. -85 C. -43 D. -84 Answer: B Explanation: The most significnat bit indicates negativity. Covnerting from two's complement yields -85. Questio...

Python List Fundamentals and Operations

A list in Python holds an ordered collection of items. Its defined with square brackets, and the items are separated by commas. numbers = [10, 20, 30, 40] names = ["alice", "bob", "carol"] Accessing Items By Index fruits = ["apple", "banana", "c...

Flattening Hierarchical Tree Structures into Arrays in JavaScript

This article demonstrates how to transform a nested tree structure into a flat array representation using recursive traversal. This technique is commonly used for converting hierarchical data (such as exam modules, organizational charts, or file systems) into a linear format suitable for tabular dis...

Implementing a Stack Data Structure in C

A stack is a linear data structure commonly used in programming. It is a restricted linear list where insertion and deletion can only occur at one end, known as the 'top'. The opposite end is called the 'bottom'. Stacks follow the 'last in, first out' (LIFO) principle, making them useful for various...