• 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 1 out of 3 pages
Exam (elaborations)

DSA 2. Data Structure Implementation Questions and Answers

Document preview thumbnail
Preview 1 out of 3 pages

DSA 2. Data Structure Implementation

Content preview

DSA 2. Data Structure Implementation


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]

Document information

Uploaded on
August 29, 2024
Number of pages
3
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$13.49

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.
Dreamer252
4.0
(117)
Sold
497
Followers
297
Items
21575
Last sold
1 month 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