Is Blockchain a Linked List like Data Structure?

Blockchain represented as Linked List Data Structure

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:

Linked List Data Structure

Figure 1. Linked List Data Structure

The following diagram represents the Blockchain.

Blockchain represented as Linked List Data Structure

Figure 2. Blockchain represented as Linked List Data Structure

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
    • Nonce
    • Timestamp
    • 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.

References

Summary

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.

Ajitesh Kumar
Follow me

Ajitesh Kumar

I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. For latest updates and blogs, follow us on Twitter. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking. Check out my other blog, Revive-n-Thrive.com
Posted in BlockChain, Data Structure. Tagged with .

Leave a Reply

Your email address will not be published. Required fields are marked *