Chap 10 (HEAP/B-TREES)

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

1/24

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 12:05 AM on 4/9/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

25 Terms

1
New cards

What is a heap

A heap is a binary tree where elements follow total order semantics and satisfy two rules: each node is greater than or equal to its children, and the tree is a complete binary tree

2
New cards

What are the two heap storage rules

1) Each node's element is greater than or equal to its children

2) The tree must be a complete binary tree

3
New cards

Why are heaps often implemented using arrays

Because a heap is a complete binary tree, which can be more easily represented using an array than linked nodes

4
New cards

How is a heap used in a priority queue

Each node stores an element and its priority, and the heap is maintained so that higher-priority elements are closer to the root

5
New cards

What is the first step when adding an element to a heap

Place the new element in the first available location to maintain the complete binary tree structure

6
New cards

Why might adding an element break the heap property

Because the new element may have a higher priority than its parent

7
New cards

What is reheapification upward

The process of swapping a newly added element with its parent until it reaches a valid position

8
New cards

When does reheapification upward stop

When the element reaches the root or its parent has a higher or equal priority

9
New cards

What is the first step when removing an element from a heap

Remove the root element, which has the highest priority

10
New cards

What replaces the root after removal

The last element in the deepest level is moved to the root

11
New cards

Why is reheapification downward needed

Because moving the last element to the root may violate the heap property

12
New cards

What is reheapification downward

The process of swapping the out-of-place root with its higher-priority child until the heap property is restored

13
New cards

When does reheapification downward stop

When the element reaches a leaf or has children with lower or equal priority

14
New cards

What is a B-tree

A B-tree is a tree structure where nodes can have more than two children and store multiple elements

15
New cards

Why are B-trees used

They prevent trees from becoming unbalanced and keep leaf depth small

16
New cards

What is the MINIMUM constant in a B-tree

A positive integer that determines the minimum number of elements in each node (except possibly the root)

17
New cards

What is the maximum number of elements in a B-tree node

Twice the value of MINIMUM

18
New cards

How are elements stored in a B-tree node

In a partially filled array sorted from smallest to largest

19
New cards

How many children does a non-leaf B-tree node have

One more than the number of elements in the node

20
New cards

How are subtrees organized in a B-tree

Elements in each subtree are ordered relative to the node’s elements, ensuring proper search behavior

21
New cards

What ensures a B-tree is balanced

All leaves must have the same depth

22
New cards

How does searching in a B-tree work

Check the root, and if not found, recursively search the appropriate subtree based on element comparisons

23
New cards

What is loose addition in a B-tree

A method that allows temporarily exceeding the maximum number of elements in the root before fixing it

24
New cards

Why is loose addition useful

It simplifies insertion by delaying enforcement of strict B-tree rules

25
New cards

What is the worst-case time complexity for binary trees

O(n)
What is the worst-case time complexity for heaps and B-trees