- Explain what a data structure is and why the choice of data structure matters.
- Describe how a linked list connects its nodes using pointers.
- Explain how a blockchain links blocks using hash pointers instead of memory addresses.
- Compare a blockchain with a linked list on reference, editing, copies, control and security.
Data Structure?
- A data structure is a way of organising, managing and storing data in a computer so that it can be accessed and modified efficiently.
- Every data structure is a trade-off: one structure may make searching fast, another may make inserting or deleting fast. Choosing the right one directly affects the speed and memory use of a program.
- Data structures are commonly divided into:
- Linear – elements are arranged in a sequence: arrays, linked lists, stacks and queues.
- Non-linear – elements form a hierarchy or network: trees, graphs and hash tables.
- Examples :
Linked List in Data Structure
- A linked list is a linear collection of nodes. Each node holds two things: the data and a pointer (reference) to the next node.
- The first node is called the head; the last node points to
NULL, which marks the end of the list. - Unlike an array, a linked list does not need a fixed size or a continuous block of memory. Nodes can be added or removed by simply changing pointers.
- Main types: singly linked list (pointer to next), doubly linked list (pointers to next and previous) and circular linked list (last node points back to the head).
- Examples :
BLOCK-CHAIN
A NEW FORM OF DATA STRUCTURE
- A blockchain is a data structure used to build a decentralized ledger (log-book). It is made of blocks arranged one after another in a fixed order.
- Each block contains a batch of records (usually transactions) and a header. The header stores the hash of the previous block, which acts as the link in the chain.
- This link is called a hash pointer: it tells you where the previous block is and also what it contained, because any change to the previous block changes its hash.
- The first block of a chain is called the genesis block. It is the only block that has no previous block.
- A blockchain is append-only: new blocks are added at the end; old blocks are never edited or deleted.
- Examples :
How a hash pointer protects the chain
Data: Tx…
Hash: A1F3…
Data: Tx…
Hash: 7C2B…
Data: Tx…
Hash: 9E40…
If someone changes a record in Block 1, its hash changes (for example from A1F3… to 55D9…). Block 2 still stores A1F3…, so the link breaks and the tampering is immediately visible. To hide the change, the attacker would have to recompute every later block and convince the rest of the network to accept the altered copy – which consensus rules make practically impossible. (Hash values shown are shortened illustrations.)
Difference between Linked List and Blockchain
| Sno | Basis | Blockchain | LinkedList |
|---|---|---|---|
| 1 | Reference | A block refers to another block by its cryptographic hash. | A node refers to another node by its memory address (pointer). |
| 2 | Reference Direction | Each block points backwards to the previous block. | Each node usually points forwards to the next node. |
| 3 | Adding Data | A new block is validated by the network (consensus) and then appended to every node’s copy of the chain. | A node is inserted directly by the program, anywhere in the list, without any validation. |
| 4 | Copies | Many identical copies exist, one on every full node of the network. | Usually a single copy exists in the memory of one program. |
| 5 | Data Editing | Confirmed data is immutable; changing it breaks the hash links and is rejected by the network. | Any node can be changed or deleted simply by updating its value or pointers. |
| 6 | Purpose | A tamper-evident, shared digital ledger of transactions or records. | A general-purpose sequential collection of data inside a program. |
| 7 | Control Structure | No central owner; control is shared by the participants of the network. | Controlled entirely by the program (and person) that owns it. |
| 8 | Block Content | A block can contain transactions that deploy or call smart contracts (code executed by every node). | A node stores whatever data the program places in it; there is no shared execution. |
| 9 | Security | Uses hashing and digital signatures to prove integrity and authorship. | Has no built-in integrity check or authentication. |
| 10 | Speed | Slower, because every block must be verified and agreed upon by many nodes. | Very fast, because operations happen in local memory. |
| 11 | Complexity | Complex to implement: networking, cryptography and consensus are required. | Simple to implement in any programming language. |
Key Takeaways
- A blockchain can be viewed as a linked list of blocks that uses hash pointers instead of memory pointers.
- Hash pointers make the structure tamper-evident: changing any old block breaks every link after it.
- Unlike a linked list, a blockchain is replicated on many computers and grows only through consensus.
Question / Answer (15 questions)
MCQ Test : Check Your Understanding (5 questions)
Select an option and press Check Answer, or answer all questions and press Submit Test to see your score. Each answer comes with an explanation.
Bibliography/References
The notes, questions and MCQs on this page are original explanations written for this course. The works listed below were consulted and are cited for attribution and further reading. Product names, logos and trademarks belong to their respective owners. Short quotations, where used, are marked and attributed.
- GeeksforGeeks. (n.d.). How is Blockchain different from a Linked List? https://www.geeksforgeeks.org/how-is-blockchain-different-from-a-linked-list/
- Narayanan, A., Bonneau, J., Felten, E., Miller, A., & Goldfeder, S. (2016). Bitcoin and Cryptocurrency Technologies: A Comprehensive Introduction. Princeton University Press. ISBN 978-0-691-17169-2.
- Nakamoto, S. (2008). Bitcoin: A Peer-to-Peer Electronic Cash System. https://bitcoin.org/bitcoin.pdf
- Haber, S., & Stornetta, W. S. (1991). How to time-stamp a digital document. Journal of Cryptology, 3(2), 99–111. https://doi.org/10.1007/BF00196791
- Yaga, D., Mell, P., Roby, N., & Scarfone, K. (2018). Blockchain Technology Overview (NISTIR 8202). National Institute of Standards and Technology. https://doi.org/10.6028/NIST.IR.8202