Skip to main content
ProductsDesktop toolsTASTECADDrawing reviewTASTEFILESFile managementTASTEFTPFile transferTASTESSHRemote workspaceTASTEZIPCompression and extractionTASTEWINMFile managementDeveloper toolsTASTECODERust integrated development environmentTASTESTUDIOIntegrated development and test environmentTASTEETLData integration (ETL)ServersTASTEREMOTERemote desktop serverTASTEGEOGeospatial serverTASTEMAILMail workspaceInvestingTASTESTOCKStock auto-trading desktop appGet startedDownloadsDocumentationBuyAll products
Marketplace
News
TechNewsToday's dev newsDeveloper docsProgramming languagesRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp & desktop frameworksTauriFlutterReact NativeElectronAlgorithmsAlgorithm basicsCore algorithmsAdvanced algorithmsPractical algorithms
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcaseCommunity guide
Work with usTech transferWebsite buildDesktop app buildRelease and payment pipelineSales partnerContact
ServicesRemote desktopCustom installer packages
TASTEDEV
Products

Desktop tools

TASTECADComplex drawings, opened with easeTASTEFILESJust the files you need, as fast as possibleTASTEFTPThe tidiest path for your filesTASTESSHA stronger link between you and your serversTASTEZIPPack faster, unpack saferTASTEWINMA keyboard-first file manager with two panes

Developer tools

TASTECODEEdit, build, debug and test Rust apps in one windowTASTESTUDIOFrom editing to remote tests and approved AI fixesTASTEETLMove data while you watch the values

Servers

TASTEREMOTEA remote desktop you run on your own serverTASTEGEORebuilding a GeoServer-compatible geospatial server in RustTASTEMAILTake back control of your email

Investing

TASTESTOCKStock auto-trading that follows the rules you set: when, and what

Get started

DownloadsLatest builds of every productDocsHow to use each productBuySubscriptions and perpetual licencesAll productsEvery product at a glance
All products
MarketplaceNews
Tech

News

Today's dev newsOfficial announcements on languages, frameworks, GitHub and AIDeveloper docsGuides to languages, frameworks and algorithms

Programming languages

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App & desktop frameworksTauriFlutterReact NativeElectron

Algorithms

Algorithm basicsComplexity analysis · Sorting · Searching · Basic data structures · Trees and heapsCore algorithmsGraph traversal · Shortest paths & minimum spanning trees · Dynamic programming · Greedy algorithms · Divide and conquer · BacktrackingAdvanced algorithmsString algorithms · Math and number theory · Bit manipulation · Segment trees · Union-findPractical algorithmsCoding interview strategy · LRU cache · Rate limiting · Consistent hashing
All development docs
Community
ProjectsDiscover builders and their workDevelopment logsDecisions and lessons learnedPromptsReusable instructionsAI tool issuesProblems and workarounds for Claude, Codex, GeminiShowcaseFinished resultsCommunity guideHow we build in the open
Work with us
Tech transferNative apps in Rust and eguiWebsite build10 languages, accounts, docs and downloadsDesktop app buildRust and egui, no WebViewRelease and payment pipelineSigning, MSI, deb, rpm, AppImage, hashesSales partnerRecommend us and earn 30%ContactBuilds, partnerships and investment
Services
Remote desktopReach your computer from a browserCustom installer packagesOnly the features you need, settings preloaded
Buy
EN
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Log in
Log in
TASTEDEV

From small tools to better development.

support@tastedev.netSupport TASTEDEV
ProductsProduct lineupBuyDocsDownloadsMarketplaceSupport
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcase
PoliciesAbout usPrivacy policyTerms of serviceSubscription termsRefund policyCommunity guidelines
AccountLog inSign up
Visitors
Today
Yesterday
Total views
Company
GXSOFT
Representative
CHOI YOUNG GU
Business registration number
853-44-00368
Address
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Phone
+82-10-4404-1523
Email
whitecalvin@tastedev.net
Privacy officer
CHOI YOUNG GU

© 2026 TASTEDEVProduct information is based on verified development sources.Released · improving

Basic data structures docs
Basic data structures
Core ConceptsHow It WorksImplementationComplexity AnalysisPractice ProblemsReal-World Use
Discussions

Basic data structures guide · 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:

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.

Questions about this chapter?
Previous chapterCore ConceptsNext chapterImplementation

0 comments

Top commentsNewest first

Sign in · Sign in to leave a comment.