Tag: Algorithms 101

  • Algorithms 101: What is a Stack

    栈是什么?What is a Stack? A stack is a linear data structure that follows the Last-In-First-Out (LIFO) principle. This means that the last element added to the stack will be the first one to be removed. Stacks are used in various applications, including expression evaluation, backtracking algorithms, and the undo mechanism…

  • Algorithms 101: What is a Queue

    什么是队列? A queue is a linear data structure that follows the First-In-First-Out (FIFO) principle. This means that the first element added to the queue will be the first one to be removed. Queues are widely used in scenarios where tasks need to be processed in the order they arrive, such…

  • Algorithms 101: Preserving Relative Position in Linked List

    链表分隔问题:保留相对位置 Linked List Partitioning Problem: Preserving Relative Position Given the head of a linked list and a specific value x, the task is to partition the linked list so that all nodes with values less than x appear before nodes with values greater than or equal to x. Additionally, the…

  • Algorithms 101: Adding Two Numbers Represented by Linked Lists

    两个链表相加 This problem involves adding two numbers represented by two linked lists. Each linked list stores a non-negative integer where the digits are stored in reverse order, meaning that the least significant digit comes first. Each node in the linked list contains a single digit, and the task is to…

  • Algorithms 101: Merge Two Sorted Linked Lists

    合并两个有序链表 Merging two sorted linked lists is a common problem that requires combining two ascending order lists into a new sorted linked list. The resulting linked list should maintain the ascending order and include all the nodes from both input lists. This problem is often encountered in algorithmic challenges and…

  • Algorithms 101: Singly and Doubly Linked Lists and Their Reversal – Stack Interpretation

    单双链表及其反转 – 堆栈诠释 Linked lists are fundamental data structures in computer science, offering a flexible way to store and manipulate data. A singly linked list consists of nodes where each node contains data and a reference to the next node in the sequence. A doubly linked list, on the other…

  • Algorithms 101: Directional Search Algorithm for Gomoku

    In this blog, we will explore the implementation and optimization of a directional search algorithm to determine the win condition in a game like Gomoku (五子棋). Gomoku is a traditional board game where two players take turns placing black or white stones on a grid, with the objective of aligning…

  • Algorithms 101: Using Bitwise AND to Check the Least Significant Bit

    The bitwise AND operation is a fundamental tool in low-level programming, and it’s particularly useful when working with binary data. One common use case is to check whether a number is even or odd by examining its least significant bit (LSB). This technique is efficient and commonly used in performance-critical…

  • Algorithms 101: InOrder Traversal

    中序遍历 InOrder traversal is a tree traversal method where the nodes are visited in ascending order. It is one of the depth-first search (DFS) methods used to explore all the nodes in a tree. In InOrder traversal, the process is to recursively visit the left subtree first, then visit the…

  • Algorithms 101: PreOrder Traversal

    先序遍历 PreOrder traversal is a tree traversal method where the root node is visited before its children. It is one of the depth-first search (DFS) methods used to explore all the nodes in a tree. In PreOrder traversal, the process is to visit the root node first, then recursively visit…