Create a class Data with generic attributes key and value of generic type. Define your MinHeap class such that it uses array members of type Data, but ordering will occur by an ent
computer science discussion question
PART 1 (JAVA HEAP)
In class we implemented a max heaps heapify method in Java for generic keys, but lacking values. For this assignment, you will implement methods as outlined below in Java.
Use the code from class / Canvas as a starting point or start yourself from scratch to create a class MinHeap
Create a class Data with generic attributes key and value of generic type. Define your MinHeap class such that it uses array members of type Data, but ordering will occur by an entries attribute key. You will need to declare your key type to be comparable. Use the Week 2 Symbol Table as example code or read the Java documentation on how to define generic types.
Create a constructor which initializes the attribute A (array) from a provided list. Make sure the actual array starts with index 1 so it aligns with our textbook. Copy the methods left, right, and parent from class code.
Write a method heapify which creates a min-heap recursively. Recall that keys cannot be compared with if the type is not known at compile-time, so use a comparator as we did in week 2.
with generic key-value entries.
Each of the problems 1 ? 3 will be graded according to listed rubric for a total of 12 points.
PART 2 (PYTHON BST)
In class we have seen implementations of several methods for a binary search tree data structure both in Java and Python. For this assignment, you will implement four methods as outlined below in Python. The main method will be successor which is to find the successor of an existing key.
Use the code from class / Canvas as a starting point or start yourself from scratch to have a class BST with key- value nodes. Note that you will need an implementation with parent pointers in order to implement successor.
Implement a private minimum method (named minimum(self, startNode)) based onthe pseudocode MINIMUM from our slides and text. This method will return the node with minimum key relative to node startNode (not necessarily root) if it exists, and None otherwise.
Implement a public minimum method (named minimum(self)) based on the pseudocode MINIMUM from our slides and the method minimum() you created. This method will return the minimum key starting from root if it exists, and None otherwise. Adjust your code so that the final answer is a key and not a node.
Implement a private search method ( search(self, startNode, key)) which recursively finds the node node with node.key==key. Use the code for get(self, startNode, key) as a blueprint, but make sure to return a node and not a value.
Implement a public successor method (successor(self, key)) which utilize search(self, startNode, key)) to find the node node with matching key. Then operate on nodes as our pseudo code does from class does:
If the key cannot be found, raise a key error or return None.
If the node does not have a right child, traverse the tree in a while loop until you find an ancestor such that the original node is in its left subtree.
If there is no successor (because the key was the maximum key) return None.
Test and debug your methods. Provide test runs in form of a main (driver) file in which you create appropriate variables, fill the tree with data from the provided JSON file, and run some cases to show your methods work. In particular, show that the successor key for S06E12 is S06E15, and that S06E16 has no successor. Do not forget to upload main.py and bst.py and provide screenshots of the test runs.
b.If the node has a right child, return the minimum key from the right childs subtree.
Each of the problems 1 ? 5 will be graded according to the following rubric for a total of 20 points.
SCORE
4
3
2
1
0
SKILL LEVEL
Response gives evidence of a complete understanding of the problem; is fully developed; is clearly communicated.
Response gives the evidence of a clear understanding of the problem but contains minor errors or is not fully communicated.
Response gives evidence of a reasonable approach but indicates gaps in conceptual understanding. Explanations are incomplete, vague, or muddled.
Response gives some evidence of problem understanding but contains major math or reasoning errors.
No response or response is completely incorrect or irrelevant.
Requirements: Depends
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.