Skip to content
m·amathatlas
ExploreAboutOpen problemsCited authorsMy libraryFeedback
Sign in
FRENES
Loading views…Recent views only, across all languages. Vercel history is unavailable for this page. Repeat visits in the same tab are grouped for 30 minutes.
ShareLinkedInXFacebookWhatsApp
← All open problems
Unanswered question

Approximating the "magic" tree rotation: P or NP?

Combinatorics

Imported on November 28, 2026

The forum classified this question as unanswered when collected. This does not certify an open research problem; check the answers and revision history at the source.

Read the question with its definitions and background below. The source provides the full formulation and further discussion; the glossary and Wikipedia links offer additional reading aids.

Problem statement

Background. (tl;dr, skippable)

  • "Dynamic" binary search trees are well researched.

  • The "magic" rotation algorithm (="offline") knows the query sequence beforehand and thus uses a minimum of (costly) tree rotations. (Call the cost C1C1C1.)

  • An "online" doesn't and thus is slower (C2C2C2). The ratio r=C2/C1r=C2/C1r=C2/C1 of such an algorithm is of utmost interest.

  • The offline cost varies with the instance (O(n)O(n)O(n) to O(nlog⁡n)O(n\log n)O(nlogn)).

  • Actually computing it may be NP-complete.

  • For the general problem (queries may repeat) it is NP-complete. (Demaine)

  • For a permutation query Π\PiΠ (each item in the set {1…n}\{1\dots n\}{1…n} is queried exactly once, an interesting subproblem) at least an O(4n)O(4^n)O(4n) algorithm is known, so at least it can't get worse than NP. (Seidel)

  • Speculation S\mathfrak SS: The subproblem is NP-complete too, but even an r=O(1)r=O(1)r=O(1) approximation is in P and can be found in near O(n)O(n)O(n) time. (Demaine, everyone else)

  • A very good algorithm is "Greedy Future", which at least can implemented to run in O(n2)O(n^2)O(n2) time, r≥26/17r\ge 26/17r≥26/17 but it is still open whether r=O(1)r=O(1)r=O(1) holds for each instance. (My Master thesis :-)

  • No r=O(1)r=O(1)r=O(1) online algorithm is actually known. The attained O(log⁡log⁡log⁡n)O(\log\log\log n)O(logloglogn) should be good enough for anyone, though :-)

I now present a heuristic, which is the basis (there are a number of snags, so a positive answer won't necessarily solve S\mathfrak SS, and I won't go into details) for a good approximation.

  • Let Π\PiΠ be an permutation of {1…n}\{1\dots n\}{1…n} as above, BBB be a binary string of length nnn and B′=Π(B)B'=\Pi(B)B′=Π(B) its permutation under BBB. Define a cost CCC of any BBB given some Π\PiΠ: For each adjacent pair of 000s in BBB add 111 to CCC. For each adjacent pair of 111s in B′B'B′ add 111 to CCC. Given PPP, find the cheapest PPP.

  • Since a "diamond of death" (pattern 0213∈P0213\in P0213∈P) costs at least 111 for any BBB, BBB can have cost O(n)O(n)O(n) (just repeat that pattern).

  • Nevertheless, for a random PPP CCC tends to be extremely low. (At least for small nnn, that may change...)

  • Task T\mathfrak TT: Given Π\PiΠ, find the BBB with lowest cost CCC. Solutions where the numbers of 000s and 111s are about equal will be preferred. (Such a BBB, as said, with some fudgery applied, can be used as a very good approximation).

Question: Is T\mathfrak TT NP-complete? (Meaning more or less: Do you offhandedly see a reduction scheme?)

Statement and context adapted from MathOverflow · Hauke Reddmann

CC BY-SA 4.0 · Formatting adapted; mathematical formulas preserved · Source history

Topics : co.combinatorics · binary-tree

Authors listed by the source : Hauke Reddmann

Sources and original status

  • MathOverflow Status in source : unanswered at collection

Last activity on the question : March 30, 2022

Coverage, sources and method

This count measures imported entries, including distinct variants. It is not a count of all open mathematical questions worldwide. One entry may belong to several fields and sources.

This directory is neither exhaustive nor updated in real time. “Reported open” describes the source classification observed at import; imported entries have not each undergone independent mathematical verification. The 32 explained entries were reviewed separately.

Formal Conjectures: only “research open” statements with no reported formal proof are retained; their tag is checked in a pinned repository revision. Variants remain distinct. A “sorry” placeholder is not sufficient to establish open status.

Erdős: solved or independent problems and entries with a Lean solution are excluded, including “open (Lean)”. Exact matches to the main Formal Conjectures statements are merged.

Open Problem Garden: the open index is checked against the solved index; spam, identified clones and some outdated statuses are excluded. Statements and definition context are attributed to their original pages; formulas are preserved and the content remains under the GFDL. Recognized duplicates across sources are merged; this does not resolve every mathematical equivalence.

OEIS: direct extraction of conjectural comments and formulas, one entry per sequence, excluding mentioned resolutions. MathOverflow and Math Stack Exchange: questions classified as unanswered by their API, excluding closed posts and non-research categories. They remain distinct from problems reported open. This is a partial, dated collection; every entry credits its authors and license.

Documented exclusions account for recent announcements and conflicting statuses. A stronger variant or a special case can remain open after a different statement is settled.

Attribution: The Formal Conjectures Authors; teorth/erdosproblems and contributors; Open Problem Garden and contributors. Each source retains its license.

  • Formal Conjectures · 1,924 · Apache-2.0 / CC-BY-4.0
  • Erdős Problems (teorth) · 622 · Apache-2.0
  • Open Problem Garden · 404 · GFDL (source content); only title/category/link metadata imported
  • OEIS · 18,857 · CC BY-SA 4.0
  • MathOverflow · 19,035 · CC BY-SA (version on each entry)
  • Mathematics Stack Exchange · 35 · CC BY-SA (version on each entry)
Report a development or correction
mathatlas

An independent atlas to understand, read, and question research.

The papers present claimed results at different stages of verification.
NewsletterShare feedbackAbout Data and privacy
Created by Sonny Mupfuni