Data Structures Lab #5 Solution

$30.00

Description

Instructions

Complete the implementation of the Min-Heap data structure (you’ll find a partial implementation in the Appendix that you need to complete). After doing this, use your implementation of the data structure to implement heapsort. Test your implementation by doing at least one of the following options:

– Unit Tests

– Reading a file with a list of numbers separated by commas and printing the sorted sequence

– Creating a separate file where you call your heapsort implementation using hard-coded

lists of numbers

Appendix

“`python

class Heap:

def __init__(self):

self.heap_array = []

def insert(self, k):

self.heap_array.append(k)

TODO: Complete implementation

def extract_min(self):

if self.is_empty():

return None

min_elem = self.heap_array.append[0]

TODO: Complete implementation

return min_elem

def is_empty(self):

return len(self.heap_array) == 0

“`

What you need to do

Part 1

Implement the program described above and upload your code to GitHub.

Part 2

Add your team members as collaborators to your GitHub repo. They will add you to their projects as a collaborator as well. Read their code and give them feedback. Use *pull requests* and/or the *Issues* section to do so.

Extra Credit (10 points total)

Solve the following leetcode problems

1. https://leetcode.com/problems/ugly-number-ii/description/

2. https://leetcode.com/problems/super-ugly-number/description/

3. https://leetcode.com/problems/kth-largest-element-in-an-array/description/