Author: admin
-
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
•
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
•
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: Sorting Algorithms
•
Sorting Algorithms Sorting algorithms arrange data in a particular order, typically ascending or descending. Common sorting algorithms include: Bubble Sort Bubble sort is a simple comparison-based sorting algorithm. It repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. def bubble_sort(arr): n…
-
Python 101: Python 35 keywords
•
Python 35 keywords Keyword Definition Code Example Tips False Boolean value indicating false. is_student = False Use in conditional statements to represent a false state. None Represents the absence of a value or a null value. result = None Commonly used to initialize variables or indicate no result. True Boolean…
-
Code Interview: Python for Coding Interviews
•
Python for Coding Interviews Variables Python is dynamically typed, meaning you don’t need to declare the type of a variable. Here’s how it works: n = 0 print(n) # Output: 0 n = "ABC" print(n) # Output: ABC Multiple Assignments You can assign multiple variables in one line: a, b…
-
Code Interview: Data Structures for Coding Interviews
•
Data Structures for Coding Interviews Basic Data Structures Arrays Lists Tuples String Manipulation Strings String Methods Sets and Dictionaries Sets Dictionaries Linked Lists Singly Linked List Doubly Linked List Circular Linked List Stacks and Queues Stacks Queues Deques Trees Binary Trees Binary Search Trees AVL Trees Red-Black Trees N-ary Trees…
-
Python 101: Sets
•
Python Sets https://www.w3schools.com/python/python_sets.asp In Python, a set is a collection of unique elements, and it is an unordered and unindexed collection of items. Set is one of 4 built-in data types in Python used to store collections of data, the other 3 are List, Tuple, and Dictionary, all with different…
-
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: Tree Preorder Traversal Using Recursive and Iterative Methods
•
Tree Preorder Traversal in Recursive and Iterative Ways In the context of the provided search results, it seems that the term "preorder" is primarily associated with marketing strategies, product launches, and customer engagement. However, I believe you are referring to the preorder traversal technique used in tree data structures. Preorder…