Okasaki | Functional data structures in C | Functional Programming library
kandi X-RAY | Okasaki Summary
kandi X-RAY | Okasaki Summary
Functional data structures in C++.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Okasaki
Okasaki Key Features
Okasaki Examples and Code Snippets
Community Discussions
Trending Discussions on Okasaki
QUESTION
Most used operation: FindMin. Less commonly: Insert and ExtractMin. Rarely: DeleteNode. Very rare: Merge.
Which of the following priority queues is faster in practical terms, under the listed conditions?
- Naive implementation based on sorted doubly linked list
- Simple heap
- Leftist heap
- Binomial heap
- Fibonacci heap
- 2-3 heap
- Pairing heap
- Thin heap
- Thick heap
- Skew Binomial Heap
- Brodal-Okasaki queue
ANSWER
Answered 2020-Feb-11 at 18:28My experience, based on work I did more than five years ago, is that a 3-heap outperforms a binary heap in the general case. Skip list heaps and pairing heaps slightly outperform a 3-heap, but at a higher memory cost. All three of the above outperformed Fibonacci heap.
Brodal queue is theoretically the most efficient. But, as Brodal himself said, they are "quite complicated" and "[not] applicable in practice." https://en.wikipedia.org/wiki/Brodal_queue
A lot of people talk about Fibonacci heap efficiency, and asymptotic analysis says that it should outperform other types of heaps. Empirical data tends not to bear that out. There are definite disadvantages of Fibonacci heap, as described in https://en.wikipedia.org/wiki/Fibonacci_heap#Worst_case.
If you're looking to implement a heap, I'd suggest starting with a binary heap. Or a 3-heap, which is a simple optimization. My next step, if I needed more performance, would be the Pairing Heap. It's easy to implement and quite efficient.
Beyond that, I don't have any advice. The performance numbers I've seen on the other types of heaps don't show a clear winner.
QUESTION
Laziness is a corner stone in the book Purely Functional Data Structures, but it is not clearly described how he obtains it, at least to me. I thought I only needed to write:
...ANSWER
Answered 2020-Jan-20 at 09:53You need to enable laziness and add some parentheses (the $
in the book has peculiar parsing rules):
QUESTION
(Questions are at the bottom in bold.)
I'm going through Chris Okasaki's Purely Functional Data Structures and I was attempting to translate the first data structure and its implementations from Standard ML to F#. The ML is as follows (translated from the book):
...ANSWER
Answered 2019-Aug-12 at 23:351. Is there any way to make use of this in the .NET ecosystem, to have just a pure type like this, practical or not? Also, is this considered some sort of bug to be able to create a non-implementable datatype?
What you have implemented compiles, but it's most certainly not what you intended to implement. It's only syntactically similar - what you're using is something called explicit class syntax, and your STACK
type is a class ostensibly without a public constructor with a bunch of getter-only properties.
This is something you can check yourself through the reflection API. If you're using this code in FSI, you may find that a constructor is generated for that type anyway, and you can use Activator.Create
to instantiate it - you'll see the properties all having the default null values.
QUESTION
I have the following Red Black tree:
...ANSWER
Answered 2019-Jan-01 at 14:51The first example of insertion code has a bug: it tries to insert the tree itself as an element.
The second version
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Okasaki
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page