본문 바로가기

0

(102)
Trie Trie is an efficient information retrieval data structure. Every node of Trie consists of multiple branches. Each branch presents a possible character of keys. We need to mark the last node of every key as end of word node. class TrieNode: def __init__(self): self.children = [None]*26 self.isEndOfWord = False class Trie: def __init__(self): self.root = TrieNode() def _charToIndex(self, ch): retu..
힙 정렬 Heap - 큰 키에 자주 액세스하거나 키(우선 순위) 중심으로 정렬된 시퀀스를 활용해야 할 때 유용한 자료구조. - 한 노드가 최대 두 개의 자식노드를 가지면서, 마지막 레벨을 제외한 모든 레벨에서 노드들이 꽉 채워진 완전 이진 트리를 기본으로 함. Heap 이 되기 위한 조건 1. 구조 조건 - 완전 이진 트리 2. 순서 조건 - Partial Order, 값의 순서가 직계 관계(부모-자식)에서만 성립. 이진 탐색 트리와의 비교 - 힙은 각 자식 < 부모. (최대 힙 트리라 가정.) - 이진 탐색트리는 왼쪽 자식 < 부모 < 오른쪽 자식. 따라서, 힙은 우선순위 정렬에, 이진 탐색 트리는 탐색에 강점을 지닌 자료구조. def heapify(unsorted, index, heap_size) : larg..
Bitcoin and Cryptocurrencies Week 4 (Summary) (2) 1. Types of Users Bitcoin makes the distinction of 4 key functionalities that every node in the network is a combination of: Wallets: management of keys and addresses Mining: the voting process which expends computational power Full Blockchain : a copy of the full Bitcoin blockchain Routing: software that allows you to talk to other Bitcoin nodes We can make powerful generalizations using these ..
Bitcoin and Cryptocurrencies Week 4 (Mining) (1) Step 0 : Download the entire Bitcoin blockchain. This only has to be done once. This allows us to know the history so we can validate future transactions. Note: This step is optional if you mine in a mining pool or are doing lightweight mining. Step 1: Verify transactions You store newly received, unprocessed transactions in a "mempool," where all pending transactions live before making their wa..
Bitcoin and Cryptocurrencies Week 3 (Bitcoin Mechanics & Optimizations) (3) 1. Cryptographic Hash Funcitons In this lecture, we dove into the low-level specifics of Bitcoin that make it work. Bitcoin was innovative because it allowed a decentralized network to reach consensus. It achieved this via tamper-evidence, which means although one can modify the information that passes along the Bitcoin network, it would be obvious that some modification has been made. This tamp..
Bitcoin and Cryptocurrencies Week 3 (Bitcoin Mechanics & Optimizations) (2) Signatures, ECDSA, and Addresses DIGITAL SIGNATURE SCHEMES (DSS) Alice uses ECDSA to generate private and public keys. Bob needs Alice's public key. Alice signs her message. Alice sends message + signature. (The message is the main payload, and the signature can be used to prove that Alice was the one who created that exact message.) Bob can easily verify if Alice signed. 암호화 알고리즘으로 ECC를 사용 ^^; ..
Bitcoin and Cryptocurrencies Week 3 (Bitcoin Mechanics & Optimizations) (1) Cryptographic Hash Functions Cryptographic hash function: Preimage resistance Given H(X), it is computationally difficult to determine X Second preimage resistance Given X, it is computationally difficult to find some value X' such that H(X) == H(X') Collision resistance It is computationally difficult to find X and Y such that H(X) == H(Y) Avalanche effect: a small change in the input produces ..
Bitcoin and Cryptocurrencies Week 2 (Blockchain History: From the Cypherpunk Movement to JP Morgan Chase) 1. Pre-Bitcoin: Libertarian Dreams In the face of increasingly powerful banks and national agencies, the Cypherpunks and Crypto-anarchists of the late 1980s advocated the use of cryptography to preserve privacy, which they defined as the power to selectively reveal oneself. They sought to devleop an anonymous digital transaction system. In October 2008, Satoshi Nakamoto released the Bitcoin whit..