binary-heap Questions

6

In my program I need to delete an element from a priority queue that is not at the top. Can that be done? If not, please suggest a way to do so except creating your own heap.
Hereunto asked 19/10, 2013 at 15:6

2

Is Dijkstra faster when using Fibonacci heap than with the Binary heap? I did some experiments implementing Fibonacci heap on my own and using it in Dijkstra, I also checked the ready-to-use Fibona...
Casandra asked 6/7, 2022 at 18:41

2

Solved

I can use the std::collections::BinaryHeap to iterate over a collection of a struct in the greatest to least order with pop, but my goal is to iterate over the collection from least to greatest. I...
Vladamir asked 2/2, 2019 at 2:10

2

Solved

When building the heap, we start calling max_heapify(A,i) from the middle of the tree, i.e. floor(n/2), until the root in decreasing fashion to maintain heap property. I've read some reasons behind...
Cadell asked 26/11, 2016 at 19:50

1

Please, help to recognize the pattern in this B-heap: In normal Binary-heap we always use the following conditions: left_child = 2*i, right_child = 2*i+1 parent = i/2 But these conditions are ...
Static asked 24/9, 2016 at 19:29

4

Solved

This is one of the interview questions I recently came across. Given the root address of a complete or almost complete binary tree, we have to write a function to convert the tree to a max-heap. ...
Stegman asked 17/7, 2014 at 10:52

1

I am looking for a way to implement an iterator on binary heaps (maximum or minimum). That is, by using it’s nextNode() function for the i-th time, can get the i-th (greater or smaller) element in...
Goiter asked 11/5, 2019 at 22:3

2

Solved

I've read that binary heaps are faster at delete minimum operations and d-ary heaps are faster at at decrease priority operations (although I don't get why), but then I've also read that a 4-heap i...
Procarp asked 18/3, 2015 at 15:42

1

I am trying to prove that for binary heaps, buildHeap does at most (2N-2) comparisons between elements. I find it very difficult to prove this claim.
Septuplicate asked 11/4, 2018 at 11:42

3

Solved

I am just trying to learn binary heap and have a doubt regarding doing delete operation in binary heap. I have read that we can delete an element from binary heap and we need to reheapify it. But ...
Rms asked 28/9, 2011 at 11:59

3

I need to know the main difference between binary and binomial heaps regardless of the their structure difference that binary heaps can have only two child (tree representation) and binomial heaps ...

4

Solved

Could someone please explain me how should I decide whether to use one or another heap implementation, among the ones mentioned in the title? I would like an answer to guide me on choosing the imp...
Kellogg asked 2/12, 2011 at 7:28

6

quoting Wikipedia: It is perfectly acceptable to use a traditional binary tree data structure to implement a binary heap. There is an issue with finding the adjacent element on the last leve...
Buffoon asked 1/2, 2009 at 2:42

2

Consider a binary heap containing n numbers (the root stores the greatest number). You are given a positive integer k < n and a number x. You have to determine whether the kth largest element of...
Novokuznetsk asked 7/2, 2011 at 14:51

1

Solved

What is the complexity of Java's PriorityQueue constructor with a Collection? I used the constructor: PriorityQueue(Collection<? extends E> c) Is the complexity O(n) or O(n*log(n))?
Andalusia asked 9/1, 2016 at 12:24

4

Solved

What are the real world applications of Fibonacci heaps and binary heaps? It'd be great if you could share some instance when you used it to solve a problem. Edit: Added binary heaps also. C...
Bentonbentonite asked 22/9, 2010 at 9:21

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...

1

In a (max) heap it is easy to find the biggest item in O(1) time, but to actually remove it you need complexity of O(log(n)). So if the insertion and deletion from a heap is both O(log(n)), what a...

2

Solved

I am willing to use a data structure as an overflow buffer of constant space. I want to have efficient insert but most importantly efficient removal of the min element. I was thinking of using a he...

3

Solved

Suppose we have a binary heap of n elements and wish to insert n more elements(not necessarily one after other). What would be the total time required for this? I think it's theta (n logn) as one ...

1

The original question is given file containing 5GB URL being visited last day, find the top k frequent URL. The problem can be solved by using hash map to count the occurrences of distinct URL and ...

1

Solved

I think that I know the answer and the minimum complexity is O(nlogn). But is there any way that I can make an binary search tree from a heap in O(n) complexity?
Translator asked 31/12, 2012 at 23:37

2

Solved

Okay, so, say I have a text file (not necessarily containing every possible symbol) and I'd like to calculate the frequency of each symbol and, after calculating the frequency, I then need to acces...
Sparteine asked 4/10, 2011 at 19:2

3

Solved

I have created a binary heap, which represents a priority queue. It's just classical well known algorithm. This heap schedules a chronological sequence of different events ( the sort key is time )....
Villanovan asked 2/8, 2011 at 9:4

2

Solved

I looked in to the C++0x standard and found the requirement that make_heap should do no more than 3*N comparisons. I.e. heapify an unordered collection can be done in O(N) /* @brief Construct a...
Afterbirth asked 9/6, 2011 at 22:3

© 2022 - 2024 — McMap. All rights reserved.