skully-coder/competitiveprogramming

Find Kth Child In Nth Generation in Family Tree. [Competitive Programming Problem]

ankit-95 opened this issue · 3 comments

Is your feature request related to a problem? Please describe.
In Family of Akaash, every male gives birth to the first Male and then Female whereas each Female gives birth to the first female
then male
We are given nth generation and kth child. We need to find the Gender of the child.
Input : N = 3 , k = 4
Tree :
Screenshot 2021-10-04 at 2 30 06 PM

Describe the solution you'd like
I will be solving this issue through recursion where we will traverse the tree using the divide and conquerer approach along with Recursion.

Describe alternatives you've considered
We can traverse each level one by one but it will be time-consuming which can be overcome by [log base k (n)] time complexity.

Additional context
@skully-coder. Please assign this issue to me.

Hey @ankit-95, this looks like a good question, assigning this to you.

Hi, I want to contribute to this issue. Please assign me. @skully-coder

@skully-coder . I have created a pull request #177 which will close this issue.