recursive-datastructures Questions

20

Python includes the heapq module for min-heaps, but I need a max-heap. What should I use for a max-heap implementation in Python?
Supereminent asked 23/3, 2010 at 15:58

8

I'm trying to populate a treeview from a list of folder path, for example: C:\WINDOWS\addins C:\WINDOWS\AppPatch C:\WINDOWS\AppPatch\MUI C:\WINDOWS\AppPatch\MUI\040C C:\WINDOWS\Microsoft.NET\Frame...
Patrica asked 20/7, 2009 at 21:12

3

What might be the thing in Python that is closest to the to the recursive data types in Haskell? (i.e. using the type's own definition while defining itself.) Edit: To give a more concrete definiti...

1

Solved

For the sake of example let's define a toy automaton type: data Automaton = Auto { success :: Automaton , failure :: Automaton } This structure is designed to by cyclic, we can imagine each ...
Magnanimity asked 24/12, 2021 at 0:26

1

Solved

I want to write a dataclass definition in Python, but can't refer to that same class inside the declaration. Mainly what I want to achieve is the typing of this nested structure, as illustrated bel...

1

I am trying to define a recursive struct similar to a linked list for a tree traversal. A node has some data and access to its parent. The child node should borrow its parent mutably to ensure excl...
Tshirt asked 11/2, 2020 at 21:43

2

Solved

Consider this code: import Data.Maybe (fromMaybe) data MyStructure = Foo Int | Bar String MyStructure | Baz MyStructure MyStructure | Qux Bool Bool MyStructure MyStructure deriving(Eq,Show) make...
Totem asked 30/9, 2019 at 21:45

1

Solved

I want to write a data type to evaluate the expressions like this: a is evaluated to a a + b * c / d -e is evaluated to a + (b * (c / (d - e))) So the first argument is always a number and the...
Argentum asked 6/9, 2019 at 22:13

3

I have a nested three layer struct. I would like to use reflect in Go to parse it (use recursive function). The reasons to use reflect and the recursive function are can have various number of f...
Azrael asked 23/2, 2018 at 14:10

2

Solved

I wrote a ternary search tree in Python and I've noticed that when the tree gets very deep, attempting to delete it causes Python to hang indefinitely. Here is a stripped version of the code that p...

2

Reading https://avro.apache.org/docs/current/spec.html it says a schema must be one of: A JSON string, naming a defined type. A JSON object, of the form: {"type": "typeName" ...attributes...} whe...
Overact asked 19/10, 2017 at 21:51

4

Solved

I have a mind-block when trying to create data-structure that follows the pattern: Map<String, T> is a main building block and T is either Map<String, T> or as terminal operator List&l...
Conjugate asked 18/2, 2019 at 8:35

3

Solved

I am stuck with a certain task. What I want is a function that, given a directory path, would return a recursive-list as an output. The output should be of the form myList$dir$subdir$subdir$fullFi...
Tenancy asked 7/1, 2013 at 0:9

1

If I understand correctly, we can model inductive data types as initial F-algebras and co-inductive data types as final F-coalgebras (for an appropriate endofunctor F) [1]. I understand that accord...
Peekaboo asked 22/8, 2018 at 13:24

3

Solved

A recursive program creates a stack internally, and causes the users to write less code. Are there any cases where recursion is actually preferred over manual stacks for the reason other than ment...

2

I have been trying to build a nested tree-like structure for two days and decided to ask here for help. Suppose I have data like this: rows = [ {'Year': None, 'Region': None, 'Country': None, 'Ma...
Turgescent asked 26/5, 2018 at 5:42

2

Solved

I have a complex Python data structure (if it matters, it's a large music21 Score object) which will not pickle due to the presence of a weakref somewhere deep inside the object structure. I've deb...
Leadership asked 26/9, 2012 at 22:20

1

Solved

I want to have an annotated AST, so I defined those recursive data structures using Fix: data Term a = Abstraction Name a | Application a a | Variable Name deriving (Read,Show,Eq,Functor,Fold...

1

Solved

In Ed Kmett's recursion-scheme package, there are three declarations: newtype Fix f = Fix (f (Fix f)) newtype Mu f = Mu (forall a. (f a -> a) -> a) data Nu f where Nu :: (a -> f a) -&...

2

Solved

Still working on my text editor Rasa. At the moment I'm building out the system for tracking viewports/splits (similar to vim splits). It seemed natural to me to represent this structure as a tree...

4

Table for my folder structure id | name | parent_id ----+--------------+----------- 1 | parent | 2 | child | 1 3 | grandchild A | 2 4 | grandchild B | 2 5 | grandchild c | 3 select id,par...
Orpha asked 14/11, 2014 at 12:33

9

So I was writing up a simple binary tree in Python and came across [...] I don't believe this to be related to the Ellipsis object, more it seems to have something to do with an infinity loop (due...
Cauldron asked 29/12, 2008 at 2:46

3

Solved

I'm seeing what seems to be a very obvious bug with scalacheck, such that if it's really there I can't see how people use it for recursive data structures. This program fails with a StackOverflowE...
Astrophysics asked 7/11, 2013 at 6:22

1

Solved

This snippet is from the implementation of Rational Numbers in Julia: # Rational.jl # ... Rational{T<:Integer}(n::T, d::T) = Rational{T}(n,d) Rational(n::Integer, d::Integer) = Rational(promote...
Enhanced asked 6/5, 2016 at 18:28

4

Solved

I'm printing a value of a what I thought was a list, but the output that I get is: [...] What does this represent? How do I test for it? I've tried: myVar.__repr__() != '[...]' and myVar.__...
Haler asked 28/4, 2016 at 2:46

© 2022 - 2024 — McMap. All rights reserved.