Data Structures

Chapter 15
Contemporary Systems, AI, Ethics, and Future Directions

Bachelors Program in IT
Data Structures   •   Bachelor

Contemporary Systems, AI, Ethics, and Future Directions

Introduction

Data structures are no longer confined to a single program running on one processor. Modern information systems operate across many cores, machines, accelerators, storage tiers, and administrative boundaries. They must process streams, tolerate failures, protect personal information, support artificial-intelligence (AI) workloads, and remain understandable to users and regulators. Consequently, the design of a data structure involves more than asymptotic time and space complexity. Correctness under concurrency, communication cost, mutability, energy consumption, security, fairness, and governance are also design concerns.

This chapter examines contemporary structures and design approaches that extend the foundations of arrays, linked lists, trees, hash tables, graphs, and indexes. It emphasizes the trade-offs rather than presenting any one structure as universally superior.

Learning Objectives

By the end of this chapter, students should be able to:

  • explain concurrent, lock-free, immutable, distributed, GPU-aware, vector-index, knowledge-graph, and approximate-nearest-neighbor structures;
  • distinguish safety, liveness, consistency, availability, and performance properties;
  • select structures for AI, analytical, transactional, and distributed workloads;
  • evaluate privacy, security, fairness, energy, and governance implications;
  • interpret recall, latency, throughput, scalability, and memory trade-offs;
  • discuss emerging research directions critically.

1. Beyond the Sequential Data Structure

A traditional data-structure analysis assumes one thread, uniform memory, and a failure-free machine. Contemporary systems violate all three assumptions. A useful design question is therefore: which costs and failure modes matter in the intended environment?

For a parallel or distributed operation, elapsed time is not determined only by the number of abstract operations. A simple performance model is:

Ttotal = Tcompute + Tmemory + Tcommunication + Tsynchronization + Tfailure

Here, each term is elapsed time attributable to computation, memory movement, communication, synchronization, and recovery or retry. The terms are workload- and platform-dependent; they are not necessarily independent, and they should not be added if the implementation overlaps them. The model is useful as a checklist rather than a universal prediction equation.

A related measure is speedup:

S(p) = T1 / Tp

where T1 is execution time on one processing unit and Tp is execution time on p units, for the same workload and correctness requirement. Ideal speedup is p, but communication, serial work, contention, and load imbalance usually reduce it.

2. Concurrent and Lock-Free Structures

2.1 Concurrency and correctness

A concurrent data structure permits operations from multiple threads to overlap. Its correctness must be specified using a concurrency model. Linearizability requires each operation to appear to take effect at one instant between invocation and response, preserving real-time ordering of non-overlapping operations. It is intuitive but may require expensive synchronization. Sequential consistency requires an ordering consistent with each thread's program order, but not necessarily with wall-clock ordering between threads.

Two broad correctness properties are important:

  • Safety: nothing bad happens, such as returning an impossible value or losing an update.
  • Liveness: something good eventually happens, such as an operation completing.

A lock can provide mutual exclusion, but poor lock design creates deadlock, priority inversion, convoying, or excessive contention.

2.2 Lock-free and wait-free methods

A non-blocking algorithm avoids conventional mutual-exclusion locks. A lock-free algorithm guarantees system-wide progress: in a finite number of steps, some thread completes, although an individual thread may repeatedly fail. A wait-free algorithm guarantees that every operation completes within a bounded number of its own steps. Wait-free guarantees are stronger and often more difficult to achieve.

A common primitive is compare-and-swap (CAS). Conceptually, CAS(address, expected, replacement) changes a memory location only if its current value equals expected. A thread can read a node, construct a new state, and attempt CAS. If another thread changed the state first, CAS fails and the operation retries.

A classic lock-free stack uses a linked top pointer. Push creates a node whose next field is the observed top and CASes top from the observed value to the new node. Pop reads top and its successor, then CASes top to the successor. Correct implementations must address the ABA problem: a pointer may change from A to B and back to A, making a simple equality test misleading. Version tags, hazard pointers, epochs, or garbage-collected memory can help.

Memory reclamation is often harder than the update algorithm. A removed node cannot be freed while another thread might still dereference it. Hazard pointers allow threads to publish nodes they may access; epoch-based reclamation delays freeing until all readers have moved beyond the relevant epoch. These methods add metadata and scanning overhead.

2.3 Choosing synchronization

Use locks when critical sections are short, contention is moderate, and simplicity is valuable. Consider lock-free methods for highly contended shared structures, real-time-sensitive paths, or systems where blocking is unacceptable. Benchmarking must include tail latency, not only average throughput: a design that improves average time but causes rare very long delays may be unsuitable for interactive or safety-critical services.

3. Immutable and Persistent Structures

An immutable object cannot be changed after construction. An update creates a new version, often sharing unchanged substructure with the old version. This is called structural sharing. A persistent vector, for example, can use a shallow tree with a high branching factor so that an update copies only the nodes along one root-to-leaf path.

Immutability simplifies reasoning: readers need no locks for stable objects, historical versions support undo and auditing, and speculative computations can be discarded safely. Its costs include allocation, garbage collection, indirection, and possible cache inefficiency. Persistent structures are therefore especially useful in functional programming, configuration management, compilers, event sourcing, and concurrent read-heavy services.

An immutable structure does not automatically provide privacy or security. A deleted logical value may remain in old versions, caches, logs, snapshots, or memory pages. Retention policies and secure disposal must be designed separately.

4. Distributed Data Structures

A distributed data structure spans multiple machines or administrative domains. Examples include distributed hash tables, replicated logs, partitioned indexes, distributed graphs, and sharded key-value stores.

4.1 Partitioning and replication

Partitioning divides data among nodes. Hash partitioning usually balances keys but makes range queries difficult. Range partitioning supports ordered scans but can create hotspots when key distributions are skewed. Replication improves availability and read capacity, but introduces consistency and coordination costs.

A system may offer strong consistency, eventual consistency, or an intermediate model. Strongly consistent reads reflect an ordering agreed by the system; eventual consistency allows temporary divergence but promises convergence if updates stop and communication continues. Neither is universally correct: financial authorization may need strong consistency, while social-media counters may tolerate eventual convergence.

Distributed systems also face network partitions. The CAP theorem is best understood as a constraint during a partition: a system cannot simultaneously guarantee both availability for every request and strong consistency for all operations. It does not claim that consistency or availability is permanently impossible, nor does it eliminate latency and failure considerations.

4.2 Distributed hash tables and sketches

A distributed hash table maps keys to responsible nodes, often using consistent hashing. When nodes join or leave, consistent hashing can limit the fraction of keys that move, although virtual nodes and replication are commonly required for balance and fault tolerance.

Large-scale analytics often use compact probabilistic structures. A Bloom filter answers set-membership queries with possible false positives but no false negatives, assuming standard insertion and query behavior and no unsupported deletion. Counting Bloom filters permit deletion by replacing bits with counters, at additional space and overflow risk. HyperLogLog estimates cardinality with small memory but is approximate. Such structures are valuable for cache admission, deduplication, routing, and telemetry, but their error characteristics must be communicated to users.

5. GPU-Aware and Heterogeneous Structures

Graphics processing units (GPUs) contain many arithmetic units and high memory bandwidth, making them effective for regular, data-parallel operations. Dense arrays, compressed sparse matrices, graph frontiers, and batches of vectors can be arranged for coalesced memory access. A GPU is less effective when operations involve irregular pointers, frequent branching, fine-grained synchronization, or repeated host-device transfers.

A practical design separates:

  1. host-side orchestration and control flow;
  2. device-resident data and kernels;
  3. transfer and synchronization boundaries.

Structure of arrays can outperform array of structures when a kernel processes one field across many records, because adjacent threads access adjacent values. Conversely, array of structures may be convenient when every operation uses all fields of one record. Layout is therefore workload-specific.

Sparse data structures illustrate the trade-off. Coordinate format stores row, column, and value triples and is easy to construct. Compressed sparse row stores row offsets, column indices, and values, supporting efficient row traversal and sparse matrix-vector multiplication. GPU performance depends on sparsity pattern, load balance, precision, and memory bandwidth—not merely on the number of nonzero entries.

Energy should be measured along with speed. A useful empirical quantity is energy per operation:

Eop = Etotal / Nop

where Etotal is measured energy, in joules, and Nop is the number of completed operations. The metric is meaningful only when the operation, workload, hardware state, and measurement boundary are clearly specified.

6. Vector Indexes and Approximate Nearest Neighbors

AI systems often represent documents, images, users, or products as vectors. A nearest-neighbor query seeks items close to a query vector under a chosen distance or similarity measure. For Euclidean distance:

d(x,y) = √(∑i=1d(xi - yi)2)

Here, x and y are vectors of dimension d, and components must be comparable and consistently scaled. Cosine similarity is:

cos(θ) = (x · y) / (||x|| ||y||)

It is defined for nonzero vectors and emphasizes direction rather than magnitude.

Exact search compares the query with every vector, requiring time proportional to the number of stored vectors times dimension for a straightforward implementation. Approximate-nearest-neighbor (ANN) methods trade a controlled reduction in accuracy for lower latency and memory or compute cost.

Important families include:

  • tree and partition methods, which divide vector space but degrade in very high dimensions;
  • inverted-file indexes, which assign vectors to coarse clusters and search selected clusters;
  • graph indexes, such as navigable proximity graphs, which traverse links toward promising candidates;
  • product quantization, which compresses vectors by encoding subvectors with learned codebooks.

Recall at k is commonly defined as:

Recall@k = (number of true top-k neighbors retrieved) / k

This assumes a known exact ground truth and a fixed query set. Recall must be reported together with latency, memory, build time, and workload distribution. A high recall average can hide poor performance for minority languages, rare users, or difficult queries.

Vector indexes do not understand meaning automatically. Embedding quality, stale vectors, adversarial inputs, duplicated content, and distance-metric mismatch can dominate index quality. Metadata filters, access controls, deletion propagation, and tenant isolation are essential in production retrieval-augmented generation systems.

7. Knowledge Graphs

A knowledge graph represents entities and relationships, commonly as triples (subject, predicate, object). For example, (Library, holds, Book) expresses a typed relation. Property graphs attach labels and properties to nodes and edges; RDF graphs use triples and support semantic-web standards.

Graph stores support relationship traversal, entity resolution, provenance, and multi-hop reasoning. Query languages such as SPARQL or property-graph query languages allow pattern matching. Indexes may be built on subject, predicate, object, labels, or frequently used properties.

Knowledge graphs face ontology alignment, incomplete data, contradictory sources, temporal validity, and provenance challenges. An inferred relationship should be distinguishable from a directly observed one. In AI applications, graphs can constrain retrieval and expose explanations, but a graph is not automatically unbiased or truthful: its sources and construction process determine what is represented and what is omitted.

8. Privacy, Security, Fairness, and Governance

Data-structure choices can create or reduce risk. A hash table containing identifiers may leak through timing, memory access patterns, or predictable hashes. Adversaries can exploit hash flooding, poisoned vector entries, graph injection, malformed serialized structures, or denial-of-service workloads. Defenses include authenticated access, input limits, collision-resistant hashing where appropriate, constant-time operations for sensitive comparisons, encryption, integrity checks, isolation, and rigorous memory-safety practices.

Privacy requires attention to the entire lifecycle: collection, indexing, replication, backup, query, retention, and deletion. Access-control lists and tenant-aware indexes should be enforced before retrieval, not merely after a large result set is assembled. Differential privacy provides a formal framework for limiting the effect of one person's data on an output. For a randomized mechanism M, differential privacy with parameters ε and δ requires, for neighboring datasets D and D′ and every output set S,

P[M(D) ∈ S] ≤ e^ε P[M(D′) ∈ S] + δ

Here, ε controls the primary privacy-loss scale, δ is a small failure probability, and the definition assumes a clearly specified neighboring-dataset relation. Privacy budgets compose across repeated releases; therefore, adding noise once does not make unlimited querying safe.

Fairness is not a single data-structure property. It concerns representation, access, error rates, ranking exposure, and downstream effects. A vector index may have unequal recall across demographic or language groups because embeddings, data density, or filters differ. Evaluation should disaggregate relevant metrics, document missingness, involve affected stakeholders, and avoid treating demographic categories as interchangeable proxies for identity or worth.

Governance connects technical controls with organizational accountability. Essential practices include data inventories, provenance, retention schedules, model and index versioning, audit logs, access reviews, incident response, deletion testing, change approval, and documented risk assessments. Regulations vary by jurisdiction; technical teams should consult applicable privacy, consumer-protection, accessibility, cybersecurity, and AI-governance obligations rather than assuming that a model or index is exempt because it is probabilistic.

9. A Detailed Illustrative Case: Public-Service Document Retrieval

Background

A fictional government information portal must retrieve relevant policy documents for citizens and support an assistant that answers questions using cited sources. Documents contain multiple languages, personal information, legal revisions, and access restrictions.

Problem

Keyword search misses paraphrases and multilingual expressions. A purely vector-based system returns semantically similar but legally obsolete documents. The organization also needs deletion, auditability, low latency, and equitable performance.

Analysis

The engineering team identifies four distinct needs: lexical matching for exact legal terms, semantic matching for paraphrases, relationship-aware retrieval for agencies and effective dates, and governance for access and provenance. Average latency alone is inadequate; the team measures p95 latency, recall@k against a reviewed benchmark, citation validity, subgroup performance, energy per query, and unauthorized-retrieval rate.

Approach and Solution

Documents are stored in immutable, versioned records. A text index supports exact terms, an ANN index supports embeddings, and a knowledge graph records agencies, topics, amendments, and effective intervals. A query first applies authorization and jurisdiction filters, then combines lexical and vector candidates. Graph constraints remove superseded documents and identify relevant relationships. Results retain source identifiers and version timestamps. A deletion workflow removes or tombstones content across primary indexes, replicas, caches, and backups according to the retention policy.

The system uses a human-reviewed evaluation set stratified by language and document type. It reports recall and citation correctness separately: retrieving a relevant passage does not guarantee that the generated answer is legally supported. Monitoring detects embedding drift, index staleness, access anomalies, and performance disparities.

Outcome

The hybrid design improves coverage without allowing semantic similarity to override legal validity. Immutable versions support audit investigations, while explicit graph relationships make effective dates visible. The system remains imperfect: new terminology may be underrepresented, translation quality varies, and deletion across backups has operational cost.

Learning Points

No single data structure solves the complete problem. The appropriate architecture combines structures with different strengths, places authorization before retrieval, measures subgroup and tail behavior, and treats provenance and lifecycle management as first-class requirements.

10. Emerging Directions and Professional Practice

Current research explores learned indexes, which use models to predict data locations; differentiable data structures that expose structure to optimization; transactional and persistent memory; confidential computing; compressed and hardware-aware graph processing; neuromorphic and near-data computation; and retrieval systems that combine symbolic graphs with neural representations.

Learned indexes can reduce search work when data distributions are stable, but they require fallback mechanisms, retraining policies, and worst-case analysis. Self-adjusting and adaptive structures can respond to workload changes, yet adaptation may complicate reproducibility and create feedback loops. Hardware trends increasingly make memory hierarchy, serialization, accelerators, and network topology part of the algorithmic design.

Best practice is to begin with a workload specification: operation mix, data size and growth, consistency, durability, latency percentiles, failure model, privacy classification, deletion requirements, and energy target. Select a simple baseline, measure it using representative data, and compare alternatives using reproducible experiments. Document assumptions, monitor production drift, test adversarial inputs, and design migration and rollback procedures before deployment.

Chapter Summary

Contemporary data structures operate under concurrency, distribution, heterogeneity, and uncertainty. Lock-free and wait-free structures reduce blocking but introduce progress, memory-reclamation, and ABA concerns. Immutable and persistent structures simplify sharing and versioning at the cost of allocation and storage. Distributed structures require explicit decisions about partitioning, replication, consistency, failures, and communication. GPU-aware layouts exploit parallel hardware when access is regular and data movement is controlled.

Vector indexes and ANN methods make high-dimensional AI retrieval practical by trading exactness for latency, memory, and build cost. Knowledge graphs represent entities, relationships, provenance, and temporal meaning, complementing rather than replacing vector retrieval. Privacy, security, fairness, energy, and governance must be evaluated across the full data lifecycle. The professional designer therefore optimizes not merely asymptotic complexity, but also correctness, accountability, resilience, and social impact.

Key Terms

Concurrent data structure: A structure designed for overlapping operations from multiple threads.

Linearizability: The property that each concurrent operation appears instantaneous and respects real-time order.

Lock-free: A progress guarantee that some thread completes in a finite number of steps.

Wait-free: A stronger guarantee that every operation completes within a bounded number of its own steps.

Compare-and-swap: An atomic conditional update primitive.

ABA problem: A change from value A to B and back to A that can defeat a simple equality check.

Hazard pointer: Published metadata identifying a node that a thread may dereference.

Immutability: The inability to change an object after construction.

Structural sharing: Reuse of unchanged components between versions.

Distributed hash table: A partitioned key-value structure spread across networked nodes.

Bloom filter: A compact probabilistic membership structure with possible false positives.

GPU-aware structure: A layout designed for accelerator memory access and parallel execution.

Vector index: An index supporting similarity search over numerical representations.

Approximate nearest neighbor: A search method that sacrifices some exactness for efficiency.

Recall@k: The fraction of true top-k neighbors retrieved.

Knowledge graph: A graph of entities and typed relationships, often with provenance.

Differential privacy: A formal limitation on how much one person's data affects an output.

Data provenance: Information about the origin, transformation, and version of data.

Tail latency: A high-percentile response-time measure, such as p95 or p99.

Governance: Policies, responsibilities, controls, and processes directing data and system use.

Review Questions

Short Answer Questions

  1. Distinguish lock-free from wait-free progress guarantees.
  2. Why is memory reclamation difficult in lock-free linked structures?
  3. State one advantage and one limitation of immutable data structures.
  4. What does recall@k measure in an ANN index?
  5. Why should provenance be retained in a knowledge graph?

Long Answer Questions

  1. Compare lock-based, lock-free, and wait-free structures in terms of correctness, progress, implementation complexity, and practical use.
  2. Explain how partitioning, replication, consistency, and network failure interact in a distributed data structure.
  3. Discuss the conditions under which GPU-aware layouts improve performance and the conditions under which they may not.
  4. Compare exact vector search with ANN methods, including latency, memory, recall, build cost, and operational risks.
  5. Explain why privacy, fairness, security, and governance must be considered across the complete index lifecycle.

Analytical / Application Questions

  1. Design a retrieval architecture for a multilingual legal-document service. Specify the roles of lexical indexes, vector indexes, a knowledge graph, versioning, and authorization.
  2. An ANN system has excellent average recall but substantially lower recall for one language group. Propose an evaluation and remediation plan that avoids concealing the disparity.
  3. A high-throughput shared queue experiences lock contention and rare long delays. Analyze whether a lock-free design is justified, identifying progress, memory-reclamation, observability, and energy considerations.

Multiple Choice Questions with Answers

Question 1

Which progress guarantee ensures that every individual operation completes within a bounded number of its own steps?

A. Eventual consistency

B. Lock-free

C. Wait-free

D. Sequential consistency

Correct Answer: C. Wait-free

Question 2

The ABA problem occurs when a shared value:

A. is encrypted before storage

B. changes from A to B and back to A

C. is copied between GPUs

D. is deleted from a Bloom filter

Correct Answer: B. changes from A to B and back to A

Question 3

What is a principal advantage of structural sharing?

A. It eliminates all memory use

B. It reuses unchanged components across versions

C. It guarantees differential privacy

D. It prevents all cache misses

Correct Answer: B. It reuses unchanged components across versions

Question 4

A Bloom filter can normally produce which type of error?

A. False positive

B. False negative for a correctly inserted item

C. Incorrect vector dimension

D. Deadlock

Correct Answer: A. False positive

Question 5

In a distributed system, range partitioning is particularly useful for:

A. Ordered range queries

B. Eliminating all hotspots

C. Guaranteeing zero communication

D. Replacing replication

Correct Answer: A. Ordered range queries

Question 6

Which condition most favors GPU acceleration?

A. Irregular pointer chasing with frequent branching

B. Small sequential workloads with constant synchronization

C. Regular, data-parallel computation with controlled data movement

D. Operations requiring exclusive access to every record

Correct Answer: C. Regular, data-parallel computation with controlled data movement

Question 7

Recall@k measures:

A. The fraction of true top-k neighbors retrieved

B. The number of index-building threads

C. The storage size of an embedding

D. The probability of a hash collision

Correct Answer: A. The fraction of true top-k neighbors retrieved

Question 8

A knowledge graph primarily represents:

A. Only encrypted byte arrays

B. Entities and typed relationships

C. GPU instruction schedules

D. Operating-system processes

Correct Answer: B. Entities and typed relationships

Question 9

In differential privacy, ε primarily controls:

A. The dimensionality of a vector

B. The primary scale of privacy loss

C. The number of graph edges

D. The GPU clock frequency

Correct Answer: B. The primary scale of privacy loss

Question 10

Why should ANN evaluation report latency together with recall?

A. Recall and latency are always identical

B. A high-recall index may still violate response-time requirements

C. Latency determines demographic identity

D. Recall cannot be measured with ground truth

Correct Answer: B. A high-recall index may still violate response-time requirements

Data Structures
Chapter 15 of 15