heapsort Questions
28
So I was going through different sorting algorithms. But almost all the sorting algorithms require 2 loops to sort the array. The time complexity of Bubble sort & Insertion sort is O(n) for Bes...
Barrett asked 12/8, 2015 at 14:52
13
Solved
Both quicksort and heapsort do in-place sorting. Which is better? What are the applications and cases in which either is preferred?
4
Solved
I'm wondering if a max or min heap tree is allowed to have duplicate values? I've been unsuccessful in trying to find information regarding this with online resources alone.
Tradescantia asked 21/3, 2014 at 21:47
3
Solved
I tried watching http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/lecture-videos/lecture-4-heaps-and-heap-sort/ to understand heaps ...
6
Solved
7
Solved
I'm trying to implement Heap Sort in Python, but I can't seem to get it right. I've tried to implement this pseudo code, but my code does not sort! It just sifts to ridiculous effect. I'm inclined ...
Symbol asked 20/12, 2012 at 20:11
6
Solved
I'm trying to understand why heapsort isn't stable.
I've googled this, but haven't found a good, intuitive explanation.
I understand the importance of stable sorting - it allows us to sort based ...
Phrenology asked 12/10, 2013 at 17:5
2
Solved
Which algorithm is faster when iterating through a large array: heap sort or merge sort? Why is one of these algorithms faster than the other?
1
Solved
I am having trouble understanding why solutions for finding the kth smallest element uses a Max heap approach. And for the kth largest element a min heap approach. Wouldn't it make more sense to us...
2
Solved
A heap can be constructed from a list in O(n logn) time, because inserting an element into a heap takes O(logn) time and there are n elements.
Similarly, a binary search tree can be constructed fr...
Dave asked 25/12, 2017 at 20:26
7
Solved
At school we are currently learning sorting algorithms in Java and I got for my homework the Heap Sort. I did my reading, I tried to find out as much as I could, but it seems I just can't grasp the...
3
Solved
I was wondering if anyone has ever used linked lists to do heap sort and if they have could they provide the code. I have been able to do heapsort using arrays, but trying to do it in linked lists ...
Marijane asked 4/6, 2012 at 17:27
2
1
Solved
I'm working on a program which sorts an array by dividing it into smaller max-heaps and extracting the max-integer out of each one, then deleting it from the heap and running again until every heap...
3
Solved
When I implement heapsort using a min-heap it sorts the array from largest to smallest. Is this the desired output for a heapsort using min-heap? It seems redundant to sort again to output smallest...
1
I created this program for an assignment in which we were required to create an implementation of Quichesort. This is a hybrid sorting algorithm that uses Quicksort until it reaches a certain recur...
4
Solved
I have implemented two algorithms for sorting elements from highest to lowest.
The first one, takes quadratic time on the real RAM model and the second an O(n log(n)) time.
The second one uses p...
Pilfer asked 1/9, 2014 at 22:22
3
Solved
In reading in Chapter 14 of Jon Bentley's "Programming Pearls", 2nd Edition, I understand that heaps use a one-based array and the easiest approach in C is to declare x[n+1] and waste element x[0] ...
2
Solved
How many number of elements can be sorted in Θ(log n) time using heap sort?
When we do a heapsort, to build the heap we need Θ(n) complexity and then to do the heapsort O(nlog n). I understa...
Copyright asked 16/1, 2014 at 7:43
9
Solved
As an exercise in Haskell, I'm trying to implement heapsort. The heap is usually implemented as an array in imperative languages, but this would be hugely inefficient in purely functional languages...
Eremite asked 31/5, 2009 at 19:52
1
Functions called: (regardless of class)
def partition( pivot, lst ):
less, same, more = list(), list(), list()
for val in lst:
if val < pivot:
less.append(val)
elif val > pivot:
more.a...
2
Solved
From the Soft Heap wikipedia page, it seems that the min extraction only takes constant time, thus using a soft heap to perform heapsort should lead to an amortized O(n). Even if the constant is la...
Hydrometeor asked 10/6, 2013 at 5:4
1
Solved
Quicksort outperforms Heapsort in practice. Mergesort is the only stable one of the 3 (in plain vanilla implementations). So it's either quicksort or mergesort that'd get used depending on th...
Macedo asked 30/12, 2012 at 1:12
4
Solved
In a max heap (assuming it's represented by an array), the top of the heap (ie. the largest value in the heap) swaps with the last element in the array (ie. one of the smallest values in the heap),...
2
Solved
1 Next >
© 2022 - 2024 — McMap. All rights reserved.