Triangle Calc: Parent Index to Child Indexes

  • Context: Undergrad 
  • Thread starter Thread starter DavidSnider
  • Start date Start date
  • Tags Tags
    Calculation Triangle
Click For Summary

Discussion Overview

The discussion revolves around determining the child indexes of elements in a triangular structure when flattened into a one-dimensional array. Participants explore how to derive a function that maps a parent index to its corresponding child indexes, focusing on the relationships between elements in the triangle.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • Post 1 introduces the problem of finding child indexes for a flattened triangle structure and provides an example of the triangle layout.
  • Post 2 questions whether 7 is a child of 5, indicating potential confusion about the relationships in the triangle.
  • Post 3 clarifies the child relationships, listing the children for each parent index in the triangle.
  • Post 4 suggests a method for visualizing the triangle and hints at a formula for determining the child indexes based on the row and position of the parent.
  • Post 5 presents a formula for calculating the first element in the nth row and introduces a method for finding the index of a parent based on triangular numbers.

Areas of Agreement / Disagreement

Participants express differing views on the relationships between specific elements, particularly regarding the status of 7 as a child of 5. While some clarifications are made, no consensus is reached on the overall approach to the problem.

Contextual Notes

Participants rely on the structure of triangular numbers and their properties, but some assumptions about the relationships and indexing may not be fully resolved.

Who May Find This Useful

Individuals interested in combinatorial mathematics, data structures, or algorithm design may find this discussion relevant.

DavidSnider
Gold Member
Messages
511
Reaction score
147
Let's say you have a triangle like:
1
2 3
4 5 6
7 8 9 10

The children of each element in the triangle are those directly adjacent on the next row. For example the children of 4 are 7 and 8. The children of 5 are 8 and 9.

Now let's say we flatten it to: [1,2,3,4,5,6,7,8,9,10]

Is there a way to compose a function that takes the index of the parent and returns a tuple containing the indexes of the children? (Assume 0 based indexes. The 1 through 10 are values, not indexes)
 
Last edited:
Mathematics news on Phys.org
Is 7 a child of 5?
 
No.

1: 2,3
2: 4,5
3: 5,6
4: 7,8
5: 8,9
6: 9,10

It's easier to picture when you draw the triangle as a pyramid shape, but I couldn't get the forum to format it that way.
 
Hi DavidSnider! :smile:

Use the CODE tag :wink:
Code:
          1
         2 3
        4 5 6
       7 8 9 10

Hint: the kth element in the nth row is parent to the kth and k+1th elements in the n+1th row, and the index of the first element in the nth row is … ? :smile:
 
Ah, thanks. I think I got it.

First element in nth row is the same as the triangle number:
[tex]\frac{n^2 + n}{2}[/tex]

What I needed was the Triangle root:
[tex]\frac{-1\pm\sqrt{8n+1}}{2}[/tex]

so the index would be:
[tex]n+\frac{1+\sqrt{8n + 1}}{2}[/tex]
 
Last edited:

Similar threads

  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 24 ·
Replies
24
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
5K
Replies
2
Views
3K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 16 ·
Replies
16
Views
3K
Replies
2
Views
2K
  • · Replies 27 ·
Replies
27
Views
4K
  • · Replies 12 ·
Replies
12
Views
2K