Wednesday, July 3, 2024
HomeData ModellingData Structure & AlgorithmHow is Blockchain Different From a Linked List?

How is Blockchain Different From a Linked List?

The article focuses on discussing the differences between Linked List and a Blockchain. Here, we will discuss the following points:

  1. What is Linked List?
  2. What is Blockchain?
  3. Similarities Between Linked List And Blockchain.
  4. Linked List vs Blockchain.

Let’s discuss each of these topics in detail.

What is Linked List?

A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. The data is stored in a node, and this node also has a reference(pointer) to the next node of data, which continues, starting from a head to the last node called a tail. 

A linked list is represented by a pointer to the first node i.e. head of the linked list. If the linked list does not contain any data then the head points to NULL.

Linked list

Singly Linked List

What is Blockchain?

Blockchain is a network of various blocks of data. The structure of each block is such that it has the following properties or attributes: 

  • Block number.
  • The data to store.
  • Reference to the previous block. In the case of the first block, it is zero.
  • It’s hash/address.

The address of a block is calculated by combining its number, data, and the previous block’s address and passing this combination to a hash function which gives a very complex hash. 

  • Once the data is added to the block it cannot be changed. This means if someone was to edit the data in a block, the address will change and a new hash will be produced. 
  • Since the next block has reference to its previous block, it will be noticed that the address does not match and one can detect if the data was manipulated. Even a single character change will change the hash value of the block.
  • Whenever a new block joins the chain, the entire chain is copied, and this copy is given to the user of this new block. If another user joins, the last chain is copied and this copy is given to the new user. 
  • Thus multiple copies are maintained of the same blocks. 
  • Whenever someone tries to change data, the address of that block will change. All the copies are used to compare the address of a block. If all can confirm that the address did not change, this means the data was not changed and nothing happens, otherwise, the change is stopped. 
  • Thus if there are 1 million blocks, and you try to change data in a block, 1 million – 1 blocks are there to compare and resist the change in data.

This simple feature makes blockchain a good choice for keeping a ledger between parties, as whenever someone tries to change data, it is resisted. Since the records cannot be changed by anyone, one can keep a secure track of transactions and rest assured that the records were not tampered with. 

Blockchain

New Block Addition in Blockchain

Similarities Between Linked List And Blockchain

The following are some of the similarities between Linked List and the Blockchain:

  • Chain: Both have a chain of data in a sequence. They are not randomly distributed.
  • Data: Both can hold data such as strings or numeric data.
  • Reference: Each block has references to another block.
  • Expansion: Both can be expanded in size.
  • Implementation: Both are implemented using a programming language.

Difference between Linked List and Blockchain

From the above explanations, it may seem like linked lists and blockchain are the same, but they are not. The following are some of the differences between Linked List and Blockchain:

Basis

Blockchain

LinkedList

Reference The reference to a block in the blockchain is given by the hash of the block. In linked lists, the reference is the memory location of that block.
Reference Direction In the blockchain, the block refers to the previous block. In a linked list, the block refers to the next block.
Expansion To add a new block, the entire chain is copied and then a new block is added to the copied chain, In a linked list, the block is simply added to the linked list without copying it.
Copies When dealing with blockchain, we have multiple copies. In a linked list, we maintain a single data chain of data without any copies.
Data Editing The data in the blockchain cannot be changed. In linked lists, it can be easily changed by simply referring to the block and putting the new value.
Purpose Blockchain is a digital ledger for transactions. A linked list is a sequential collection of data.
Control Structure Blockchain has no central control, it is distributed among people in the chain. A linked list is in a single location under the control of one party.
Block Content A block in a blockchain can also hold some code to execute, A linked list only stores solid data that can be either numerical or string data.
Security Blockchain is highly secured for authentication. The linked list doesn’t have any method for authentication.
Speed Blockchains are a little slow due to a high number of calculations. Linked Lists are faster than blockchain, as copying of the entire chain and verification is absent.
Complexity Blockchains are very complex to implement. Linked lists are easy to implement.
Feeling lost in the world of random DSA topics, wasting time without progress? It’s time for a change! Join our DSA course, where we’ll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!

Nokonwaba Nkukhwana
Experience as a skilled Java developer and proven expertise in using tools and technical developments to drive improvements throughout a entire software development life cycle. I have extensive industry and full life cycle experience in a java based environment, along with exceptional analytical, design and problem solving capabilities combined with excellent communication skills and ability to work alongside teams to define and refine new functionality. Currently working in springboot projects(microservices). Considering the fact that change is good, I am always keen to new challenges and growth to sharpen my skills.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments