AAdrieneinadrienetz.hashnode.dev·Feb 26, 2025 · 5 min readAlgorithm: RecursionWhat’s recursion? A function calls itself and runs again. An easy example below: func rc() { rc() } Every recursive function needs to have a base case or a stopping point. If the stop case doesn’t exist, the recursive function will keep running ...00
AAdrieneinadrienetz.hashnode.dev·Oct 9, 2024 · 3 min readData Structure: Arrays Exercise - Reverse A StringReverse A String: 把任意input的string倒敘排列 JavaScript: 解法一:先把input string轉換成array,組合後再轉回string,最後return Time Complexity: O(n) for loop會iterate整個string → O(n) join會iterate整個array → O(n) Space Complexity: O(n) push把資料一個一個放入result array → O(1) join會建立新的strin...00
AAdrieneinadrienetz.hashnode.dev·Oct 8, 2024 · 3 min readData Structure: ArraysSometimes, an array is also called a list. Array organizes elements sequentially and in order. Data stored in the memory is one after another. indexitem 0Oak 1Maple 2Pine 3Birch 4Cedar 5Palm 6Plum Array Methods in JavaScript & Slice Fu...00
AAdrieneinadrienetz.hashnode.dev·Sep 27, 2024 · 2 min readData Structure ContentsData Structure: a collection of values Algorithms: processes to manipulate these collections of values What is a Data Structure? A data structure is like a container for organizing related data. The key is knowing how to organize the data in a suitab...00
AAdrieneinadrienetz.hashnode.dev·Sep 24, 2024 · 1 min readBig O: Why learn to use Big O? What makes good code?Why learn to use Big O? Use Big O to measure how and why one data structure is better than others. Why do we use an array rather than an object in some cases? Each data structure has pros and cons. Big O is used to describe how efficiently the code r...00