• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 8 pages
Exam (elaborations)

CSE310 Exam 2 2025 Questions and Answers

Document preview thumbnail
Preview 2 out of 8 pages

CSE310 Exam 2 2025 Questions and Answers

Content preview

CSE310 Exam 2 2025 Questions and
Answers


What is the root index of a heap? - ANSWER-1

How is a heap stored? - ANSWER-Layer by layer, left to right

Min Heap vs Max Heap? - ANSWER-Max Heap: The parent node is greater than

or equal to the child nodes




Min Heap: The parent node is less than or equal to the child nodes

MAX-HEAPIFY(A, i) - ANSWER-Assume left and right are max heaps

Compare A[i] to A[left(i)] and A[right(i)]

If A[i] less than either, swap with the larger value child node

(IF LARGER CHILDREN EQUAL SWAP WITH LEFT)

If A[i] swapped than recursive call

BUILD-MAX-HEAP(A) - ANSWER-Starts from i = floor of length(A)/2 to 1 to

exclude all leaf nodes




COPYRIGHT ©️ 2025 ALL RIGHTS RESERVED...TRUSTED & VERIFIED 1

, Runs from bottom and goes up

BUILD-MAX-HEAP(A) runtime - ANSWER-θ(n)

Heapsort - ANSWER-Uses BUILD-MAX-HEAP(A), then from i = length(A) to 2

it swaps the first node with the last element in the array, decrementing the heap

size and calling heapify to create a sorted list

Heap-Maximum(A) - ANSWER-return largest value in max heap should be A[1]

Heap-Extract-Max(A) - ANSWER-Store value of A[1] (max)

Copy A[length(A)] to A[1]

Decrement heap size by 1

Perform Max-Heapify(A, 1)

Return stored A[1]

Increase-Key(A, i, key) - ANSWER-If key > A[1] then set A[i] = key

Compare A[i] to parent, if A[i] larger then swap and continue swapping if

necessary

Insertion(A, key) - ANSWER-Insert a new node at the end of heap with the value -

inf

call Increase-Key on the new node, where key is the key value of the node being

inserted




COPYRIGHT ©️ 2025 ALL RIGHTS RESERVED...TRUSTED & VERIFIED 2

Document information

Uploaded on
August 17, 2025
Number of pages
8
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$12.99

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

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.
KatelynWhitman
3.6
(260)
Sold
1255
Followers
485
Items
43943
Last sold
12 hours ago




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