Tag: Algorithms 101

  • Algorithms 101: Understanding Recursion with a Deep Dive into the Call Stack

    Algorithms 101: Understanding Recursion with a Deep Dive into the Call Stack

    Introduction In this blog post, we’ll explore the concept of recursion and how it interacts with the call stack, which is fundamental to understanding how recursive functions execute. We’ll provide practical examples in both Python and JavaScript to help solidify these concepts. By the end of this post, you should…

  • Algorithms 101: Top 10 Essential Coding Interview Concepts for Data Structures & Algorithms

    Algorithms 101: Top 10 Essential Coding Interview Concepts for Data Structures & Algorithms

    We’re diving into the top 10 essential coding interview concepts you need to master for data structures and algorithms. These concepts are crucial for acing coding interviews and are commonly encountered across various companies. While some may have different opinions, these ten are generally agreed upon as foundational. 1. Arrays…

  • Algorithms 101: Ultimate Guide to Solving Binary Tree Coding Problems with Tips & Techniques

    Algorithms 101: Ultimate Guide to Solving Binary Tree Coding Problems with Tips & Techniques

    Binary Tree Problems and Solutions 1. Sum of Elements in a Binary Tree Python Code: class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def sum_of_elements(root): if root is None: return 0 left_sum = sum_of_elements(root.left) right_sum = sum_of_elements(root.right) return root.value + left_sum +…

  • Algorithms 101: Understanding Stacks

    Algorithms 101: Understanding Stacks

    Definition A Stack is a simple yet powerful data structure used for storing and retrieving data in a Last-In, First-Out (LIFO) manner. This means the last element added to the stack will be the first one to be removed. Key Concepts Push: Add an element to the top of the…

  • Algorithms 101: Recursion

    Algorithms 101: Recursion

    Why Start Learning Algorithms 101 with Recursion Fundamental Concept in Computer Science Recursion is one of the core principles in computer science and is foundational for understanding many advanced topics. Learning recursion early helps build a strong base for tackling more complex algorithms and data structures. Key Reasons Intuitive Problem…

  • Algorithms 101: Data Structures

    Algorithms 101: Data Structures

    Arrays Arrays are a basic data structure used to store elements in a contiguous memory location. They are used in a variety of algorithms for efficient data access and manipulation. # Example functions to demonstrate array operations # Accessing elements in an array – O(1) def access_element(arr, index): return arr[index]…

  • Algorithms 101: Big O Notation

    Algorithms 101: Big O Notation

    Big O Notation Big O notation is a mathematical notation used to describe the upper limit of the runtime of an algorithm as a function of the input size. # Example functions to demonstrate Big O notation # O(1) – Constant Time def constant_time_example(arr): return arr[0] # Accessing the first…

  • Algorithms 101: Search Algorithms

    Algorithms 101: Search Algorithms

    Search Algorithms Search algorithms are designed to retrieve information stored within some data structure or calculated in the search space of a problem domain: Linear Search Linear search is a simple search algorithm that checks every element in the list until it finds the target value. def linear_search(arr, target): #…

  • Algorithms 101: Non-Recursive Binary Tree Traversal

    Non-Recursive Binary Tree Traversal by 砖家王二狗 In-order Traversal: In in-order traversal, we visit the left subtree, then the root, and finally the right subtree. Here’s a non-recursive example in Python: def in_order_traversal(root): result = [] stack = [] current = root while current or stack: while current: stack.append(current) current =…

  • Algorithms 101: DFS and BFS

    Depth-First Search (DFS) and Breadth-First Search (BFS) are two common traversal methods for trees and graphs Tree Traversal Depth-First Search (DFS) is an algorithm that traverses the nodes of a tree by searching the branches as deeply as possible. It traverses the nodes of the tree along its depth, exploring…