1
ここでは、配列の右または左の円を動かす再帰的プログラムの私の擬似コードです。私は複雑さを理解しようとしています(これはn、配列Aのサイズ、または左右どちらかに戻ることができるので2^nかもしれません)。"OR"を持つreturn文はどのような種類の再帰呼び出しですか?
私はまた、これが最後のreturn文にORを持つため、これに関する情報を見つけることができないので、どのような再帰があるか把握しようとしています。
Boolean rightWing (int circle, Array A, List<int> checkerList)
Integer lastPlace equals A.length - 1
If circle equals lastPlace then // base case for recursion
Return true
If circle < 0 then
Return false
If circle > lastPlace then
Return false
// impossible case
If checkerList contains (circle) returns True then
Return false
checkerList.add(circle) // add the circle to the list for the checker if it's an impossible case
Integer moveRight equals circle + A[circle]
Integer moveLeft equals circle - A[circle]
Return rightWing (moveRight, A, checkerList) or rightWing(moveLeft, A, checkerList)
「種類の再帰」を定義します。あなたが何を求めているのか不明です。 – EJP