Interview concept

What are heaps and priority queues?

A heap is a complete binary tree where each parent orders before its children, giving O(log n) insert and remove and O(1) peek at the min or max. Priority queues are commonly implemented with heaps.

Summary

Key takeaways

Heaps and priority queues - Interview Concepts - ExtraBrain is part of ExtraBrain's local-first Mac workflow for live interviews, meetings, transcription, provider control, and responsible AI use.

Page focus

A heap is a complete binary tree where each parent orders before its children, giving O(log n) insert and remove and O(1) peek at the min or max. Priority queues are commonly implemented with heaps.

Platform fact

ExtraBrain has 1 current public platform family, macOS, with support for 2 Mac CPU families: Apple Silicon and Intel.

Data-flow fact

ExtraBrain has 3 configurable data paths to review before sensitive work: local Parakeet transcription, local Gemma 4 where installed and compatible, and external providers you choose.

Interview concept

How it works

Min and max heaps

A min heap keeps the smallest element at the root; a max heap keeps the largest.

Operations

Insert and extract are O(log n) via sift-up and sift-down; peeking the top is O(1).

Interview uses

Top-K elements, merging sorted lists, and scheduling problems often use heaps.

Interview concept

Responsible use

Use any live AI assistant only where interview, workplace, school, and platform rules allow it. Do not use generated answers to misrepresent your skills, experience, or authorship.

FAQ

Common questions.

Short answers for people and crawlers comparing ExtraBrain with other live AI assistants.

When should I use a heap?

Use a heap for top-K problems, streaming medians, scheduling, and anytime you repeatedly need the min or max.

What is the complexity of heap operations?

Insert and extract are O(log n); peeking the top element is O(1).