x ≠ NIL - answer*Inserting into a Binary Search Tree*
Given a binary search tree T and a new node z, the TREE_INSERT(T,z) procedure
insert the new node into the tree, maintaining the Binary Search Tree Property. Identify
the missing piece of code.
x ≠ NIL and k ≠ x.key - answer*Searching a Binary Search Tree*
Given a root node x and a key k, the TREE_SEARCH(x,k) procedure iteratively
searches the tree for the key K, returning NIL if k is not found. Identify the missing piece
of code.
TREE_SEARCH(x.left,k) - answer*Searching a Binary Search Tree*
Given a root node x and a key k, the TREE_SEARCH(x,k) procedure recursively
searches the tree for the key K, returning NIL if k is not found. Identify the missing piece
of code.
T[j] == NIL - answer*Inserting into an open addressing hash table*
Given a key k, the HASH_INSERT(T, k) procedure adds the key k to the hash table T.
This hash table is implemented as an array T[1..m], and includes a hash function h(k, i)
that, for every key k, the probe sequence {h(k,0),h(k,1),...,h(k,m-1)} is a permutation of
{0,1...,m-1}. Identify the missing piece of code.
T[j] == NIL - answer*Searching an open addressing hash table*
Given a key k, the HASH_SEARCH(T, k) procedure searches for the key k in the hash
table T. This hash table is implemented as an array T[1..m], and includes a hash
function h(k, i) that, for every key k, the probe sequence {h(k,0),h(k,1),...,h(k,m-1)} is a
permutation of {0,1...,m-1}. The HASH_SEARCH(T, k) procedure returns the index j
where the key k is found or NIL if the key is not in the hash table. Identify the missing
piece of code.
exchange A[i] with A[largest] - answer*Max-heapify an array*
Given an array A and an index i, where the left subtree rooted at 2i and the right subtree
rooted at 2i + 1 are max-heaps, the MAX_HEAPIFY(A,i) procedure lets the value at A[i]
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Dreamer252. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $12.99. You're not tied to anything after your purchase.