etcd: A Reliable Distributed KV Store

Pronounced et-cee-dee Persistent KV store Uses Raft protocol to maintain data consistency Developed in Go Popular Use case: Kubernetes Installation (OSX) Step 1 $ ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)” < /dev/null 2> /dev/null Step 2 $ brew install etcd Step 3 $ which etcd /usr/local/bin/etcd Start Server and Make Requests Step 4 $ /usr/local/bin/etcd [WARNING] … More etcd: A Reliable Distributed KV Store

Why Use Python Ordered Dictionary?

An ordered dictionary offers same time complexity as the standard dict. The implementation is simple: Keep two dictionaries and a doubly-linked list of keys. The DLL maintains order. One dict maps key => DLL node Other dict maps key => value Implementation details https://github.com/python/cpython/blob/3.7/Lib/collections/init.py#L129 Example Problem: Find the first non-repeating char in a string. def … More Why Use Python Ordered Dictionary?

Quicksort in C++

// cat quicksort.cc #include <bits/stdc++.h> #include <algorithm> // std::swap using namespace std; int partition(int arr[], int low, int high); void qsort(int arr[], int start, int end) { int p; if (start < end) { p = partition(arr, start, end); qsort(arr, start, p – 1); qsort(arr, p + 1, end); } } int partition(int arr[], int … More Quicksort in C++

Basic HashMap in C++

Useful Points I use chaining for key collisions. The key is also stored with the payload. A GET operation searches the key in bucket’s linked-list and returns the value. #include<bits/stdc++.h> using namespace std; class HashNode { private: string key; string value; HashNode *next; public: HashNode(string key, string value) { this->key = key; this->value = value; … More Basic HashMap in C++