Recursive call is that this method call oneself.
Specially, Function uses this method.
Below C Source is example for recursive call function.
As you see, Function RF called the RF that is name of oneself.
Now I give you one question.
Please make Fibonacci sequence function using recursive call method.
You can see Fibonacci condition <here>
The LINUX that is name of OS is also recursive call type.
Some people said " LINUX is abbreviation of LINUX is not UNIX. "
Here, LINUX is call LINUX is not UNIX. In this sentence, LINUX is call LINUX is not UNIX again..
so..like that
(((((LINUX is not UNIX) is not UNIX) is not UNIX) is not UNIX) is not UNIX) is not UNIX
This case sink into the infinity roof because there is not escape condition. so we have to be careful when we use recursive call.
<English is very difficult.. Plz someone correct my poor sentence.>
์ฌ๊ทํธ์ถ์ด๋ ์๊ธฐ๊ฐ ์๊ธฐ์์ ์ ํธ์ถํ๋ ๋ฐฉ์์ ๋งํ๋ค.
ํนํ ํจ์์์ ์ด๋ฐ ์ผ์ ํ๋ค.
์ด๋ฐ ์ฌ๊ทํธ์ถ ํจ์๊ฐ ํ์ํ ๊ฒฝ์ฐ๋
์ด๋ค ์ผ์ ํ๋ ํจ์๊ฐ ์ฌ๋ฌ๊ฐ์ง ์กฐ๊ฑด์ ๋ํ์ฌ ๋๊ฐ์ ์ผ์ ํ ํ์๊ฐ ์์ ๋์ด๋ค.
๊ทธ๋ฐ๋ฐ ๋ค์ ์ฌ๋ฌ๊ฐ์ง ์กฐ๊ฑด์ด ์ฃผ์ด์ง๊ณ ๋๋ค์ ๊ฐ์ ์ผ์ ํด์ผํ ๋ ์ฌ๊ท ํธ์ถ ํจ์๋ฅผ ์ด๋ค.
์ด๊ฑด ๋ง๋ก ํํํ๊ธฐ ๋ฌด์ฒ ์ด๋ ต๋ค.. ใ
ใ
ํ๊ฐ์ง ์์ ๋ฅผ ๋ณด์
----------------------------------------------
int RF(int A);
void main()
{
printf("%d\n", RF(5) );
}
int RF(int A)
{
int B=0;
if(A>1)
{
B = RF(A-1);
}
return A+B;
}
------------------------------------------------
RFํจ์๋ 1์์ ์
๋ ฅ๋ ์ซ์๊น์ง ๋ํ๋ ํจ์์ด๋ค.
RFํจ์๋ฅผ ๋ณด๋ฉด ๋ณธ๋ฌธ์์ ๋ค์ ์๊ธฐ ์์ ์ ํธ์ถํ๋ ๊ฒ์ ๋ณผ ์ ์๋ค.
์ด๋ฐ ๋ฐฉ๋ฒ์ ์ฌ๊ทํธ์ถ์ด๋ผ๊ณ ํ๋ค.
์ฌ๊ธฐ์ ๋ฌธ์ ๊ฐ ๋๊ฐ๋๋ค.
์ด๋ฐ ์ฌ๊ทํธ์ถ ๋ฐฉ์์ ์ด์ฉํ์ฌ ํผ๋ณด๋์น ์์ด์ ๊ฐ์ ๊ตฌํ๋ ํจ์๋ฅผ ๊ตฌํํด ๋ณด์์ค.
์ด๋ฒ์๋ ์ข ์ด๋ ค์ธ ๊ฑธ.. ใ
ใ
์ด๋ฐ ๊ฒ๋ ์ฌ๊ท ํธ์ถ์ผ๊น?
LINUX ๋ผ๋ ์ด์์ฒด์ ๊ฐ ์๋ค.
๊ทธ๋ฐ๋ฐ ์ด๊ฒ์ LINUX is not UNIX์ ์ฝ์๋ผ๊ณ ํ๋ค. ๊ทธ๋ฐ๋ฐ ์ฌ๊ธฐ์ LINUX๋ ๋ค์ LINUX is no UNIX๋ฅผ ๋ง๋ ๋ค.
๋ฐ๋ผ์ ..
(((((LINUX is not UNIX) is not UNIX) is not UNIX) is not UNIX) is not UNIX) is not UNIX
LINUX is not UNIX์์ LINUX๊ฐ ๊ณ์ LINUX is not UNIX๋ฅผ ์์ฑํด ๋ธ๋ค..
์ด๋ ๋ฏ ์ฌ๊ทํธ์ถ์ ์กฐ๊ฑด ๋ฌธ์ผ๋ก break๋ฅผ ์ ํด์ฃผ์ง ์์ผ๋ฉด ๋ฌดํ ๋ฃจํ์ ๋น ์ง๊ธฐ ์ฝ๋ค..
9/05/2011
What is a Recursive Call? and Make Fibonacci sequence function using Function of the Recursive Call type.
Subscribe to:
Post Comments (Atom)
-
This is data acquisition source code of LMS511(SICK co.) Source code is made by MFC(vs 2008). The sensor is communicated by TCP/IP. ...
-
As you can see in the following video, I created a class that stitching n cameras in real time. https://www.youtube.com/user/feelmare/sear...
-
Optical Flow sample source code using OpenCV. It programed based on http://feelmare.blogspot.kr/2012/10/make-2-frame-having-time-interv...
-
Image size of origin is 320*240. Processing time is 30.96 second took. The result of stitching The resul...
-
Logistic Classifier The logistic classifier is similar to equation of the plane. W is weight vector, X is input vector and y is output...
-
Creating a custom CUDA kernel that directly utilizes tensor cores is an advanced topic, as tensor cores are typically accessed through highe...
-
yolo v5 data coordinate format ex) str_v = "32 0.262 0.7878 0.314 0.385" #read image cvmat = cv2.imread(img_path) #get height, w...
-
* Introduction - The solution shows panorama image from multi images. The panorama images is processing by real-time stitching algorithm...
-
OpenCV has AdaBoost algorithm function. And gpu version also is provided. For using detection, we prepare the trained xml file. Although...
-
Video stabilization example source code. The principle is like that... Firstly, to obtain 2 adjacent images extract good feature to t...
๋ฏผํ๊ท
ReplyDelete#include
int fi(int n);
void main()
{
printf("%d\n",fi(11));
}
int fi(int n)
{
int a=0;
int b=1;
if(n>2)
{
a=fi(n-2);
b=fi(n-1);
}
return a+b;
}
JeKang's Code :
ReplyDelete#include
int fiv(int Num);
int main()
{
int Num=0;
scanf("%d", &Num);
printf("%d",fiv(Num));
}
int fiv(int Num)
{
int Answer=0;
if(Num==0) return 0;
else if(Num==1) return 1;
else if(Num>1){
Answer=fiv(Num-2)+fiv(Num-1);
return Answer;
}
}
์์ ๋ฏผํ๊ท
ReplyDelete#include
int fi(int n);
void main()
{
int n;
printf("ํผ๋ณด๋์น์์ดfi(n):");
scanf("%d",&n);
printf("%d\n",fi(n));
}
int fi(int n)
{
int a=0;
int b=1;
if(n>=2)
{
a=fi(n-2);
b=fi(n-1);
return a+b;
}
else if(n==0) return a;
else if(n==1) return b;
}
#include
ReplyDeleteint RecursiveF(int n);
void main()
{
int x=20;
for(int i=0; i<x; ++i)
{
printf("f(%d) = %d\n", i, RecursiveF(i) );
}
}
int RecursiveF(int n)
{
if(n==0)
return 0;
if(n==1)
return 1;
return (RecursiveF(n-2) + RecursiveF(n-1));
}
๋ค๋ค ์ํ๋ค.
ReplyDelete์ด๋? ๋ฐ๋ณต์ ๋ฐฉ๋ฒ๊ณผ ์ฌ๊ทํธ์ถ์ ๋ฐฉ๋ฒ์ค ์ด๋ค๊ฒ ํ๋ก๊ทธ๋จ ํ๊ธฐ ํธํ๊ฒ ๊ฐ์?(์๊ธฐ ์๊ฐ ์ฝ๋ฉํธ ํ๋์ฉ ๋ฌ๊ธฐ~)
...
ํ์ง๋ง ์ฌ๊ทํธ์ถ ๋ฐฉ๋ฒ์ ๋ฐ๋ณต์ ์ธ ๋ฐ๋ณต๋ณด๋ค ํ๋ก๊ทธ๋จ์ ๋ถ๋ด์ ๋ง์ด ์ฃผ๋ ๋ฐฉ๋ฒ์ด์ผ.. ์๋ํ๋ฉด ํจ์์์ ํจ์๋ฅผ ํธ์ถ.. ๋ ๋ค์ ํจ์ ํธ์ถ.. ์ด๋ ๊ฒ ์์ผ๋ก ๋ค์ด๊ฐ์๋ก ํ๋ก๊ทธ๋จ์ ๊ธฐ์ตํ ๊ฒ ๋ง์์ง๊ฑฐ๋ .
ํจ์๋ฅผ ๋ง์ณค์๋ ๋์๊ฐ์ผํ๋ ์์น ๊ทธ๋ฆฌ๊ณ ๊ณ์ ์์ฑ๋๋ ์ง์ญ ๋ณ์๋ค(ํธ์ถ๋ ํจ์๊ฐ ๋๋๊ธฐ์ ๊น์ง ํจ์์์ ๋ณ์๋ค์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฐจ์งํจ)..
๊ทธ๋์ ๋๋๋ก ์ฌ๊ทํจ์๋ ์์ฐ๋๊ฒ ์ข์ง๋ง ์ปดํจํฐ ์ฑ๋ฅ์ ๋ฌด๋ฆฌ๋ฅผ ์์ค๋ค๋ฉด ์๊ณ ๋ฆฌ์ฆ์ ๊น๋ํ๊ฒ ์์ฑ์ํฌ์ ์์ง..
๊ทธ๋ฆฌ๊ณ ์ฌ๊ทํธ์ถ์ ์๊ณ ๋ฆฌ์ฆ ๊ณต๋ถํ ๋ ๋ ผ๋ฆฌ์ ์ฌ๊ณ ๋ฅผ ํค์ฐ๊ธฐ ์ํด ์ข์ ๋ฐฉ๋ฒ์ธ๊ฒ ๊ฐ๋ค..
๊ทธ๋ผ ๋ฟ ~
์ฌ๊ทํธ์ถ ๋ฐฉ๋ฒ์ ์ด๋ฒ์ ์ฒ์ ํ๋ก๊ทธ๋๋ฐ ํด๋ด์ ๊ทธ๋ฐ์ง ๋ชจ๋ฅด๊ฒ ๋๋ฐ ๋ฐ๋ณต๋ฌธ์ด ํจ์ฌ ํธํ๊ฑฐ ๊ฐ์์. ์์ ํ๋์ด ์ ์ด๋์ ๊ฑฐ ์ฒ๋ผ ํจ์์์ ํจ์์์ ํจ์... ๊ณ์ ํธ์ถํ๊ธฐ ๋๋ฌธ์ ํธ์ถ ์์น์ ๋ฐ๋ผ ๊ฒฐ๊ณผ๋ฅผ ์์ํ๊ธฐ๊ฐ ๋๋ฌด ํ๋ค์์ด์.
ReplyDelete๋ ผ๋ฆฌ์ ์ฌ๊ณ ๋ฅผ ํค์ฐ๋๋ฐ๋ ์ข์ ๋ฐฉ๋ฒ์ธ๊ฑฐ ๊ฐ์๋ฐ, ์ฅ์ ๋ณด๋ค๋ ๋จ์ ์ด ๋ง์์ ์์ง ์ด๋ณด์ธ ์ ๋ ๋ฐ๋ณต๋ฌธ์ผ๋ก ๋ง๋๋๊ฒ ์ข์๊ฑฐ ๊ฐ์์.ใ ใ