C++ Tutorial 8 : Recursion Algorithms & Overloaded Functions

  Рет қаралды 25,011

Derek Banas

Derek Banas

Күн бұрын

Code & Transcript : bit.ly/cplusplus8
Best C++ Book : amzn.to/2uU38X5
/ derekbanas
In this tutorial we continue learning not only the syntax of C++, but also how to solve problems using C++. We'll cover the BubbleSort, Recursion, Factorials, Fibonacci Numbers, Overloaded Functions and Work through many Problems.

Пікірлер: 84
@xavigordill0
@xavigordill0 6 жыл бұрын
I can do nothing but admire people like you who offer their knowledge to the world for free. Thank you infinitely for investing yor time and effort into teaching without expecting anything, in my opinin that is a true act of kindness and philantropy, and the world would benefit greatly from more people like you. Keep doing what you do, your students will always be thankful for it :)
@2271masoud
@2271masoud 6 жыл бұрын
your tutorials are the best resources on the planet. Thanks Derek
@derekbanas
@derekbanas 6 жыл бұрын
Thank you very much :)
@lunadusk8590
@lunadusk8590 4 жыл бұрын
In your Fibonacci example, you are confusing index with term. If it were stored in a vector then the 18 would indeed give 2584, however this is the 19th term of the sequence. Fib(1) should return 0, and Fib(2) = 1;
@philipchama2858
@philipchama2858 6 жыл бұрын
Thank you so much for the effort you put into the videos. Learning through problem-solving is very enjoyable and makes it sink in faster. Greatly appreciated as always.
@derekbanas
@derekbanas 6 жыл бұрын
Thank you I'm happy you are enjoying them :)
@Awesomekid2283
@Awesomekid2283 6 жыл бұрын
In your factorial function you should avoid creating the extra variable "result" when you can just return the value directly and you need to catch the 0! case in your return 1 if statement
@ledzeppeman
@ledzeppeman 6 жыл бұрын
Still the best channel out there. Hands down the absolute bedt instruction I've ever seen.
@derekbanas
@derekbanas 6 жыл бұрын
Thank you for the nice compliment :)
@zkfdsldfjsdjfl1
@zkfdsldfjsdjfl1 6 жыл бұрын
now we're talking I am glad you are done with the intro and started to delve into more interesting stuff am looking forward to future tutorials
@derekbanas
@derekbanas 6 жыл бұрын
I'm glad you liked it. Everything will continue getting more complex.
@jakesmith6853
@jakesmith6853 6 жыл бұрын
Thank you very much for the tutorials. Hope to see more☺
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) More are coming
@FritsvanDoorn
@FritsvanDoorn 6 жыл бұрын
Master Derek, Thumbs up for fun and education !!!
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :)
@publicstaticvoid3224
@publicstaticvoid3224 6 жыл бұрын
Derek is the hardest working KZbinr ever!! We appreciate all of your tutorials brother!
@derekbanas
@derekbanas 6 жыл бұрын
Thank you very much :) I'm doing my best
@siriacopereira3153
@siriacopereira3153 6 жыл бұрын
Freaking good tutorial!
@derekbanas
@derekbanas 6 жыл бұрын
Thank you very much :)
@JRasmusBm
@JRasmusBm 6 жыл бұрын
For anyone interested, I created a useful subvector function: std::vector SubVector(std::vector theVector, int start, int end) { std::vector::const_iterator first = theVector.begin() + start; std::vector::const_iterator last = theVector.begin() + end; std::vector newVec(first, last); return newVec; } Derek, do you know how to make it accept a generic vector in C++?
@ArjunandRem
@ArjunandRem 6 жыл бұрын
Thanks a lot for the tutorial. The last time I worked with C++ was in 2009. It seems to have changed a lot since then.
@derekbanas
@derekbanas 6 жыл бұрын
I'm glad you liked it :) Yes many new features have been added
@jakekudur2263
@jakekudur2263 6 жыл бұрын
it is beneficial, especially for students))
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) I'm doing my best
@shipilov23
@shipilov23 6 жыл бұрын
Although I'm Russian and do not understand much, but still a good Tutorial;) Continue in the same spirit))
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) I can understand your struggles because I'm currently learning Japanese. Many more videos are coming.
@zulumopuku5370
@zulumopuku5370 6 жыл бұрын
Да
@loganrobert5811
@loganrobert5811 6 жыл бұрын
If I initialize j outside the outer while loop, why does the bubble sort stop after just 1 round?
@sharadkochhar2941
@sharadkochhar2941 5 жыл бұрын
You are doing great job mate # Best on youtube SoFar # Please make more videos on complex things in Computer science!
@derekbanas
@derekbanas 5 жыл бұрын
Thank you for the compliment :)
@mcalex4747
@mcalex4747 3 жыл бұрын
Curiosity, how do you type this "void PrintHorzVector(std::vector& theVec);", having the "using namespace std;" void PrintHorzVector(int& theVec[ ]) - is it good????
@saarbsatr5479
@saarbsatr5479 5 жыл бұрын
I really don't understand why the PrintHorzVector works just fine, shouldn't the blocks containing a two-digit integer be larger than the ones containing a one-digit one since the amount of spaces is hardcoded and not dependent on the integer? edit. Also in the fib function, couldn't the else just be removed? Not trying to be a smart-ass, I love this series and I've learned a lot! Just curious.
@arkeodev4468
@arkeodev4468 6 жыл бұрын
Really great tutorials! Thanks... Derek, what is the best way to add a thousand separator to an integer in printf?
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) #include #include int main(void) { setlocale(LC_NUMERIC, ""); printf("%'d ", 1123456789); return 0; }
@youngmhd9439
@youngmhd9439 6 жыл бұрын
Nice video
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :)
@mukeshkumarsharma8447
@mukeshkumarsharma8447 6 жыл бұрын
Nice video sir
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :)
@vladyudashkin1471
@vladyudashkin1471 6 жыл бұрын
I am very gratefull to you for this tutorials and problem solving training! I am able to solve problems much faster if I use "use cases". But I steel wonder if they are good enough. Could you pls give me some feedback on this one: /* USE CASE * print 6 '-' for every index in the vector * on a new line print a '|' * print an index after (3 - number of digits) spaces * print 2 spaces after an index * print an index * repeat till all indexes are printed * print 6 '-' for every index in the vector * * print a number after (3 - number of digits) spaces * print 2 spaces after a number * print a number * repeat till all values are printed * print 6 '-' for every index in the vector */
@derekbanas
@derekbanas 6 жыл бұрын
I'm happy I could help :) Yes using a use case is always preferred and you did a good job with yours
@Awesomekid2283
@Awesomekid2283 6 жыл бұрын
I don't know if you've mentioned this in a future tutorial that I haven't gotten to yet, but you should briefly explain the std::cerr output stream which is used to handle outputting for error messages. I mainly use it because any text output through the std::cerr stream gets printed in red text so I can see it really clearly. One of the problems, however, is that text doesn't get printed in order when you're outputting to both cout and cerr and sometimes error messages or regular text will print in a different order than how they were coded. I don't know, I just know it exists for error messages and you would probably be able to teach me something about the cerr stream as it's only real purpose for my small c++ coding needs is to change the color of the text, which only happens in my specific IDE.
@derekbanas
@derekbanas 6 жыл бұрын
Thank you for sharing :)
@Shpendulum
@Shpendulum 6 жыл бұрын
Nicely done, man! There's a quite amazing feature existing in many programming languages including Cpp - default function parameters. Can you cover it as well?
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) Yes I covered that in this tutorial kzbin.info/www/bejne/baGvnZecj9qhgKs
@Shpendulum
@Shpendulum 6 жыл бұрын
I've just re-watched part 3 and didn't notice you covering it.
@pater429
@pater429 6 жыл бұрын
Can u make a static Globals class tutorial? attached to any of these examples? i know how to in C# but not in C++ pretty important to me that will prob be used in any project i make.
@derekbanas
@derekbanas 6 жыл бұрын
That's coming very soon
@noeflores-ramirez7998
@noeflores-ramirez7998 6 жыл бұрын
Does anyone know why would Visual Studio Code not let me input my age in the birthday code from C++ Tutorial 2? The program runs but I cant enter any number. It does not stop running either, I have to right click on the output window and stop code run. Thank you.
@derekbanas
@derekbanas 6 жыл бұрын
VSC doesn't except direct input
@hyphenpointhyphen
@hyphenpointhyphen 6 жыл бұрын
The = in >= index comparison/switch isn't necessary, just nitpicking
@LadolMark
@LadolMark 5 жыл бұрын
GOOD
@derekbanas
@derekbanas 5 жыл бұрын
Thank you very much :)
@exodus8814
@exodus8814 6 жыл бұрын
Hello Derek :) Very good video thanks for the hard work. C++ is just awesome, can't wait for OOP, GUIs and Graphics programming :) Oh and just a question. Why smart people don't like to do web development? Don't you think so? You don't seem to like web development that much. Keep up the good content :)
@derekbanas
@derekbanas 6 жыл бұрын
Thank you Exodus I'm glad you liked it :) I do web development sort of as my main job, but because I have done it for so long I don't have to think very much because I have my tool set. I think many people get irritated by web development if they are using frameworks that have numerous callback nightmares and modules that break for unknown reasons. As I get older I'm most excited about doing completely different things. I just started learning Japanese and I love that. It feels like I'm traveling to another planet through a Star Gate.
@androandro7179
@androandro7179 6 жыл бұрын
Derek Banas that is amazing ! Many years back I studied Japanese for 6 months with a Japanese teacher and it was awesome ! Are you learning it by yourself or with a teacher? And why you chose Japanese in particular? I love learning languages so much :D
@alexanderthegreat5352
@alexanderthegreat5352 6 жыл бұрын
Since you're the most prolific language expert there is, do you know of a language where I can have as big an integer as I want with as much numbers after the floating point, and be able to perform simple arithmetic on them ( + , -, * , / ) ? love your tutorials btw
@derekbanas
@derekbanas 6 жыл бұрын
Thanks for the compliment, but I'm nothing special. Check out gm_float www.boost.org/doc/libs/1_55_0/libs/multiprecision/doc/html/boost_multiprecision/tut/floats/gmp_float.html
@Kalumbatsch
@Kalumbatsch 6 жыл бұрын
So as usual, the answer is yes and it's C++. There may be others. :D
@zulumopuku5370
@zulumopuku5370 6 жыл бұрын
Mr.DEREK....Could u please cover the N-QUEENS problem , in your next video please ? Great problem with lots of trick. Use both iterative and recursive approach. PLEASE!
@derekbanas
@derekbanas 6 жыл бұрын
I'll cover algorithms and classic problems soon
@zulumopuku5370
@zulumopuku5370 6 жыл бұрын
do a poll on which problems folks wanna solved. List them or let me list if u don't mind.
@SongSeeker7
@SongSeeker7 6 жыл бұрын
I didn't think this would work but I tried with function overloading: // A B C(A+B) i //------------------- // 1 + 0 = 1 0 // 0 + 1 = 1 1 // 1 + 1 = 2 2 // 1 + 2 = 3 3 int Fib(int a, int b, int i) { if(i == 0) return a + b; return Fib(b, a + b, --i); } int Fib(int i) { Fib(1, 0, i); }
@derekbanas
@derekbanas 6 жыл бұрын
Thank you for sharing :)
@KreativFly
@KreativFly 6 жыл бұрын
❤ leave a heart
@derekbanas
@derekbanas 6 жыл бұрын
@KreativFly
@KreativFly 6 жыл бұрын
Tnku
@libanabdi5337
@libanabdi5337 6 жыл бұрын
Thnks so much sir so excited this video i was watching till end appreciated sir
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :)
@sirturnables
@sirturnables 5 жыл бұрын
I've only got 1 heart. I don't wanna miss these tutorials!!
@ManoloEsparza
@ManoloEsparza 6 жыл бұрын
are you going to teach memory management?
@derekbanas
@derekbanas 6 жыл бұрын
Yes
@24.buivanha58
@24.buivanha58 4 жыл бұрын
(max + 1) - min ?? I don't understand it. Who can heip me ??? PLEASE !!
@tkdevlop
@tkdevlop 6 жыл бұрын
Does it cover memoization?
@derekbanas
@derekbanas 6 жыл бұрын
I'm not a big believer in memorization with programming. The goal isn't to learn a language, but instead to learn how to solve problems with a language. I think you'll benefit best by referring the the cheat sheets I provide to get better at problem solving. Naturally through practice you'll learn what you need most
@tkdevlop
@tkdevlop 6 жыл бұрын
Derek Banas thanks for the advice I definitely will go through the cheatsheet
@andrewman178
@andrewman178 6 жыл бұрын
Hey Derek, I think he meant "memoization", the process of storing results of a computation to avoid doing the same calculations multiple times. It's an important part of dynamic programming algorithms
@derekbanas
@derekbanas 6 жыл бұрын
Whoops I was answering while mobile. Sure
@WardForFun
@WardForFun 6 жыл бұрын
Heyyyyyy
@derekbanas
@derekbanas 6 жыл бұрын
Hey :)
@lucasmcnamee3658
@lucasmcnamee3658 6 жыл бұрын
Lol bubblesort 😂😂😂😂😂
@alexjohnson5677
@alexjohnson5677 5 жыл бұрын
...as we SORT. IT.
@Alphabet_-_
@Alphabet_-_ 4 жыл бұрын
C++ Tutorial 9 : Lambda Expressions
25:21
Derek Banas
Рет қаралды 56 М.
5 Simple Steps for Solving Any Recursive Problem
21:03
Reducible
Рет қаралды 1,2 МЛН
World’s Largest Jello Pool
01:00
Mark Rober
Рет қаралды 112 МЛН
Jumping off balcony pulls her tooth! 🫣🦷
01:00
Justin Flom
Рет қаралды 28 МЛН
Каха заблудился в горах
00:57
К-Media
Рет қаралды 10 МЛН
C++ Tutorial 13 : Advanced Functions
18:27
Derek Banas
Рет қаралды 67 М.
Stop, Intel’s Already Dead!
13:47
Linus Tech Tips
Рет қаралды 206 М.
Towers of Hanoi: A Complete Recursive Visualization
21:13
Reducible
Рет қаралды 453 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 779 М.
C++ Tutorial 11 : Polymorphism
18:48
Derek Banas
Рет қаралды 75 М.
C++ Tutorial 18 : Associative Containers & Container Adapters
21:06
JPEG is Dying - And that's a bad thing
8:09
2kliksphilip
Рет қаралды 128 М.
Intro to Competitive Programming
11:41
Junferno
Рет қаралды 769 М.