skully-coder / competitiveprogramming

This repository aims to contain solutions and explanations to various competitive programming problems, which may be important for interviews and online tests of different companies.
https://skully-coder.github.io/competitiveprogramming/
MIT License
39 stars 90 forks source link

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

Closed ankit-95 closed 3 years ago

ankit-95 commented 3 years ago

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.

skully-coder commented 3 years ago

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

riya244 commented 3 years ago

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

ankit-95 commented 3 years ago

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