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

5 tips for IT managers in job interviews
5 tips for IT managers in job interviews
News
Commentary on Press Freedom Day: The thing with your own nose
Commentary on Press Freedom Day: The thing with your own nose
Software
GNT: the top news of the week that you shouldn’t miss
GNT: the top news of the week that you shouldn’t miss
Computing
No, your electric car battery is not likely to be scrapped in 5 years
No, your electric car battery is not likely to be scrapped in 5 years
Mobile

You Might also Like

GNT: the top news of the week that you shouldn’t miss
Computing

GNT: the top news of the week that you shouldn’t miss

0 Min Read
contracts signed with several AI giants…except Anthropic!
Computing

contracts signed with several AI giants…except Anthropic!

4 Min Read
the Chinese exascale supercomputer with 47,000 purely CPU processors!
Computing

the Chinese exascale supercomputer with 47,000 purely CPU processors!

4 Min Read
Is lunar dust the solution to building on the Moon?
Computing

Is lunar dust the solution to building on the Moon?

2 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?