Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

DATA STRUCTURES HEAPS EXAM QUESTIONS AND ANSWERS

Rating
-
Sold
-
Pages
2
Grade
A+
Uploaded on
28-07-2025
Written in
2024/2025

DATA STRUCTURES HEAPS EXAM QUESTIONS AND ANSWERS

Institution
DATA STRUCTURES
Course
DATA STRUCTURES

Content preview

DATA STRUCTURES HEAPS EXAM
QUESTIONS AND ANSWERS



max-heap - Correct Answers -A binary tree that maintains the simple property that a
node's key is greater than or equal to the node's children's keys

A max-heap's root must have the maximum key.

Max-heap insert - Correct Answers -An insert into a max-heap starts by inserting the
node in the tree's last level, and then swapping the node with its parent until no max-
heap property violation occurs. Inserts fill a level (left-to-right) before adding another
level, so the tree's height is always the minimum possible. The upward movement of a
node in a max-heap is sometime called percolating.

Max-heap remove - Correct Answers -A remove from a max-heap is always a removal
of the root, and is done by replacing the root with the last level's last node, and
swapping that node with its greatest child until no max-heap property violation occurs.
Because upon completion that node will occupy another node's location (which was
swapped upwards), the tree height remains the minimum possible.

Given N nodes, what is the height of a max-heap? - Correct Answers -logN

what is the worst-case complexity of an insert,
complexity for removing root - Correct Answers -o(logN)

min-heap - Correct Answers -A min-heap is similar to a max-heap, but a node's key is
less than or equal to its children's keys.

Online tech support waiting lines
low # = top priority

Heap storage - Correct Answers -Heaps are typically stored using arrays. Given a tree
representation of a heap, the heap's array form is produced by traversing the tree's
levels from left to right and top to bottom. The root node is always the entry at index 0 in
the array, the root's left child is the entry at index 1, the root's right child is the entry at
index 2, and so on.

heap parent index formula - Correct Answers -floor((i - 1) / 2)

Written for

Institution
DATA STRUCTURES
Course
DATA STRUCTURES

Document information

Uploaded on
July 28, 2025
Number of pages
2
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$10.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
millyphilip West Virginia University
Follow You need to be logged in order to follow users or courses
Sold
2921
Member since
4 year
Number of followers
1958
Documents
44266
Last sold
3 hours ago
white orchid store

EXCELLENCY IN ACCADEMIC MATERIALS ie exams, study guides, testbanks ,case, case study etc

3.6

551 reviews

5
239
4
87
3
104
2
32
1
89

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions