on-internet
← Community

Find an explicit criterion about a specific class of integer sequences expressed by a recursive predicate

Stack Overflow ·

Let a "branching" operation be an operation that, given a finite sequence of integers, increments and duplicates one element in place. For example: (3,1,4,1,7) → (3,1,5,5,1,7) A tree sequence is a sequence of integers that can be derived from the "root" sequence (0) by applying a sequence of such branching operations. For example, (1,2,2) is a tree sequence (derived via (0) → (1,1) → (1,2,2)), but (2,1,2) is not. Below is a recursive algorithm that (I think) determines whether a given sequence is a tree sequence. Algorithm A Input: an integer sequence (a0, a1, ..., an−1) If (a0, a1, ..., an−1)

Comments

Sign in or sign up to comment and upvote.

No comments yet.