By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
World of SoftwareWorld of SoftwareWorld of Software
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Search
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
Reading: CFG Tree Enumeration: Mastering Pairing Functions & Bijections | HackerNoon
Share
Sign In
Notification Show More
Font ResizerAa
World of SoftwareWorld of Software
Font ResizerAa
  • Software
  • Mobile
  • Computing
  • Gadget
  • Gaming
  • Videos
Search
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Have an existing account? Sign In
Follow US
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
World of Software > Computing > CFG Tree Enumeration: Mastering Pairing Functions & Bijections | HackerNoon
Computing

CFG Tree Enumeration: Mastering Pairing Functions & Bijections | HackerNoon

News Room
Last updated: 2026/03/14 at 8:52 AM
News Room Published 14 March 2026
Share
CFG Tree Enumeration: Mastering Pairing Functions & Bijections | HackerNoon
SHARE

Table of Links

Abstract and 1. Introduction

2. Pairing functions

  1. Enumerating trees
  2. LZ-trees
  3. Conclusion and References

2 Pairing functions

To construct a bijection between trees and integers, we use a construction that has its roots in Cantor [12]’s proof that the rationals can be put into one-to-one correspondence with the integers. Cantor used a pairing function [13] to match up N × N with N itself:

Other pairing functions are more convenient for some applications. A popular alternative, illustrated in Figure 1 is the Rosenberg-Strong pairing function [17],

Then, for example, n = 147 can be broken down as,

It may not also be obvious how to use this approach to generate from an arbitrary CFG where the productions allowed at each step vary depending on the CFG’s nonterminal types. In particular, there may be multiple ways of expanding each nonterminal, which differs depending on which non-terminal is used. A simple scheme such as giving each CFG rule an integer code and then using a pairing function like R to recursively pair them together will not, in general, produce a bijection because there may be integer codes that do not map onto full trees (for instance, pairings of two terminal rules in the CFG).

The issue is that in generating from a CFG, we have to encode a choice of which rule to expand next, of which there are only finitely many options. In fact, the number of choices will in general depend on the nonterminal. Our approach to address this is to use two different pairing functions: a modular “pairing function” to encode which nonterminal to use and the Rosenberg-Strong pairing function to encode integers for the child of any node. Thus, if a given nonterminal has k expansions, define a pairing function that pairs {0, 1, 2, . . . , k − 1} × N with N. A simple mod operation, shown in Figure 1, will work:

:::info
Author:

(1) Steven T. Piantadosi.

:::


:::info
This paper is available on arxiv under CC BY 4.0 license.

:::

[1] A function f such that f(x, y) > max(x, y).

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Twitter Email Print
Share
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
Previous Article Pixel Desktop vs Samsung DeX: Which phone-powered PC experience is better? Pixel Desktop vs Samsung DeX: Which phone-powered PC experience is better?
Next Article Consumer Reports Calls This  Power Bank On Amazon A ‘Smart Buy’ – BGR Consumer Reports Calls This $24 Power Bank On Amazon A ‘Smart Buy’ – BGR
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

248.1k Like
69.1k Follow
134k Pin
54.3k Follow

Latest News

Qualcomm responds to GBL exploit used on latest Snapdragon flagships
Qualcomm responds to GBL exploit used on latest Snapdragon flagships
News
The Google Pixel 10 Pro Fold drops to a much lower price on Amazon
The Google Pixel 10 Pro Fold drops to a much lower price on Amazon
News
Why My SAM3 Masks Flickered—and the Coordinate Bug Behind It | HackerNoon
Why My SAM3 Masks Flickered—and the Coordinate Bug Behind It | HackerNoon
Computing
UN: Putin’s deportation of Ukrainian children is a crime against humanity
UN: Putin’s deportation of Ukrainian children is a crime against humanity
News

You Might also Like

Why My SAM3 Masks Flickered—and the Coordinate Bug Behind It | HackerNoon
Computing

Why My SAM3 Masks Flickered—and the Coordinate Bug Behind It | HackerNoon

13 Min Read
The 5 Best Suits From Marvel’s Spider-Man: Miles Morales | HackerNoon
Computing

The 5 Best Suits From Marvel’s Spider-Man: Miles Morales | HackerNoon

7 Min Read
Comedian Workshop Data: AI Creativity Support & Human-AI Collaboration | HackerNoon
Computing

Comedian Workshop Data: AI Creativity Support & Human-AI Collaboration | HackerNoon

7 Min Read
Comedy’s Future: Focus Group Insights on AI Writing & Ethics | HackerNoon
Computing

Comedy’s Future: Focus Group Insights on AI Writing & Ethics | HackerNoon

4 Min Read
//

World of Software is your one-stop website for the latest tech news and updates, follow us now to get the news that matters to you.

Quick Link

  • Privacy Policy
  • Terms of use
  • Advertise
  • Contact

Topics

  • Computing
  • Software
  • Press Release
  • Trending

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

World of SoftwareWorld of Software
Follow US
Copyright © All Rights Reserved. World of Software.
Welcome Back!

Sign in to your account

Lost your password?