Fibonacci Heap Amortized Analysis Confusion

EDIT: If anybody stumbles on this problem again in the future, the answer is: when computing amortized runtimes using the potential method, the potential method can hide constants as well.

Hello /r/askcomputerscience ,

I've been having a problem understanding this amortized analysis of Fibonacci Heap amortized runtimes. Something about the justifications given for delete min/popmin being O(log n) seems like nonsense to me. Here's my breakdown of the problem:

A fibonacci heap is a list of trees that satisfy the heap property, along with a reference to the item . On each tree, certain nodes may be marked "losers".

There are a few important operations on the fibonacci heap:

  • Insert

Inserts the item and updates the minimum when the inserted node is smaller than the current minimum.

  • Popmin

This is like an "extract min" of any minheap. Fibonacci popmin has a few particularities:

After popping the min from the linked list, it dumps the min's children onto the linked list. Then, it combines all nodes into the largest possible trees. This is achieved by keeping an array of roots along with a linear scan over the roots, where trees are funneled to an array index at their size, then merged if there is already a tree of that size at that index. All "loser" nodes become unmarked. Finally, the minimum is updated.

  • Decrease Key

The decrease key operation decreases a key and then checks for a heap violation. If a heap violation is found, the key is dumped to the root list. Then one of two things can occur:

  1. If the parent is a loser, it is dumped to the root list, and if its parent is a loser, its parent is dumped to the root list, and so on, until you get up to the first non loser parent. This non loser parent is marked a loser.
  2. If the parent is not a loser, it is marked a loser.

Okay, so here's the problem setup:

What is the amortized analysis of the Popmin operation?

As far as I can tell, this is how the video breaks it down:

First, he defines phi, the potential function of the fibonacci heap, to be the number of root nodes plus the number of loser nodes. When computing amortized cost, we simply compute the sum: actual worst-case cost + change in phi.

Then while analyzing popmin, he analyzes the runtime of putting the children of the min on the root node, which is o(log n). This follows from some other analysis elsewhere.

Then, he analyzes the runtime of the cleanup (combining all nodes into trees) portion. He

... keep reading on reddit ➑

πŸ‘︎ 13
πŸ’¬︎
πŸ‘€︎ u/likes-beans
πŸ“…︎ Jul 23 2021
🚨︎ report
Implementing Dijkstra’ Algorithm with Fibonacci heap?

Recently I learned that when Dijkstra Algorithm is implemented with a fibonacci heap, the time complexity tremendously reduces to O(E+Vlog(V)), where E is the edges and V is the Vertices of the graph.

I don’t know much about Fibonacci heap either, all I know is that it’s quite difficult to implement one in practise. And there is no point implementing one for the shortest path algorithm unless your graph is quite large.

Any comments on how to go on achieve that? This is open to all kind of discussion. Thank you.

πŸ‘︎ 40
πŸ’¬︎
πŸ‘€︎ u/sassysalmnder
πŸ“…︎ Jul 08 2019
🚨︎ report
d-ary heap implementation vs Fibonacci heap implementation Dijkstra performance comparions

I am the OP of this link, (https://cs.stackexchange.com/questions/102851/d-ary-heap-implementation-vs-fibonacci-heap-implementation-dijkstra-performance) please help still not much progress.

Let's say that Dijkstra’s algorithm with the priority queue using a d-ary heap. if adjusting d, we can try to achieve the best runtimes for the algorithm with d being ~ |E|/|V|.

Then for a fixed |V|, what is the largest possible ratio between this runtime and the runtime of Dijkstra using a Fibonacci heap? Where knowing the Fibonacci heap: delete_min = O(log |V |), insert/decrease_key = O(1) (amortized) and |V | Γ— delete_min + (|V | + |E|) Γ— insert = O(|V|log|V|+|E|).

On the other hand, d-ary heap implementation : delete_min = O($\dfrac{d \log|V|}{log d}$) , insert/ decrease_key =O($\dfrac{log|V|}{log d}$) , and |V | Γ— delete_min + (|V | + |E|) Γ— insert = O( (|V|Β·d+|E|)$\dfrac{ \log|V|}{log d}$ ).

As trying to follow a provide solution, but I am not sure why it reduces to O($\dfrac{log|V|}{log |E|/|V|})$, in the case 1 where |E| dominates, so Dijkstra with Fibonacci heap is O(|E|), How can we get the ration as O($\dfrac{log|V|}{log |E|/|V|})$ while Dijkstra with d-ary heap is O $( (|V|Β·d+|E|)\dfrac{ \log|V|}{log d}$)?

https://preview.redd.it/ul736dfe3ia21.png?width=1828&format=png&auto=webp&s=b27fb490c7c145b0d293caa039e15762ccc1fb77

πŸ‘︎ 18
πŸ’¬︎
πŸ‘€︎ u/MaxfieldMax
πŸ“…︎ Jan 15 2019
🚨︎ report
The Fibonacci heap seems to essentially rely on the golden ratio, xΒ²-x-1. What could a data structure akin to it, but based on the 'plastic ratio', xΒ³-x-1, look like?

I already asked this in /r/AskMath:
https://www.reddit.com/r/AskProgramming/comments/79ingi/the_fibonacci_heap_essentially_relies_on_the/

And /r/AskProgramming:

https://www.reddit.com/r/askmath/comments/79iq4f/the_fibonacci_heap_essentially_relies_on_the/

Unfortunately this so far only yielded responses pointing out well known properties of the plastic number without any ideas on the actual question(on which I currently also don't have any ideas, hence the question... :)) so I decided to post it here, too.

For reference, Fibonacci heaps:
https://en.wikipedia.org/wiki/Fibonacci_heap

And here, a good introduction to the plastic number:
http://bib.irb.hr/datoteka/628836.Plastic_Number_-_Construct.pdf

See also my comment here for some more well known properties of the plastic number, posted in response to the above mentioned pointing out of well known properties:
https://www.reddit.com/r/askmath/comments/79iq4f/the_fibonacci_heap_essentially_relies_on_the/dp38f14/?depth=4

(And, off topic, since I don't think this has any application to the heap topic, but I figured I'd mention it since I find it interesting, if anyone has any interest in the "morphic numbers" property mentioned in the paper I linked above, someone derived "morphic angles" from that:

https://link.springer.com/article/10.1007/s00004-015-0285-1)

πŸ‘︎ 10
πŸ’¬︎
πŸ‘€︎ u/AforAnonymous
πŸ“…︎ Oct 30 2017
🚨︎ report
STL-like implementation of Fibonacci heap and queue (X-post r/Cplusplus)

I've written a C++ implementation of a Fibonacci heap and queue: https://github.com/beniz/fiboheap

Fibonacci heaps are especially useful in search and random search algorithms, from Dijkstra to A* and AO* as priority queues with mutable keys.

Boost includes an implementation, but I must confess I rather do not like my programs to depend on Boost for a few hundred lines of code. Maybe this will be of use to others.

But most importantly, C++ and STL gurus here may want to give me advice on how to improve it / make it more compliant to STL-like container.

πŸ‘︎ 15
πŸ’¬︎
πŸ‘€︎ u/pilooch
πŸ“…︎ Mar 31 2014
🚨︎ report
Fibonacci heap (theoretically faster) vs binary heap running times compared github.com/danielborowski…
πŸ‘︎ 8
πŸ’¬︎
πŸ‘€︎ u/10_6
πŸ“…︎ Feb 22 2016
🚨︎ report
`Heck, I didn't even know what a Fibonacci heap was until a bit ago!` -- /u/techno_science reddit.com/r/cscareerques…
πŸ‘︎ 6
πŸ’¬︎
πŸ‘€︎ u/PeopleWhoSayHeck
πŸ“…︎ Jun 19 2017
🚨︎ report
The Fibonacci heap ruins my life maryrosecook.com/blog/pos…
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/asankhs
πŸ“…︎ Jul 06 2014
🚨︎ report
The Fibonacci heap ruins my life maryrosecook.com/blog/pos…
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/qznc_bot
πŸ“…︎ Jul 06 2014
🚨︎ report
STL-like implementation of Fibonacci heap and queue (X-post r/Cplusplus) : cpp reddit.com/r/cpp/comments…
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/pilooch
πŸ“…︎ Mar 31 2014
🚨︎ report
Fibonacci heap - Wikipedia, the free encyclopedia en.wikipedia.org/wiki/Fib…
πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/jmuk
πŸ“…︎ Jul 31 2006
🚨︎ report
3 months ago I posted here about being rejected by Microsoft for full time after my internship. Today I have 8 new grad offers.

Original post:

https://www.reddit.com/r/csMajors/comments/pe541i/rejected_for_full_time_return_offer_after/

When I made the post here 3 months ago and it took off, I got a lot of good advice to start applying to companies immediately. I probably applied to aprox. 200 companies for new grad in the month of September.

Here are some notable rejections:

Failed after OA:

IBM 9/16

Stripe 9/16

Ocient 9/16

Expedia 9/26

Better 9/26

Google 9/26

Redfin 10/7

Failed after phone:

Facebook 10/11

Bloomberg: 10/25

Oracle

Failed after final:

Amazon 11/26

Qualtrics 11/15

Offers:

JPMorgan 130k NYC (switch to another location) Accepted

Dell 86k Austin

GM 100k Detroit

Chevron 100k Houston

Progressive 75k Remote

Caterpillar 90k Chicago

Ford 90k Detroit

Wells Fargo 74k Raleigh

First thing to note is that Microsoft (or probably any FAANG) on resume got me responses from just about every company. There were countless ghosts and rejections not shown here but I got a good shot at almost all big tech companies (except Apple which always ghosts me).

If you notice, I only got offers from companies that have fully behavioral interview loops. Yes Chevron and JPMorgan asked technical questions but they were LC super easy (Fibonacci question for example). The good news about this is my STAR responses really work. The bad news is I could not meet the bar in my LeetCode style technical interviews.

I started the recruiting season after my Microsoft rejection with 81 LeetCode solved. About 60 Easy, 21 Medium. From September to now I completed 46 problems for a current total of 127 (63 E / 57 M / 7 H).

Clearly this amount wasn’t enough. I bombed basically every DS&A interview round except the one for JPMC where they asked me to count the occurrences of nums in an array…

My strategy for the last 3 months was to fully complete and internalize this even more consolidated version of the B75 list written by the original B75 creator. It is 50 questions instead of 75:

https://techinterviewhandbook.org/best-practice-questions/

This list opened my eyes to Tries, Heaps, and a bunch of other crucial LeetCode patterns I had not known.

At my current level of preparation, I feel that I have seen each LC pattern at least once and know about each data structure. However, I don’t feel like I’ve ma

... keep reading on reddit ➑

πŸ‘︎ 461
πŸ’¬︎
πŸ‘€︎ u/MsftReject
πŸ“…︎ Nov 30 2021
🚨︎ report
Blind Girl Here. Give Me Your Best Blind Jokes!

Do your worst!

πŸ‘︎ 5k
πŸ’¬︎
πŸ‘€︎ u/Leckzsluthor
πŸ“…︎ Jan 02 2022
🚨︎ report
Can I learn this Algorithms and Data Structures course by myself?

Hello Reddit,

I have throughout my bachelor realised that I would much rather study data science than my "free" business masters. I have been looking at data science masters at other universities here in Denmark, where I can see that all of them require me to take a lot of courses, where one of them being Algorithms and Data Structures. I have found that course on a university, where I can pay 1/10th of the price if I would just go to the exam rather than taking the course.

I am then wondering if I can teach myself the curriculum by using paid material online or youtube content.

The curriculum looks like this (using google translate):

Knowledge

Sorting algorithms. Graphing algorithms for determining shortest paths and least spanning trees. Fibonacci heaps and binary search trees. Amortized analysis. Divide and rule. Dynamic programming. Greedy algorithms. Proofs of correctness.

Skills Recognize algorithmic paradigms (eg divide and rule, dynamic programming, greedy algorithms) and apply them to new issues. Perform asymptotic complexity analysis of algorithms (including solving recursive equations). Apply appropriate data structures to new issues. Argue for the correctness of algorithms using induction (including the formulation of loop variants) as well as direct and contradictory evidence.

Best regards

πŸ‘︎ 9
πŸ’¬︎
πŸ‘€︎ u/Olafcitoo
πŸ“…︎ Jan 04 2022
🚨︎ report
What starts with a W and ends with a T

It really does, I swear!

πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/PsychedeIic_Sheep
πŸ“…︎ Jan 13 2022
🚨︎ report
Dropped my best ever dad joke & no one was around to hear it

For context I'm a Refuse Driver (Garbage man) & today I was on food waste. After I'd tipped I was checking the wagon for any defects when I spotted a lone pea balanced on the lifts.

I said "hey look, an escaPEA"

No one near me but it didn't half make me laugh for a good hour or so!

Edit: I can't believe how much this has blown up. Thank you everyone I've had a blast reading through the replies πŸ˜‚

πŸ‘︎ 19k
πŸ’¬︎
πŸ‘€︎ u/Vegetable-Acadia
πŸ“…︎ Jan 11 2022
🚨︎ report
I'm looking for non-industry-standard compiled languages to learn, and in my "journey" some langs stood out: Zig, V reddit.com/r/Zig/comments…
πŸ‘︎ 47
πŸ’¬︎
πŸ‘€︎ u/fp_weenie
πŸ“…︎ Jul 07 2021
🚨︎ report
What is a a bisexual person doing when they’re not dating anybody?

They’re on standbi

πŸ‘︎ 11k
πŸ’¬︎
πŸ‘€︎ u/Toby-the-Cactus
πŸ“…︎ Jan 12 2022
🚨︎ report
What do you call quesadillas you eat in the morning?

Buenosdillas

πŸ‘︎ 12k
πŸ’¬︎
πŸ‘€︎ u/FarronKeepSucks
πŸ“…︎ Jan 14 2022
🚨︎ report
Geddit? No? Only me?
πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/shampy311
πŸ“…︎ Dec 28 2021
🚨︎ report
I wanna hear your best airplane puns.

Pilot on me!!

πŸ‘︎ 3k
πŸ’¬︎
πŸ‘€︎ u/Paulie_Felice
πŸ“…︎ Jan 07 2022
🚨︎ report
E or ß?
πŸ‘︎ 9k
πŸ’¬︎
πŸ‘€︎ u/Amazekam
πŸ“…︎ Jan 03 2022
🚨︎ report
No spoilers
πŸ‘︎ 9k
πŸ’¬︎
πŸ‘€︎ u/Onfour
πŸ“…︎ Jan 06 2022
🚨︎ report
Covid problems
πŸ‘︎ 7k
πŸ’¬︎
πŸ‘€︎ u/theincrediblebou
πŸ“…︎ Jan 12 2022
🚨︎ report
These aren't dad jokes...

Dad jokes are supposed to be jokes you can tell a kid and they will understand it and find it funny.

This sub is mostly just NSFW puns now.

If it needs a NSFW tag it's not a dad joke. There should just be a NSFW puns subreddit for that.

Edit* I'm not replying any longer and turning off notifications but to all those that say "no one cares", there sure are a lot of you arguing about it. Maybe I'm wrong but you people don't need to be rude about it. If you really don't care, don't comment.

πŸ‘︎ 12k
πŸ’¬︎
πŸ‘€︎ u/Lance986
πŸ“…︎ Dec 15 2021
🚨︎ report
I had a vasectomy because I didn’t want any kids.

When I got home, they were still there.

πŸ‘︎ 10k
πŸ’¬︎
πŸ‘€︎ u/demotrek
πŸ“…︎ Jan 13 2022
🚨︎ report
What did 0 say to 8 ?

What did 0 say to 8 ?

" Nice Belt "

So What did 3 say to 8 ?

" Hey, you two stop making out "

πŸ‘︎ 9k
πŸ’¬︎
πŸ‘€︎ u/designjeevan
πŸ“…︎ Jan 03 2022
🚨︎ report
Spi__
πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/Fast_Echidna_8520
πŸ“…︎ Jan 11 2022
🚨︎ report
I dislike karma whores who make posts that imply it's their cake day, simply for upvotes.

I won't be doing that today!

πŸ‘︎ 15k
πŸ’¬︎
πŸ‘€︎ u/djcarves
πŸ“…︎ Dec 27 2021
🚨︎ report
The Ancient Romans II
πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/mordrathe
πŸ“…︎ Dec 29 2021
🚨︎ report
How do you stop Canadian bacon from curling in your frying pan?

You take away their little brooms

πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/Majorpain2006
πŸ“…︎ Jan 09 2022
🚨︎ report
School Was Clothed
πŸ‘︎ 5k
πŸ’¬︎
πŸ‘€︎ u/Kennydoe
πŸ“…︎ Jan 08 2022
🚨︎ report
I did it, I finally did it. After 4 years and 92 days I went from being a father, to a dad.

This morning, my 4 year old daughter.

Daughter: I'm hungry

Me: nerves building, smile widening

Me: Hi hungry, I'm dad.

She had no idea what was going on but I finally did it.

Thank you all for listening.

πŸ‘︎ 17k
πŸ’¬︎
πŸ‘€︎ u/Sk2ec
πŸ“…︎ Jan 01 2022
🚨︎ report
It this sub dead?

There hasn't been a post all year!

πŸ‘︎ 13k
πŸ’¬︎
πŸ‘€︎ u/TheTreelo
πŸ“…︎ Jan 01 2022
🚨︎ report
Couch potato
πŸ‘︎ 8k
πŸ’¬︎
πŸ“…︎ Dec 31 2021
🚨︎ report
Baka!
πŸ‘︎ 5k
πŸ’¬︎
πŸ‘€︎ u/ridi86
πŸ“…︎ Jan 09 2022
🚨︎ report
All dad jokes are bad and here’s why

Why

πŸ‘︎ 7k
πŸ’¬︎
πŸ‘€︎ u/LordCinko
πŸ“…︎ Jan 13 2022
🚨︎ report
Letting loose with these puns
πŸ‘︎ 6k
πŸ’¬︎
πŸ“…︎ Jan 13 2022
🚨︎ report
concrete πŸ—Ώ
πŸ‘︎ 5k
πŸ’¬︎
πŸ‘€︎ u/Fast_Echidna_8520
πŸ“…︎ Jan 07 2022
🚨︎ report
My name is ABCDEFGHIJKMNOPQRSTUVWXYZ

It’s pronounced β€œNoel.”

πŸ‘︎ 14k
πŸ’¬︎
πŸ‘€︎ u/beef_fried_rice
πŸ“…︎ Dec 25 2021
🚨︎ report
Why are people so surprised and angry about Djokovic being an anti-vaxxer?

After all his first name is No-vac

πŸ‘︎ 4k
πŸ’¬︎
πŸ‘€︎ u/hangryman23
πŸ“…︎ Jan 06 2022
🚨︎ report
d-ary heap implementation vs Fibonacci heap implementation Dijkstra performance comparions

I am the OP of this link, (https://cs.stackexchange.com/questions/102851/d-ary-heap-implementation-vs-fibonacci-heap-implementation-dijkstra-performance) please help still not much progress.

Let's say that Dijkstra’s algorithm with the priority queue using a d-ary heap. if adjusting d, we can try to achieve the best runtimes for the algorithm with d being ~ |E|/|V|.

Then for a fixed |V|, what is the largest possible ratio between this runtime and the runtime of Dijkstra using a Fibonacci heap? Where knowing the Fibonacci heap: delete_min = O(log |V |), insert/decrease_key = O(1) (amortized) and |V | Γ— delete_min + (|V | + |E|) Γ— insert = O(|V|log|V|+|E|).

On the other hand, d-ary heap implementation : delete_min = O($\dfrac{d \log|V|}{log d}$) , insert/ decrease_key =O($\dfrac{log|V|}{log d}$) , and |V | Γ— delete_min + (|V | + |E|) Γ— insert = O( (|V|Β·d+|E|)$\dfrac{ \log|V|}{log d}$ ).

As trying to follow a provide solution, but I am not sure why it reduces to O($\dfrac{log|V|}{log |E|/|V|})$, in the case 1 where |E| dominates, so Dijkstra with Fibonacci heap is O(|E|), How can we get the ration as O($\dfrac{log|V|}{log |E|/|V|})$ while Dijkstra with d-ary heap is O $( (|V|Β·d+|E|)\dfrac{ \log|V|}{log d}$)?

Processing img 2lmyxyl32ia21...

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/MaxfieldMax
πŸ“…︎ Jan 15 2019
🚨︎ report
The Fibonacci heap essentially relies on the golden ratio, xΒ²-x-1. What could a data structure akin to it, but based on the 'plastic ratio', xΒ³-x-1, look like?

I already asked this, over in /r/AskProgramming; but I figured I'd ask it here, too.

For reference, the Fibonacci heap: https://en.wikipedia.org/wiki/Fibonacci_heap

And here, a good introduction to the plastic number: http://bib.irb.hr/datoteka/628836.Plastic_Number_-_Construct.pdf

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/AforAnonymous
πŸ“…︎ Oct 29 2017
🚨︎ report
The Fibonacci heap essentially relies on the golden ratio, xΒ²-x-1. What could a data structure akin to it, but based on the 'plastic ratio', xΒ³-x-1, look like?

For reference, the Fibonacci heap: https://en.wikipedia.org/wiki/Fibonacci_heap

And here, a good introduction to the plastic number: http://bib.irb.hr/datoteka/628836.Plastic_Number_-_Construct.pdf

Edit:
Also crossposted to /r/AskMath, unfortunately no ideas yet, but I linked to some more details about the number sequences to which the plastic number relates there, something only very incompletely covered in most of the literature:
https://www.reddit.com/r/askmath/comments/79iq4f/the_fibonacci_heap_essentially_relies_on_the/

πŸ‘︎ 7
πŸ’¬︎
πŸ‘€︎ u/AforAnonymous
πŸ“…︎ Oct 29 2017
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.