Posts

Showing posts from June, 2021

Beautiful Language and Beautiful Code

Image
The post Beautiful Language and Beautiful Code first appeared on Qvault . “Dead Poet’s Society” is a classic film, and has become a recent favorite of mine. There’s a scene in particular that I enjoy, where Robin William’s character explains that it’s bad practice to use terms like “very tired” or “very sad”, instead we should use descriptive words like “exhausted” or “morose”! I wholeheartedly agree with what’s being taught to the students in this scene. It’s tiresome to read a novel where the author drones on within the bounds of a lackluster vocabulary. This brings me to the point I wanted to emphasize in this short article: Beautiful language and beautiful code are far from the same. Beautiful language doesn’t simply communicate instructions from one human to another. Language well-used arouses emotions, illustrates scenery, exposes nuance, and can sing through rhyme and meter. Its purpose isn’t purely functional, it’s a rich medium of creative expression. Beautiful code...

Intro to the One-Time Pad Cipher

Image
The post Intro to the One-Time Pad Cipher first appeared on Qvault . In cryptography, the one-time pad, or OTP is a way of encrypting information so securely that it’s impossible to be cracked. That said, OTP has a major drawback in that it requires both parties to have access to the same key before a message is encrypted. Sorry to interrupt! I just wanted to mention that you should check out my new free Go cryptography course. It’s designed to teach you all the crypto fundamentals you’ll need to get started in cybersecurity. Start Cryptography Course How the one-time pad cipher works When using the one-time pad, a message and a secret key are required to start. Each bit of the original messageg, assuming we can use binary data, is encrypted by using an XOR operation on it and the corresponding bit from the secret key. Refresher on XOR XOR, or “exclusive or” is a binary operator that works with binary data. It returns true if both ...

16 Great Coding Challenges You Can Try Out

Image
The post 16 Great Coding Challenges You Can Try Out first appeared on Qvault . Coding challenges are a fun way to improve your coding quickly. When I started to learn coding in school, coding challenges were the furthest thing from my mind. In fact, I was struck with one particular issue: I didn’t really want to learn to code. I didn’t care enough about coding. I didn’t care about the language. I wanted to get a decent grade and get out. Like a lot of other coders, I’m competitive by nature, but only when it suits me. I need a reason to care. That’s why one of my earliest coding successes was a personal coding challenge. Could I get a python bot up and running? If so, the reward was more Instagram followers for my cats. Suddenly, I was motivated to trawl through error code explanations, figure out the best libraries, and read through dozens of stackoverflow answers.  Coding challenges are a great way to give yourself a reason to pick up a new coding language, whether you’r...

Building a Red-Black Binary Tree in Python

Image
The post Building a Red-Black Binary Tree in Python first appeared on Qvault . A red-black tree is a kind of self-balancing binary search tree. Each node stores an extra bit, which we will call the color, red or black. The color ensures that the tree remains approximately balanced during insertions and deletions. When the tree is modified, the new tree is rearranged and repainted to restore the coloring properties that constrain how unbalanced the tree can become in the worst case. The purpose of a red-black tree is to stay balanced which ensures that its common operations, like lookup and delete, never degrade to worse than O(n*log(n)) . Sorry to interrupt! I just wanted to mention that you should check out my new free Python course, “Big-O Data Structures”. You’ll learn all you need to know to crush your upcoming coding interviews and whiteboard sessions. Start Python Data Structures Course What is a balanced binary tree? Since the reason colors are added ...

Quick Sort in Golang

Image
The post Quick Sort in Golang first appeared on Qvault . Quicksort is an efficient sorting algorithm that’s widely used in production sorting implementations. Like merge sort , quick sort is a divide and conquer algorithm . True to its name, quicksort is one of the fastest sorting algorithms, that said, you need to be careful with the implementation details because if you’re not careful the speed can degrade quickly. Sorry to interrupt! I just wanted to mention that you should check out my new free algorithms course. You’ll learn the basics of Big O notation while writing awesome code in the Go programming language. Learn Big O Algorithms Now Divide Select a pivot element that will preferably end up close to the center of the sorted pack Move everything onto the “greater than” or “less than” side of the pivot The pivot is now in its  final  position Recursively repeat the operation on both si...

How to Write Insertion Sort in Go

Image
The post How to Write Insertion Sort in Go first appeared on Qvault . Insertion sort builds a final sorted list one item at a time. It’s much less efficient on large lists than more advanced algorithms like quicksort or merge sort . Insertion sort is a simple algorithm that works just like you would arrange playing cards in your hands. A slice is first split into sorted and unsorted sections, then values from the unsorted section are inserted into the correct position in the sorted section. Full example of the insertion sort algorithm func insertionSort (arr [] int ) [] int { for i := 0 ; i < len (arr); i++ { for j := i; j > 0 && arr[j -1 ] > arr[j]; j-- { arr[j], arr[j -1 ] = arr[j -1 ], arr[j] } } return arr } Code language: Go ( go ) Sorry to interrupt! I just wanted to mention that you should check out my new free Go course. It’s designed to teach you all the fundamentals of my favorite coding language. Learn Golang Now As y...

Merge Sort in Golang with Examples

Image
The post Merge Sort in Golang with Examples first appeared on Qvault . Merge sort is a recursive sorting algorithm and, luckily for us, it’s quite a bit faster than  bubble sort . Merge sort is a  divide and conquer algorithm . Divide Divide the input slice into two (equal) halves Recursively sort the two halves Conquer Merge the two halves to form a sorted array Sorry to interrupt! I just wanted to mention that you should check out my new free Go course. It’s designed to teach you all the fundamentals of my favorite coding language. Learn Golang Now Full example of the merge sort algorithm Merge sort actually has two functions involved, the recursive mergeSort function, and the merge function. Let’s write the mergeSort() function first. It’s a recursive func...