Vai al contenuto principale
ProdottiStrumenti desktopTASTECADVisualizzazione disegniTASTEFILESGestione fileTASTEFTPTrasferimento fileTASTESSHSpazio di lavoro remotoTASTEZIPCompressione ed estrazioneStrumenti per sviluppatoriTASTECODEAmbiente di sviluppo integrato per RustTASTESTUDIOAmbiente integrato di sviluppo e testTASTEETLIntegrazione dati (ETL)ServerTASTEREMOTEServer di desktop remotoTASTEGEOServer geospazialeTASTEMAILSpazio di lavoro emailIniziaDownloadDocumentazioneAcquistaTutti i prodotti
Marketplace
Notizie
TecnologiaNotizieNotizie di sviluppo di oggiDocumentazioneLinguaggi di programmazioneRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartFramework frontend webNext.jsReactVue.js · NuxtSvelteKitAngularFramework serverSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressFramework per app e desktopTauriFlutterReact NativeElectronAlgoritmiBasi degli algoritmiAlgoritmi fondamentaliAlgoritmi avanzatiAlgoritmi pratici
CommunityProgettiLog di sviluppoPromptProblemi degli strumenti di IAVetrinaGuida alla community
CollaboraTrasferimento tecnicoRealizzazione del sito webRealizzazione di app desktopPipeline di rilascio e pagamentoPartner commercialeContatti
ServiziDesktop remotoPacchetti di installazione su misura
TASTEDEV
Prodotti

Strumenti desktop

TASTECADApri con leggerezza anche i disegni più complessiTASTEFILESSolo i file che servono, alla massima velocitàTASTEFTPLa via più ordinata per i tuoi fileTASTESSHUn legame più solido tra te e i tuoi serverTASTEZIPComprimi più veloce, estrai più sicuro

Strumenti per sviluppatori

TASTECODEModifica, compila, esegui il debug e testa app Rust in un'unica finestraTASTESTUDIODalla modifica ai test remoti e alle correzioni IA approvateTASTEETLSposta i dati guardando i valori

Server

TASTEREMOTEUn desktop remoto che gira sul tuo serverTASTEGEOUn server geospaziale compatibile con GeoServer, ricostruito in RustTASTEMAILRiprendi il controllo della tua posta

Inizia

DownloadUltime versioni di ogni prodottoDocsCome usare ogni prodottoAcquistaAbbonamenti e licenze perpetueTutti i prodottiTutti i prodotti a colpo d’occhio
Tutti i prodotti
MarketplaceNotizie
Tecnologia

Notizie

Notizie di sviluppo di oggiAnnunci ufficiali su linguaggi, framework, GitHub e IADocumentazioneGuide a linguaggi, framework e algoritmi

Linguaggi di programmazione

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Framework

Framework frontend webNext.jsReactVue.js · NuxtSvelteKitAngular
Framework serverSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
Framework per app e desktopTauriFlutterReact NativeElectron

Algoritmi

Basi degli algoritmiAnalisi della complessità · Ordinamento · Ricerca · Strutture dati di base · Alberi e heapAlgoritmi fondamentaliVisita dei grafi · Cammini minimi e alberi ricoprenti · Programmazione dinamica · Algoritmi greedy · Divide et impera · BacktrackingAlgoritmi avanzatiAlgoritmi sulle stringhe · Matematica e teoria dei numeri · Manipolazione dei bit · Alberi di segmenti · Union-FindAlgoritmi praticiStrategia per colloqui di programmazione · Cache LRU · Rate limiting · Hashing consistente
Tutta la documentazione di sviluppo
Community
ProgettiScopri sviluppatori e lavoriLog di sviluppoDecisioni e lezioni appresePromptIstruzioni riutilizzabiliProblemi degli strumenti di IAProblemi e alternative di Claude, Codex, GeminiVetrinaRisultati completatiGuida alla communityCome sviluppiamo in modo aperto
Collabora
Trasferimento tecnicoApp native in Rust ed eguiRealizzazione del sito web10 lingue, account, documentazione e downloadRealizzazione di app desktopRust ed egui, senza WebViewPipeline di rilascio e pagamentoFirma, MSI, deb, rpm, AppImage, hashPartner commercialeConsigliaci e ricevi il 30%ContattiSviluppo, partnership e investimenti
Servizi
Desktop remotoRaggiungi il tuo computer dal browserPacchetti di installazione su misuraSolo il necessario, impostazioni precaricate
Acquista
IT
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Accedi
Accedi
TASTEDEV

Dai piccoli strumenti a uno sviluppo migliore.

support@tastedev.netSostieni TASTEDEV
ProdottiGamma di prodottiAcquistaDocsDownloadMarketplaceAssistenza
CommunityProgettiLog di sviluppoPromptProblemi degli strumenti di IAVetrina
NormeInformativa sulla privacyTermini di servizioCondizioni di abbonamentoRimborsiLinee guida della community
AccountAccediRegistrati
Visitatori
Oggi
012345678901234567890123456789012345678901234567890123456789
Ieri
012345678901234567890123456789012345678901234567890123456789
Visualizzazioni totali
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Società
GXSOFT
Rappresentante
CHOI YOUNG GU
Numero di registrazione
853-44-00368
Indirizzo
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Telefono
+82-10-4404-1523
E-mail
whitecalvin@tastedev.net
Responsabile privacy
CHOI YOUNG GU

© 2026 TASTEDEVLe informazioni sui prodotti si basano su fonti di sviluppo verificate.Rilasciato · in miglioramento

Documentazione di Strutture dati di base
Strutture dati di base
Core ConceptsHow It WorksImplementationComplexity AnalysisPractice ProblemsReal-World Use
Discussioni

Guida a Strutture dati di base · 4/6

Complexity Analysis

Per ora questo capitolo è disponibile solo in inglese.

Big-O tells you how cost grows with n, the number of stored items. For basic data structures the interesting part is that the same operation can be O(1) on one structure and O(n) on another, and that some O(1) figures are averages or amortized rather than guaranteed.

Operation costs side by side

OperationDynamic arrayLinked list (doubly)Deque (ring buffer)Hash table
Access k-th itemO(1)O(n)O(1)not supported
Search by valueO(n)O(n)O(n)O(1) average by key
Insert / delete at endO(1) amortizedO(1)O(1) amortizedn/a
Insert / delete at frontO(n)O(1)O(1) amortizedn/a
Insert / delete in the middleO(n)O(1) once the node is foundO(n)n/a
Insert / delete by keyn/an/an/aO(1) average, O(n) worst
Extra memory per itemsmall (spare capacity)two pointers per nodesmallbucket array plus chain nodes

Stacks and queues are restrictions of these structures, so a stack on a dynamic array has O(1) amortized push and pop, and a queue on a ring buffer or linked list has O(1) enqueue and dequeue.

Amortized O(1) append

A single append to a full dynamic array copies all n items, which is O(n). Over a sequence of n appends with doubling, the copies are 1 + 2 + 4 + ... + n/2 + n, which is less than 2n. Total work is O(n), so the cost per append is O(1) amortized.

The growth factor matters. Growing by a constant amount (say 10 slots each time) makes the copies 10 + 20 + 30 + ..., which is O(n squared) in total. Any constant multiplier greater than 1 keeps appends O(1) amortized; libraries trade memory for speed by choosing 1.5, 2 or a small over-allocation as CPython does.

def total_copies(n, grow):
    size, cap, copies = 0, 1, 0
    for _ in range(n):
        if size == cap:
            copies += size
            cap = grow(cap)
        size += 1
    return copies

n = 100_000
print("x2   :", total_copies(n, lambda c: c * 2))       # about 1.3 * n
print("x1.5 :", total_copies(n, lambda c: c + c // 2 + 1))
print("+10  :", total_copies(n, lambda c: c + 10))      # about n * n / 20
Domande su questo capitolo?
Capitolo precedenteImplementationCapitolo successivoPractice Problems

Hash tables: average vs worst case

With m buckets and n keys, the load factor is alpha = n / m. If the hash function spreads keys evenly, the expected chain length is alpha, so a lookup costs O(1 + alpha). Keeping alpha below a constant (0.75 in Java's HashMap, 1.0 by default in C++'s std::unordered_map) makes it O(1) on average. Resizing costs O(n) when it happens, but like array growth it is O(1) amortized per insert.

The worst case is O(n): if every key lands in one bucket, the table degenerates into a list. This happens with a poor hash function or with adversarial input crafted to collide (hash flooding). Python randomizes string hashes per process for this reason, and Java's HashMap turns very long chains into balanced trees so the worst case becomes O(log n).

Measuring it yourself

Complexity tables are easy to verify with a timer. Removing from the front is the classic trap:

from collections import deque
from timeit import timeit

def drain_list(n):
    items = list(range(n))
    while items:
        items.pop(0)          # shifts every remaining item

def drain_deque(n):
    items = deque(range(n))
    while items:
        items.popleft()       # moves one index

n = 100_000
print("list.pop(0)    ", timeit(lambda: drain_list(n), number=1))
print("deque.popleft()", timeit(lambda: drain_deque(n), number=1))

The list version is quadratic in total and at this size is often a hundred times slower or more. Membership tests show the hash table advantage:

from timeit import timeit

items = list(range(10_000))
as_set = set(items)
probes = range(0, 20_000, 7)
print("list:", timeit(lambda: sum(p in items for p in probes), number=1))
print("set :", timeit(lambda: sum(p in as_set for p in probes), number=1))

Python's built-in types

TypeOperationAverage cost
listx[i], append, pop()O(1) (append amortized)
listinsert(0, x), pop(0), x in listO(n)
dequeappend, appendleft, pop, popleftO(1)
dequed[i] in the middleO(n)
dict / setget, set, delete, inO(1) average, O(n) worst

Space

All five structures use O(n) space, but the constants differ. A dynamic array may hold up to about twice the slots it needs right after growing. A doubly linked list stores two pointers per item, which on a 64-bit machine is 16 bytes of overhead before counting the value. Hash tables cap the load factor at a limit such as 0.75 or 1, so many buckets stay empty, and chaining adds a node per entry.

Summary

Arrays give O(1) indexing and amortized O(1) appends, linked structures give O(1) splicing at known positions, and hash tables give O(1) average key operations with an O(n) worst case. Amortized and average figures are reliable in practice as long as growth is geometric and the hash function spreads keys well; measure when in doubt.

0 commenti

Commenti principaliPrima i più recenti

Accedi · Accedi per lasciare un commento.