Recursions & Recursive Functions in C++ | C++ Tutorials for Beginners #18
Вставка
- Опубліковано 18 вер 2024
- Download the best IDE for C, C# and C++: bit.ly/WholeTo...
►Source Code & Resources: codewithharry....
►This video is a part of my C++ playlist: • C++ Tutorials In Hindi
►For Doubt Solving, Brain Storming Sessions & guaranteed replies, join the channel membership here: / @codewithharry
►Click here to subscribe - / @codewithharry
►Checkout my English channel here: / programmingwithharry
Best Hindi Videos For Learning Programming:
►Learn Python In One Video - • Python Tutorial In Hin...
►Python Complete Course In Hindi - • Python Tutorials For A...
►C Language Complete Course In Hindi -
• C Language Tutorials I...
►JavaScript Complete Course In Hindi -
• JavaScript Tutorials I...
►Learn JavaScript in One Video - • JavaScript Tutorial
►Learn PHP In One Video - • Learn Php In One Video...
►Django Complete Course In Hindi -
• Python Django Tutorial...
►Machine Learning Using Python - • Machine Learning Tutor...
►Creating & Hosting A Website (Tech Blog) Using Python - • [Hindi] Web Developmen...
►Advanced Python Tutorials - • Intermediate/Advanced ...
►Object Oriented Programming In Python - • Object Oriented Progra...
►Python Data Science and Big Data Tutorials - • Python Data Science an...
Follow Me On Social Media
►Website (created using Flask) - www.codewithhar...
►Facebook - / codewithharry
►Instagram - / codewithharry
►Personal Facebook A/c - / geekyharis
Twitter - / haris_is_here
N(N-1)! = Katai jahar concept bilkul sahi paaji😂😁
dedo ♥️♥️♥️♥️♥️♥️
12th maths padhi hoti toh tujhe zeher nhi lagta ekdum basic hai ye
@@nirmalbuoy 11th maths be
@@palashagrawal2343 Ha wahi jo bhi hai, hume JEE coaching ke waqt aisa kuch 11th 12th nahi padhaya tha isiliye pata nahi kaunse class me aata hai
11th maths Padhi nahi hai aapne bca wale ho na
Halwa hai😂😂
fib(5)=fib(4) + fib(3) = fib(2) + fib(3) + fib(2) + fib(1) should in place of fib(2) + fib(3) + fib(2) + fib(3).
yes
Ye chij mujhe samaj ni aayi ki Harry bro ne kaise toda
Could you pleas explain me?
fib(n) = fib(n-1) + fib(n-2) apply this .
@@apmotivationakashparmar722
n = 5 so fib(5) = fib(4) + fib(3) ho gya
But iske bad ye dubara se jab run hoga to
fib(4) ke liye fib(4-2) = fib(2)
Fib(4-1) = fib(3)
And fib(3) ke lye fib (3-1) = fib(2)
Fib(3-2) = fib(1)
Banega but lecture me fib(1) to kahi hai hi nhi
@@anju7334 Jab fib(1) meh jayega toh value toh 1 return karega kyuki n
//Author:Harman kaur
//purpose:fibonacii series
#include
using namespace std;
int fib(int n)
{
if (n < 2)
{
return 1;
}
else
{
return fib(n - 1) + fib(n - 2);
}
}
int main()
{
int num;
cout num;
cout
what will be the iterative approach he is mentioning is it with the help of loops
Thank you! Needed this for an assignment
Can you give practice uestions after every lecture
Loving this playlist.
Day-12
Completed upto Tutorial-18
Date-14/12/2022
Time-19:32
Topic-Recursions and Recursive Functions
bro are u from cs / it branch?
@@sayman099 yes bro,i am from it branch.
@@AnEngineerHuman CPP DONE???
@@sayman099 TUM KONSE BRANCH SE HOO??
@@pratikingle3963 ha ,keh sakte ho .Par jada practise nahi hui...
Thanks for reminding me
I can't even imagine a world without stack overflow and codewithharry!
can u tell me how 2 returned in fibbonacci at 3?
@@seasonalmind7241 f(3) = f(2)+f(1) = [f(1)+f(0)] + f(1) = f(0) + 2 f(1) = 1 + 2(1) = 1+2 = 3. Makes sense?
@@desiquant yeah it definitely does.Thanks.
increase u r imagination
competitive programming pe series bana bhai, Please!
Do you find cp series???
@@SK-gp6cm wow 2 years back
Yes many series are there, I also bought a course on udemy but it is more of DSA focused rather than cp
@@Abhishek-dp5tc can you share that link
Bro where can i practice question or should i practice question or first complete whole series of c++ here
@@Ramneet04 first complete this series
Sir, jab samajh me awajata hay, to video ending song bohat acha lagtahay.
7:55 what a clear Explanation
Legendary 😃
We can also do this by using Array, It decreases the execution time.
1. Factorial :
int fact(int n){
int a[100];
a[0] = 0, a[1] = 1, a[2] = 2;
for(int i = 3;i
bhaiya is factorial wale tarike se aur harry bhaiya ke tarike se bhi 20! ka ans nhi aa rha
ans negative m de deta h
koi solution is ko solve krne ka for greater integer values
@@ayushparmar7729 20 ka factorial?
@@ayushparmar7729 bhai 20 ka factorial itna badha hota h ki int mi nhi aa sakta
kyuki int ki range -2147483648 to 2147483647 hoti h aur iska factorial quadrillion mei h
@@kartikbisht1909 bhai vo to ho gya tha jo bhi digit calculate krke aa rhi h use array m store krte joa aur pos pointer ko +1 krte jao
@@ayushparmar7729 ook
While calculating the factorial of very big number, we get zero since computers try to give the answer in exponential form. So, to get the actual result, change the data type of the function to double to get the exact value. Hope this helps!
Actually, I wanted to calculate the factorial of 100 but it gave 0 as an answer...I was confused. But because of your advice, I changed int to double and I got the correct answer. Thank You!
@@user-th4dw9zd5l Happy to know that the solution I gave, helped somebody :) ! This made my day :)
Bhai datatype long used karke dekh
@@Sports-im6yveven better long double😊
@@bansilalnabediya3501 thanks bhai ❤
In the fib function, the base case returns 1 for n
11:42 if(n
2:52
n! = n*(n-1)!
It is correct .
Let we take example :
Factorial of 5 = 5×4x3x2x1 .
Instead of multiplying like above we should first calculate factorial of 4
and then multiply it with 5 . Now we get factorial of 5.
Hme bhi ata hai
@@programinglife.1400 😂😂
I realized something that all the people who are watching this to learn c++ are building there programming style a lot similar to harry bhai's
Awesome video
Question of 03:00
yess
Ur explanation is Just amazing👍👍👍👍👍The Best
3:06 ----> this is correct
16:00 It should be like this. Fib(3)= Fib(2)+Fib(1)...correct me if I'm wrong.
I think you are right since I was searching for this comment as well
You have made my coding life easy
IN last 16:30 - I will see you next time...... BGM(totally incredible)
For calculation nth term we can use a+(n-1)d, where a is 1st term and d is common difference
that's for constant series, but here the common difference is changing
Ha..it is the staple equation where the difference is fixed
👍👍👏Excellent explanation.
3:08 yes Harry Bhai we can write.
we can also find factorial using static as in previous video.
How? I tried but it isn't possible without recursion or looping.
Data structures aur algorithm pe playlist 🙏🙏🙏🙏
go to geeksforgeeks until codewithharry sir upload Data structures and algorithms
@@nikhilraj1842 thanks
@@nikhilraj1842 can u plz tell me the roadmap for programming language with dsa
@@niteshbovi769 well i am not a professional in this topic as I learned which i like to do in dsa like question solving and I Don't follow a roadmap.
So i can't give you roadmap for this.
recursions means a function is calling itself on its own until it gets the answer
make a complete course on data structure and algorithum
please sir
Already there on channel bro 😃😃
@@sanatani_raj462 Tu 10 mahine baad reply karega ...toh woh bana liya hoga naa ????
Sir please provide practice questions also
yes, we write n*(n-1) to the n!
Your way of teaching is really awesome . But I have one request can u plz written program separately , sometime it's confusing and irritating too...
yeah even I felt the same
Love these content
I really love all of your videos BUT please change your chrome browser theme to DARK MODE because when you switch from vs code to chrome browser it hurt my eyes badly because we are so focused on your video and suddenly going from black screen to white screen really hurt eye cornea and I cant tolerate that feeling anymore please take this note on a serious measure...btw love your teaching style and keep it on!
recursion function is also known as aatmnirbhar function
oooo
Iterative approach for fibonacci.
#include
using namespace std;
void fibonacci(int n){
int a =0;
int b=1;
int sum =0;
cout
#include
using namespace std;
int factorial(int n){
if(n==0||n==1){
return 1;
}
else{
return n*factorial(n-1);
}
}
int main(){
int n;
cout
Write a C ++ Program. We have a day-to-day record of USD price in PKR for last 100 weeks. Find the week, which has a highest variation in PKR, while a base price is 160Rs = 1 USD. Also, find which week has the highest average USDprice
Sir Please Solve The Problem
Question mein to logic hain wahh
Teaching method is awesome👍👏
You are same like my sir very understanding
3:05 yes
Sir you make programing easy for me really thank you SSO much.....
Why fib(3) is fib(2)+fib(3)? I am bit confused. I thought it should be fib(2)+fib(1)
Yes you're right 👍
Ho jati hai jaldbaji mein galti 🙏
🙂thanks m bhi yahi confuse thi 😂aur 3 baar video dekhli iss chakkar m
Same doubt tha comment me clear ho gaya 😅
2:55 Yes it is factorial
Yes, n!=n*(n-1)!.
Thanks Harry Bhaiya
Best Explination Sir, Very Nice Video
2:51 sahi hoga kyuki yahi formula hai factorial nikaalne ka
bro pls practice set bana do us se aur bhi zyada confidence aa jaata hai jab saare questions complete krleta hu
First!!!
12:57 for n
3:08 yes it can be written
recursion means function call itself again an again until result is found
Recursion is just a function calling itself inside itself
Thanks bhaiya
fib(5)
// fib(4) + fib(3)
// fib(2) + fib(3) + fib(2) + fib(3)
harry bhai ap ne is mai ghalti krdi hai mai tou cinfused hogaya tha pehle ab clear hogaya
thank you sir
3:07 yes you can write.
You are the most intelligent programmer in the India
सर, आपसे एक सवाल था कि अगर में python series के साथ C++ की series भी साथ में लेकर चलू तो क्या ये, ठीक रहेगा, क्योंकि कुछ लोग बोलते है, कि C++ python से कठिन है सिखना।
ek samay pe ek language sikhna behtar hai,
aur python aur c++ ke syntax bilkul alag hai
@@Souravkumar-iw7gy pr mera mind bolra h ki C++ ke basics bhi saath lekr chalu taaki kb advanced pe aau to koi prblm na ho
@@Ajaykumar-nj5yz concepts to lagbugh same hi hai sirf syntax different hai
Yes
yes you are right
It will be
If(n
yes you are correct
3:11 Yes, Ofcourse
#include
#include
using namespace std;
void fibonacci_sequence(int );
int main()
{
int n;
coutn;
fibonacci_sequence(n);
return 0;
}
void fibonacci_sequence(int n)
{
int a=-1 ,b=1 ,i, sum , N=20;
cout
i want to call you and will say that...
HAA BHAI ACCESSS KARLI HAI PLAYLIST!!!!! KARLI HAIIIIII !!!!!!!!!!!!!!
yes we can
#include
using namespace std;
int work(int n){
if(n>=30){
return n = 3;
}
else if(n>=15){
return n = 4;
}
else if(n>=10){
return n = 5;
}
else if(n>=5){
return n = 6;
}
return n = 8;
}
int main(){
int a;
cout
3:05 Obviously sir
yes ❤
Fibonacci Series 0 se start hota hai. 12:46 par n sahi tha. Aapne 1 kar diya anways bade bade sahro me chotti chotti baat hote rahti hai
# same function in python
def factorial(x):
if x
But very slow as compared to cpp if you run it it will take 5-7 sec but in cpp even more lines of code will run under 2 sec
But code is wrong💯💯
n! = n(n-1)! . It is a basic funda for every JEE student.
bilkul sahi baat hogi
Great
yes we can write it
yes likh sakte hai
1:32 6! = 720
2:52 Sahi hogi
good teacher
yes we can write it tthat way
Seq 1,1,2,3,5,8...
Fibonacci me ek number aage kyun aa rha hai.... For example 3 enter krte h to 3 aata hai (2 aana chahiye)... Aur 4 enter krte h to 5 aata h(3 aana chahiye)..... Any solution for this??
3:06
Yes.
3:07 yes we can
Yes we can write 3:07
Now i understand kay India ka har bacha coder kyuon hai.
Wasa ap boht amazing ho sar manna padaga he is so amazing apki explanation to ItnA excellent ha ka na bhi samajh aya to ap samjha hi data han ItnA àcha aj tak mujha kisii na koi topic nhi samjhaya you are the best for explained every topic thank you so much sir thanks
Yes Sir, n! = n * (n-1)!
time 2:53
Yes , ture , n! = n * ( n -1)
Yes thk haie..❤
2:46
Yes It is correct
ye baat sahi hongi
want to hear pc fan sound?
give 900 as input in fibonacci program :-)
LOL! It will take a lot of memory.
@@AshutoshKumar-fu6qe results come with sacrifices 🙂
Bhaiya agar hum fibonacci function ko inline banate to kya hota?
Upload a video on factorial of large numbers like 100 and more.
It can be done if ur pc performance is extreme...
Yesh we can write
yes,we write this
I don't know programming very well but I know maths very well and according to me for example if we put 5=n then fib(5-2)=3+fib(5-1)=4 and putting 4 and 3 together we get 7 not 8 please tell me who's wrong the program or my maths
Ur math is wrong
fib(5-2)=fib(3) hota hai 3 nahi hota..waha fib(3) ki value 2 ayegi
Maths galat jagah se padh rahe ho. Tuition change karo
सही बात है।
true we can write that
yes, You can write
2:55 correct
Bhaiya.....so can we say that , recursion can be used in functions where their is need of both static and inline functions?
Because the function you had written for finding factorial would have also been possible if somehow we could static and inline together.
Of course not, because harry bhaiya ke hisab se dekha jae to inline function sirf normal function problem pe he use karna chahiye, reccursion simple nai hai fibonacci ko he dekh lo kaafi complicated hai
3:06 yes! likh sakte hai