本文へスキップ
製品デスクトップツールTASTECAD図面の確認TASTEFILESファイル管理TASTEFTPファイル転送TASTESSHリモートワークスペースTASTEZIP圧縮と展開TASTEWINMファイル管理開発ツールTASTECODERust 統合開発環境TASTESTUDIO統合開発・テスト環境TASTEETLデータ統合(ETL)サーバーTASTEREMOTEリモートデスクトップサーバーTASTEGEO空間情報サーバーTASTEMAILメールワークスペース投資TASTESTOCK株式自動売買デスクトップアプリはじめるダウンロードドキュメント購入すべての製品
マーケットプレイス
ニュース
技術ニュース今日の開発ニュース開発ドキュメントプログラミング言語RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWebフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngularサーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Expressアプリ・デスクトップ フレームワークTauriFlutterReact NativeElectronアルゴリズムアルゴリズムの基礎主要アルゴリズム発展アルゴリズム実務のアルゴリズム
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケースコミュニティガイド
協業技術移転ウェブサイト構築デスクトップアプリ構築リリース・決済パイプライン販売パートナーお問い合わせ
サービスリモートデスクトップインストールパッケージのカスタマイズ
TASTEDEV
製品

デスクトップツール

TASTECAD複雑な図面を、軽やかにひらくTASTEFILES必要なファイルだけを、最速でTASTEFTPファイルが行き交う、いちばん端正な道TASTESSHサーバーとあなたを、より確かにつなぐTASTEZIPより速くまとめ、より安全にひらくTASTEWINM2つの画面で整理する、キーボード中心のファイルマネージャー

開発ツール

TASTECODERust アプリの編集・ビルド・デバッグ・テストまでひとつのウィンドウでTASTESTUDIO編集からリモートテスト、承認した AI 修正までTASTEETL値を見ながら、データを運ぶ

サーバー

TASTEREMOTE自社サーバーで運用するリモートデスクトップTASTEGEOGeoServer 互換の空間情報サーバーを Rust で作り直しますTASTEMAILメールの主導権を、もう一度自分の手に

投資

TASTESTOCKいつ・何を。自分で決めたルールどおりに動く株式自動売買

はじめる

ダウンロード全製品の最新版ドキュメント各製品の使い方購入サブスクリプション・永久ライセンスすべての製品全製品を一覧で
すべての製品
マーケットプレイスニュース
技術

ニュース

今日の開発ニュース言語・フレームワーク・GitHub・AI の公式発表開発ドキュメント言語・フレームワーク・アルゴリズムのガイド

プログラミング言語

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

フレームワーク

Webフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngular
サーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
アプリ・デスクトップ フレームワークTauriFlutterReact NativeElectron

アルゴリズム

アルゴリズムの基礎計算量解析 · ソート · 探索 · 基本データ構造 · 木構造とヒープ主要アルゴリズムグラフ探索 · 最短経路と最小全域木 · 動的計画法 · 貪欲法 · 分割統治法 · バックトラッキング発展アルゴリズム文字列アルゴリズム · 数学と整数論 · ビット演算 · セグメント木 · Union-Find実務のアルゴリズムコーディング面接対策 · LRUキャッシュ · レート制限 · コンシステントハッシュ法
開発ドキュメントをすべて見る
コミュニティ
プロジェクトビルダーと作品を探す開発ログ決定と試行錯誤プロンプト再利用できる指示AIツールの問題Claude・Codex・Gemini の問題と回避策ショーケース完成した成果コミュニティガイドオープンにつくる方法
協業
技術移転Rust・egui でネイティブアプリを作るウェブサイト構築10言語、アカウント、ドキュメントとダウンロードデスクトップアプリ構築Rust・egui、WebView なしリリース・決済パイプライン署名・MSI・deb・rpm・AppImage・ハッシュ販売パートナー紹介して決済額の30%お問い合わせ構築・提携・投資のご相談
サービス
リモートデスクトップブラウザから自分のパソコンへインストールパッケージのカスタマイズ必要な機能だけ、設定は事前に
購入
JA
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
ログイン
ログイン
TASTEDEV

小さなツールから、より良い開発へ。

support@tastedev.netTASTEDEVを支援
製品製品ラインナップ購入ドキュメントダウンロードマーケットプレイスサポート
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケース
ポリシー会社概要プライバシーポリシー利用規約サブスクリプション規約返金ポリシーコミュニティガイドライン
アカウントログイン新規登録
訪問者
今日
昨日
累計閲覧
商号
GXSOFT
代表者
CHOI YOUNG GU
事業者登録番号
853-44-00368
所在地
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
電話
+82-10-4404-1523
メール
whitecalvin@tastedev.net
個人情報保護責任者
CHOI YOUNG GU

© 2026 TASTEDEV製品情報は検証済みの開発ソースに基づいています。リリース・改善中

基本データ構造 ドキュメント
基本データ構造
Core ConceptsHow It WorksImplementationComplexity AnalysisPractice ProblemsReal-World Use
ディスカッション

基本データ構造 ガイド · 2/6

How It Works

この章は現在、英語でのみ提供しています。

This chapter traces each structure on a tiny example, so you can see exactly which memory moves on every operation.

A dynamic array growing

A dynamic array keeps a size (items in use) and a capacity (slots allocated). When size == capacity and you append, it allocates a block twice as large, copies the old items over and then writes the new one. Here is a trace of nine appends starting from capacity 1:

AppendSize afterCapacity afterItems copied
1110
2221
3342
4440
5584
6 to 8880
99168

Nine appends caused 1 + 2 + 4 + 8 = 15 copies, fewer than two per append. That is why appending is O(1) amortized even though a single append can cost O(n). The simulation below counts copies for any number of appends:

def count_copies(n, growth=2):
    size, capacity, copies = 0, 1, 0
    for _ in range(n):
        if size == capacity:
            copies += size            # move every item to the new block
            capacity *= growth
        size += 1
    return copies

for n in (9, 1_000, 1_000_000):
    print(n, count_copies(n), round(count_copies(n) / n, 2))
# the copies-per-append ratio stays below 2

Inserting at the front is different: every existing item shifts one slot to the right, so list.insert(0, x) costs O(n) every time, not just occasionally.

A linked list splice

A singly linked list A -> B -> D stores three nodes, each with a next reference. To insert C after B:

  1. Create node C.
  2. Set C.next = B.next (so C points to D).
  3. Set B.next = C.

Only two references change, regardless of the list length. The order of steps 2 and 3 matters: doing step 3 first loses the only reference to D. Finding B in the first place still requires walking from the head, which is O(n).

A stack checking brackets

A stack is the natural tool for anything nested. To check that is balanced, push every opening bracket and, on every closing bracket, pop and compare:

この章について質問がありますか?
前の章Core Concepts次の章Implementation
([]{})
CharActionStack after
(push(
[push( [
]pop [, matches(
{push( {
}pop {, matches(
)pop (, matchesempty

The input is balanced because every pop matched and the stack ended empty.

PAIRS = {")": "(", "]": "[", "}": "{"}

def balanced(text):
    stack = []
    for ch in text:
        if ch in "([{":
            stack.append(ch)
        elif ch in PAIRS:
            if not stack or stack.pop() != PAIRS[ch]:
                return False
    return not stack

print(balanced("([]{})"), balanced("(]"), balanced("(("))  # True False False

A queue as a ring buffer

A queue on top of a fixed array uses two indices: head (next item to remove) and tail (next free slot). Both move forward and wrap around with % capacity, so nothing is ever shifted. With capacity 4:

OperationSlotsheadtailSize
start_ _ _ _000
enqueue a, b, ca b c _033
dequeue (a)_ b c _132
enqueue d_ b c d103
enqueue ee b c d114

After e the tail wrapped to slot 0. When the buffer is full, a growable version copies the items into a larger array in queue order and resets head to 0.

A hash table with separate chaining

A hash table has an array of buckets. To store a key, compute hash(key) % bucket_count and put the pair in that bucket. With separate chaining, each bucket is a small list, and keys that collide simply share it. Using 8 buckets and integer keys whose hash is the key itself:

Keykey mod 8Bucket after insert
33bucket 3: [3]
113bucket 3: [3, 11]
66bucket 6: [6]
193bucket 3: [3, 11, 19]

Keys 3, 11 and 19 collide. Looking up 19 hashes to bucket 3 and then scans three entries. The load factor is 4 / 8 = 0.5. When it passes a threshold such as 0.75, the table doubles its bucket count and reinserts every pair, because each pair's bucket index depends on the bucket count.

def place(keys, bucket_count):
    buckets = [[] for _ in range(bucket_count)]
    for key in keys:
        buckets[hash(key) % bucket_count].append(key)
    return {i: b for i, b in enumerate(buckets) if b}

keys = [3, 11, 6, 19]
print(place(keys, 8))   # {3: [3, 11, 19], 6: [6]}
print(place(keys, 16))  # {3: [3, 19], 6: [6], 11: [11]}

Doubling to 16 buckets split the long chain. A good hash function plus a bounded load factor keeps chains short, which is where the average O(1) comes from.

Summary

A dynamic array pays for occasional copying with cheap appends, a linked list changes a couple of references per splice, a stack and a ring-buffer queue only touch their ends, and a hash table computes a bucket and scans a short chain. Tracing these on paper once makes their complexity numbers obvious instead of memorised.

コメント 0件

人気のコメント順新しい順

ログイン · ログインするとコメントできます。