Intersection of data structures, Big O complexities, and hardware performance (CPU caches, memory hierarchy, and SIMD)

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/19

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:28 PM on 7/28/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

20 Terms

1
New cards

What is the primary cause of the "Performance Gap" in modern computer architecture?

The widening disparity in growth rates between fast CPU processing speeds and slow main memory (RAM) access times.

2
New cards

What is spatial locality in the context of CPU caching?

The tendency of a processor to access memory addresses that are physically close to those it recently accessed.

3
New cards

What is temporal locality in the context of CPU caching?

The tendency of a processor to repeatedly access the exact same memory locations within a short time frame.

4
New cards

In system programming, what is the size of a typical CPU cache line on modern architectures (x86/ARM)?

64 bytes.

5
New cards

Scenario: You are sequentially iterating through millions of items. Why do contiguous Arrays consistently outperform Linked Lists on real hardware?

Arrays exploit spatial locality, allowing the CPU hardware prefetcher to load data into cache lines in bulk. Linked List nodes are scattered, causing frequent, expensive cache misses.

6
New cards

What is the time complexity of a Linked List traversal?

O(n) time, though hardware realities make it significantly slower than an O(n) array traversal due to cache misses.

7
New cards

Struct of Arrays (SoA) vs Array of Structs (AoS): Which memory layout is strictly better for SIMD (Single Instruction, Multiple Data) vectorization?

Struct of Arrays (SoA). It packs identical data fields contiguously, allowing vector instructions to load and process them in a single operation.

8
New cards

Array of Structs (AoS) vs Struct of Arrays (SoA): When should you choose Array of Structs?

When your program typically accesses and modifies all properties of a single entity at once (improving temporal locality within a single cache line).

9
New cards

What is the space complexity of a standard Hash Table?

O(n) space.

10
New cards

Scenario: Designing an embedded system with strict real-time constraints. Why might you choose a B-Tree over a Hash Table?

B-Trees provide predictable O(log n) worst-case latency. Hash Tables have unpredictable O(n) worst-case latency spikes during collisions or dynamic resizing.

11
New cards

Why are B-Trees preferred over standard Binary Search Trees for disk-based storage and databases?

B-Tree node sizes are deliberately tuned to match disk block sizes or memory pages, drastically minimizing costly I/O operations and cache misses during traversal.

12
New cards

What is the time complexity of searching a B-Tree?

O(log n) time complexity.

13
New cards

What is a Lock-Free Data Structure?

A concurrent data structure that guarantees at least one thread makes progress, typically implemented using atomic CPU instructions like Compare-And-Swap (CAS) instead of blocking mutex locks.

14
New cards

What is a common architectural drawback of implementing Lock-Free data structures?

They are highly prone to the ABA problem and can cause severe memory bus contention from threads spinning on atomic retries.

15
New cards

What specific problem do Probabilistic Data Structures (like Bloom Filters) solve?

They answer set-membership queries with extreme space efficiency, at the cost of a small, mathematically controllable false-positive rate.

16
New cards

Can a Bloom filter produce a false negative?

No. It can only tell you if an element is "possibly in the set" (false positive possible) or "definitely not in the set" (no false negatives).

17
New cards

What is memory fragmentation in the context of custom memory allocators?

The phenomenon where free memory is broken into small, non-contiguous blocks, making it impossible to allocate a large contiguous array even if the total free memory is sufficient.

18
New cards

Scenario: You need a data structure for IP routing table lookups and efficient string prefix matching in a firmware driver. What structure should you use?

A Trie (Prefix Tree).

19
New cards

What is the average time complexity of a Hash Table lookup?

O(1) time complexity.

20
New cards

How does modifying a Linked List (insertion/deletion) compare to a Dynamic Array in terms of hardware performance?

While Linked Lists are O(1) for insertion at a known node, Dynamic Arrays (O(n) worst-case) often still outperform them for small datasets because moving contiguous memory uses highly optimized hardware-level routines (like memmove).