Binary Tree in Python
Let’s create a Binary Tree in Python and understand how it works. A binary tree is a hierarchical data structure composed of nodes, where each node has at most two children, referred to as the left child and the right child. The structure resembles a tree with a single root node and branches extending downward, […]
SurrealDB tutorial
Let’s learn more about SurrealDB with a real world use case, albeit stripped down for learning purposes. For the purposes of this SurrealDB tutorial I have a collection of old farming magazines. Suppose I was to build a website where I sell them. It might be useful to have a feature that allows people to […]
Sorting in Rust
Current implementation The current algorithm is an adaptive, iterative merge sort inspired by timsort. It is designed to be very fast in cases where the slice is nearly sorted, or consists of two or more sorted sequences concatenated one after another. To sort you can use itertools : https://doc.rust-lang.org/std/collections/
Proof of work
Proof of Work (PoW) is a consensus mechanism in blockchain technology. It requires participants, called miners, to solve complex mathematical puzzles to validate transactions and create new blocks. The first miner to solve the puzzle broadcasts the solution, and others verify it. PoW ensures security and decentralization.
Lazy Iterators in Python
A lazy iterator in Python is often implemented using a generator expression, denoted by (…). https://www.youtube.com/watch?v=9jEvIAsYr5w A generator expression is similar to a list comprehension but produces values lazily, one at a time, as they are requested. Let’s break down the concept and create a simple example. Generator Expression Syntax: A generator expression is enclosed […]
Trait Objects and dynamic dispatch
Dynamic dispatch in Rust allows treating different types implementing a trait uniformly through trait objects like Box<dyn Trait>. It provides flexibility by resolving method calls at runtime, enabling runtime polymorphism. This is particularly useful when dealing with collections of diverse types sharing a common trait. “This works differently from defining a struct that uses a […]