BlockChain

Is Blockchain a Linked List like 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:

Figure 1. Linked List Data Structure

The following diagram represents the Blockchain.

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

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. 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.

Share
Published by
Ajitesh Kumar
Tags: blockchain

Recent Posts

Agentic Reasoning Design Patterns in AI: Examples

In recent years, artificial intelligence (AI) has evolved to include more sophisticated and capable agents,…

1 month ago

LLMs for Adaptive Learning & Personalized Education

Adaptive learning helps in tailoring learning experiences to fit the unique needs of each student.…

1 month ago

Sparse Mixture of Experts (MoE) Models: Examples

With the increasing demand for more powerful machine learning (ML) systems that can handle diverse…

2 months ago

Anxiety Disorder Detection & Machine Learning Techniques

Anxiety is a common mental health condition that affects millions of people around the world.…

2 months ago

Confounder Features & Machine Learning Models: Examples

In machine learning, confounder features or variables can significantly affect the accuracy and validity of…

2 months ago

Credit Card Fraud Detection & Machine Learning

Last updated: 26 Sept, 2024 Credit card fraud detection is a major concern for credit…

2 months ago