データ構造(Data Structure)
コンピュータのメモリ内でデータを効率的に使用できるよう、組織化、処理、検索、保存するための専門的なフォーマット。
Web3において、マークルツリー(Merkle [Tree](/ja/terms/merkle-tree))などの特殊なデータ構造は不可欠です。これにより、ブロックチェーン全体のデータをダウンロードすることなく、トランザクションの存在をO(log N)の時間で検証できます。
graph LR
Center["データ構造(Data Structure)"]:::main
Rel_tree["tree"]:::related -.-> Center
click Rel_tree "/terms/tree"
Rel_data_type["data-type"]:::related -.-> Center
click Rel_data_type "/terms/data-type"
Rel_merkle_patricia_trie["merkle-patricia-trie"]:::related -.-> Center
click Rel_merkle_patricia_trie "/terms/merkle-patricia-trie"
classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
linkStyle default stroke:#4b5563,stroke-width:2px;
🧠 理解度チェック
🧒 5歳でもわかるように説明
100個の工具を大きな袋に放り込むと、ドライバーを探すのに時間がかかります。しかし、引き出しのついた工具箱に整理すれば、一瞬で見つかります。データ構造とは、コンピュータがデータをすぐに見つけられるようにするメモリ内の「工具箱」です。
🤓 Expert Deep Dive
抽象データ型(ADT)とデータ構造の違い:ADT(スタックやキューなど)は、どのような操作が許可されるかを定義する数学的モデルです。データ構造は、それをメモリ上でどう実装するか(配列か連結リストか)を決定します。配列は連続したメモリを使用するためアクセスがO(1)ですが、連結リストはポインタを使用するためアクセスが遅くなります。
❓ よくある質問
Why are there so many different data structures?
Because different tasks require different optimizations. If you need to search data quickly, you might use a Hash Table. If you need to keep data in a sorted hierarchy, you use a Tree. There is no single 'best' structure for everything.
What is the difference between an Array and a Linked List?
An array stores items next to each other in memory, making it very fast to jump to a specific item. A linked list stores items wherever there is free space, and each item points to the next one, making it fast to add or remove items without shifting everything else.
What is a Merkle Tree in crypto?
A Merkle Tree is a cryptographic data structure used in blockchains. It allows computers to quickly verify that a specific transaction exists in a block without having to download all the data in the block.