In this post, you will learn about similarity and differences between linked list and Blockchain.
The most trivial way to understand What is Blockchain is to visualize Blockchain as a crude form of the Linked List data structure that we read in one of our engineering classes.
Simply speaking, a Blockchain can be defined as a linked list of a group of transactions (block) which is connected with each other using hash pointers rather than pointers as in the case of the linked list.
The following diagram represents the Linked List data structure:
The following diagram represents the Blockchain.
Note some of the following characteristics of a block:
- Each block consists of a header section and a body section.
- The header section of the block may consist of the following information:
- Merkel root
- Hash of the previous block header
- Version number
In case of bitcoin blockchain, a block is of 80 bytes. The following is the details:
- Merkel root (32 bytes)
- Hash of previous block header (32 bytes)
- Timestamp (4 bytes)
- Version number (4 bytes)
- Nonce (4 bytes)
- Difficulty target (4 bytes)
- The body section of the block may consist of the list of transactions. This is as represented in above diagram.
- Hash of the block header (80 bytes) of the block N results in the 32 bytes (256 bits using SHA-256) which get stored as “hash of previous block header” – a part of the block header of the block N+1.
Similarities between Linked List and Blockchain
Note some of the following similarity between Linked List and Blockchain.
- Both look like a list connected with a link (a form the of pointer).
- In Linked List, the link is termed as a Pointer. The pointers are variables which stores the address of subsequent or next node or block. It is used to nagivate to next node. The last node has a null pointer which means that it has no value.
- In Blockchain, the link is termed as a Hash Pointer. The hash pointer is not only used to look up the previous block the of transaction but also used to verify that the transactions stored the in previous block is not tampered. The hash pointer is the hash value of the header data of the previous block (also termed as block header). Recall that a block consists of a header section and a transactions section.
Difference between Linked List and Blockchain
The following is the list of difference(s) between a linked list and a blockchain:
- In a linked list, data stored in a data node could be change. In Blockchain, changing a transaction would lead to re-calculation of hashes of all of the blocks.
- In a linked list, a data node can be added at any place in the list. In Blockchain, the block is added to the end of the chain (list).
- In a linked list, deleting a node would only require a link to be pointed the to previous node of the node to be deleted. In Blockchain, it is not easy to delete a block as the hash of all the block would require to be re-calculated.
In this post, you learned about similarity and differences between linked list data structure and Blockchain.
Did you find this article useful? Do you have any questions or suggestions about this article? Leave a comment and ask your questions and I shall do my best to address your queries.
He has also authored the book, Building Web Apps with Spring 5 and Angular.
Latest posts by Ajitesh Kumar (see all)
- Difference between True Error & Sample Error - December 26, 2019
- Python – How to Create Dataframe using Numpy Array - December 15, 2019
- Hypergeometric Distribution Explained with 10+ Examples - December 14, 2019