Skip to main content

Questions tagged [heap-sort]

Heapsort is an efficient comparison-based sorting algorithm that divides an input into a sorted and an unsorted part and iteratively shrinks the unsorted part by extracting the largest element and moving that to the sorted part. Run time is O(n log n).

7 votes
4 answers
552 views

I developed a heap sort variant that sorts a heap through traversal. Unlike in the standard heap sort, the algorithm does not remove the min element from the heap instead it traverses all the nodes of ...
ariko stephen's user avatar
-4 votes
1 answer
132 views

Help me with Pyramidal sorting by D. Knuth algorithm in C++. I would like to clarify if I followed the algorithm correctly. The code works. I have the function, but I'm not sure if my code fully ...
Loly18's user avatar
  • 1
8 votes
2 answers
443 views

I tried to optimize heap sort algorithm. Instead of recursion, I used iteration: ...
iskander's user avatar
  • 121
15 votes
5 answers
4k views

I have tried to implement my Heap in C. The following are the 13 operations defined: build_maxheap insert exctract_max (delete heap max root) max_delete (delete an element or key) max_heapify clear ...
V_head's user avatar
  • 575
8 votes
2 answers
588 views

Let's say you are living in a controlled economy where there is a baker in town, and every day he bakes a random number of loaves of bread (sometimes the oven breaks, or he has less ingredients). The ...
Tennis Tubbies's user avatar
3 votes
0 answers
154 views

The assumption is that k is quite large as compared to no. of elements in the array and division by 2 returns ceiling of the result. Request for your review and suggestions for further improvements ...
Deepak Mishra's user avatar
1 vote
1 answer
68 views

I have (designed and) implemented this fancy sorting algorithm that combines natural runs in the input array with a heap data structure: ...
coderodde's user avatar
  • 32.3k
3 votes
2 answers
428 views

NOTE: I am beginner in Python I learnt the Heap sort today and tried my own implementation using Python. Can i get feedback for my code and areas of improvement. I have tried to add comments inline, ...
prabh's user avatar
  • 151
-1 votes
3 answers
388 views

This code relies on Python3.7.4 I'm learning Heapsort in python 3. Please show me the errors in my code. Runs on my computer but tell me if Python rules or not. ...
Brijesh Kalkani's user avatar
7 votes
1 answer
1k views

I've implemented a minimal external sort of text file using heapq python module. On the few tests I did it seems to works well, but I would like to have some advice to have a cleaner and faster code. ...
RomainL.'s user avatar
  • 314
5 votes
1 answer
225 views

I implemented this max-heap to satisfy the C++ Container requirements. I am fairly confident I implemented bubble_up, bubble_down...
Brady Dean's user avatar
2 votes
2 answers
2k views

Objective: Create a heap sort that returns a unsorted list to sorted from greatest to least. Does this implementation look correct? Do you have any tips for optimizing this? ...
Johnathan's user avatar
  • 131
3 votes
2 answers
896 views

As part of my study on fundamentals, I have implemented the following code in JavaScript for a MinHeap data structure. Please have a look and I look forward to ...
Still Questioning's user avatar
3 votes
2 answers
4k views

Overview I was doing some performance optimization patterns when I stumbled upon PriorityQueue and I implemented for that reason ...
kuskmen's user avatar
  • 413
1 vote
1 answer
702 views

I am learning algorithms by using Java. Here is an implementation of heapsort. Let me know if anything is wrong and and suggestion to improve the algorithm. ...
Bahodir  Boydedayev's user avatar

15 30 50 per page