input: 233
current input is 233
when function is called, the return value is added to the call stack
|----------------------|
| findBinary(116, "1") |
|----------------------|
move to the next recursion call
current input is 116
when function is called, the return value is added to the call stack
|----------------------|
| findBinary(58, "01") |
| findBinary(116, "1") |
|----------------------|
move to the next recursion call
current input is 58
when function is called, the return value is added to the call stack
|-----------------------|
| findBinary(29, "001") |
| findBinary(58, "01") |
| findBinary(116, "1") |
|-----------------------|
move to the next recursion call
current input is 29
when function is called, the return value is added to the call stack
|------------------------|
| findBinary(14, "1001") |
| findBinary(29, "001") |
| findBinary(58, "01") |
| findBinary(116, "1") |
|------------------------|
move to the next recursion call
current input is 14
when function is called, the return value is added to the call stack
|------------------------|
| findBinary(7, "01001") |
| findBinary(14, "1001") |
| findBinary(29, "001") |
| findBinary(58, "01") |
| findBinary(116, "1") |
|------------------------|
move to the next recursion call
current input is 7
when function is called, the return value is added to the call stack
|-------------------------|
| findBinary(3, "101001") |
| findBinary(7, "01001") |
| findBinary(14, "1001") |
| findBinary(29, "001") |
| findBinary(58, "01") |
| findBinary(116, "1") |
|-------------------------|
move to the next recursion call
current input is 3
when function is called, the return value is added to the call stack
|--------------------------|
| findBinary(1, "1101001") |
| findBinary(3, "101001") |
| findBinary(7, "01001") |
| findBinary(14, "1001") |
| findBinary(29, "001") |
| findBinary(58, "01") |
| findBinary(116, "1") |
|--------------------------|
move to the next recursion call
current input is 1
when function is called, the return value is added to the call stack
|---------------------------|
| findBinary(0, "11101001") |
| findBinary(1, "1101001") |
| findBinary(3, "101001") |
| findBinary(7, "01001") |
| findBinary(14, "1001") |
| findBinary(29, "001") |
| findBinary(58, "01") |
| findBinary(116, "1") |
|---------------------------|
move to the next recursion call
current input is 0
since return value for this has hit the base case,
it will start executing by poping the top stack frame from the call stack
return result: "11101001"
|---------------------------|
| "11101001" |
| findBinary(1, "1101001") |
| findBinary(3, "101001") |
| findBinary(7, "01001") |
| findBinary(14, "1001") |
| findBinary(29, "001") |
| findBinary(58, "01") |
| findBinary(116, "1") |
|---------------------------|
return result: "11101001"
|---------------------------|
| |
| "11101001" |
| findBinary(3, "101001") |
| findBinary(7, "01001") |
| findBinary(14, "1001") |
| findBinary(29, "001") |
| findBinary(58, "01") |
| findBinary(116, "1") |
|---------------------------|
return result: "11101001"
|---------------------------|
| |
| |
| "11101001" |
| findBinary(7, "01001") |
| findBinary(14, "1001") |
| findBinary(29, "001") |
| findBinary(58, "01") |
| findBinary(116, "1") |
|---------------------------|
return result: "11101001"
|---------------------------|
| |
| |
| |
| "11101001" |
| findBinary(14, "1001") |
| findBinary(29, "001") |
| findBinary(58, "01") |
| findBinary(116, "1") |
|---------------------------|
return result: "11101001"
|---------------------------|
| |
| |
| |
| |
| "11101001" |
| findBinary(29, "001") |
| findBinary(58, "01") |
| findBinary(116, "1") |
|---------------------------|
return result: "11101001"
|---------------------------|
| |
| |
| |
| |
| |
| "11101001" |
| findBinary(58, "01") |
| findBinary(116, "1") |
|---------------------------|
return result: "11101001"
|---------------------------|
| |
| |
| |
| |
| |
| |
| "11101001" |
| findBinary(116, "1") |
|---------------------------|
return result: "11101001"
|---------------------------|
| |
| |
| |
| |
| |
| |
| |
| "11101001" |
|---------------------------|
return result: "11101001"
|---------------------------|
| |
| |
| |
| |
| |
| |
| |
| |
|---------------------------|