Write a function child_indices(parent,branch_factor) that returns a list containing the list ofindices where the children of the node at index parentwill be stored for a heap list with the given branch_factor (ie, abranch_factor-heap). Python language
Notes:
- The function should return all possible indices and the indicesshould be in order from smallest to biggest.
- The values in the heap list start at index 1 - that is the rootof the heap is at index 1 in the heap list.
Test | Result |
---|
print(child_indices(1,2)) | [2, 3] |
print(child_indices(2,2)) | [4, 5] |
print(child_indices(1,3)) | [2, 3, 4] |