Author: admin

  • 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…

  • Python 101: Immutable vs Mutable Objects in Python

    In Python, objects are categorized as either mutable or immutable. Understanding the distinction between these two types of objects is crucial for efficient programming and can profoundly influence your decision when choosing which data type to use in solving a given programming problem. Immutable Objects: Immutable objects do not allow…

  • LeetCode: 124 Binary Tree Maximum Path Sum

    Problem Statement Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need…

  • Python 101: Is there a specific reason why lists have append() but not add() in Python

    The distinction between the append() method for lists and the add() method for sets in Python can be attributed to the fundamental differences in the way lists and sets are structured and used. Lists are ordered collections of items, meaning that the items in a list have a specific order,…

  • Python 101: memo = {} vs memo = dict() in Python

    memo = {} vs memo = dict() The choice between memo = {} and memo = dict() in Python can be seen as a matter of personal preference, as both achieve the same result. The {} syntax is a shorthand for creating an empty dictionary, while dict() is the explicit…

  • Algorithms 101: commonly used time complexities from smallest to largest

    The order of commonly used time complexities, from smallest to largest, is: O(1) < O(logn) < O(n) < O(nlogn) < O(n^2) < O(n^3) < O(2^n) < O(n!) < O(n^k) This order is determined based on the growth rate of commonly encountered time complexities. Time complexity represents the relationship between the…

  • Algorithms 101: Exploring the Time Complexity of Nested Loops in Programming

    Algorithms 101: Exploring the Time Complexity of Nested Loops in Programming

    Title: Introduction: In the world of programming, understanding the time complexity of algorithms is crucial for optimizing code and improving performance. One common scenario that often arises is the use of nested loops, where loops are nested within each other. In this blog post, we will explore the time complexity…

  • Python 101: sort() vs sorted() in Python

    In Python sort() vs sorted() When sorting lists in Python, you can use either the sort() method or the sorted() function. Below is a detailed comparison of these two approaches, including code examples, tips, and warnings. Comparison Table Feature sort() Method sorted() Function Modifies Original List Yes No Returns None…

  • Code Interview: Understanding Shallow Copy vs Deep Copy in Programming

    Code Interview: Understanding Shallow Copy vs Deep Copy in Programming

    Shallow Copy A shallow copy creates a new object, but inserts references into it to the objects found in the original. Changes made to a shallow copy of an object can reflect in the original object if the changes are made to a mutable object contained within the shallow copy.…

  • 500+ Python Snippets

    500+ Python Snippets

    FOR and IN Constructs in Python