JavaScript Memo

This post is the memo from Eloquent JavaScript Chapters 1 through 11. 1 Compute and convert to a string. 2 The difference from var and let. Var is global while let is local. 3 Exception 4 Regular Expression

Transaction Object

Transaction object has the following properties. nonce: How many times the sender has sent a transaction to: Address of account this money is going to value: Amount of ether to send to the target address gasPrice: Amount of ether the sender is willing to pay per unit gas to get this transaction processed startGas/gasLimit: Units

Metamask Accounts

A Metamask account consists of three parts. Account Address: Identify the account. The address is the last 20 bytes of the hash of the public key. Public Key: Identify the account.Private Key: Authorize the sending from your account. Access to your account. Very long so not easy to guess.

jQuery Memo

What happens when…

There is an age old interview question “What happens when you type google.com into your browser’s address box and press enter?” This article is to give an simple answer of it which is limited to Web knowledge. The reference at the end of the article gives the complete answer. The query is submitted to the

Import Ether to MetaMask from Ganache

When we want to test the truffle application, we should construct a test environment. Generally, we use MetaMask to complete transactions. Before that, we must have some ethers in the MetaMask. 1. Install Ganache and MetaMask. 2. Open the ganache and click the setting icon on the top-right of the window. Then set port number

Multi-end BFS

BFS and DFS are usually used in searching problem. But for a specific kind of problem, we should use a optimized BFS, Multi-end BFS to guarantee the efficiency of the solution. This kind of problems has the following features: There are many entrances in the searching space. We want the minimum or the maximum solutions.

Tree Serialization

Serialization means transforming tree structure to a linear structure to store it. Generally, traversal is used to implement serialization. So, what kinds of traversal could be used to implement serialization? We mainly focus on binary tree in this article. At the end of the article we will discuss a little about N-ary tree. 1 Serialization

Tree Traversal

Generally, tree traversal can be specified as inorder traversal (only for binary tree) , preorder traversal, postorder traversal and level order traversal. Level order traversal can be easily implemented with a queue. But other three traversals could be implemented recursively, iteratively with O(n) space and even iteratively with O(1) space. We focus on binary tree

Union-Find

Union-Find is a data structure to check a cycle in the graph. Every node in the graph has its own parent. So we need a parent array to should each node’s parent. Set the initial parent of each node to itself. And we need a rank array to show the height of the tree of