So let's start with the what
and there I want to start with algorithm,
an algorithm is not that hard to understand.
Often in programming, you have a certain problem where you have some inputs and you want to get to a
certain output.
So let's say you have an array of numbers as an input, 2, 1, 3 in this case
and now let's say our goal here for a given problem, for the application we're writing, for a part of
that application is to find the minimum number in that array,
so in this scenario here, that would be the number one, we want to find that minimum number.
Now how do we get there? Which code do we need to write to get the minimum number out of this array of
numbers?
That is the algorithm, the sequence of steps we need there to derive this desired output for the given
input,
so for the algorithm we expect an input of a certain format and that format should always be the same
and we know what we want to get as an output,
so the minimum number in this case and then it's up to us to come up with a number of steps that help
us get there, that help us find a solution here.
That is what we would call an algorithm,
that sequence of steps that gives us for a given input a certain desired output.
And here we also see a data structure in action by the way, this array is a data structure,
of course one that is built into Javascript and built into most programming languages actually
but still it is a data structure,
it's a piece of data which also follows certain rules,
in the case of an array, an ordered list of data where every item has an index and we can work with that
data structure to solve a certain problem.
So here we see both important concepts on one simple slide, the data structure is something like an array
or an object or also maps and sets and the algorithm is a sequence of steps to solve a problem,
that is what this module is about in the end.
Now why would you care about this?
Well if you're working on more complex projects or more complex programs, you might need more sophisticated
data storage solutions or computation logic to solve certain problems,
so you simply need to solve certain problems all the time in programming.
If you're working on something, no matter how complex it is, you typically have certain problems you need
to solve to make sure that your program does what it should do,
so to make sure that your application as a whole behaves correctly and that involves a ton of simple
problems where you might not need to think much about it but even such simple problems would technically
be algorithms of course but you might also have some more complex issues, more complex tasks you need
to solve and in order to solve them, you need to know how to think logically, you need to be able to solve
problems as a programmer and understanding algorithms and how to derive them and how to compare different
solutions against each other,
that is therefore a crucial thing
as a developer. You need to be able to do that so that you can solve any problem and you can write good
code and in the end also, get hired because being able to solve problems when being provided with them
in an interview is something recruiters are looking for. Often in a job interview, you will be presented
with a certain problem,
so with some input data and a desired output and you need to describe and derive how to get there,
so you need to build and describe an algorithm whilst you're in a job interview.
That is a common task and even if you wouldn't care about the other parts, though you really should try
to become a problem solver
but even if you wouldn't care about that, even if you just want to ace job interviews, you need to understand
this algorithm thing and how to derive your own algorithms and think about all of that.
So this is what this module is about and why you should care
and with that I'd say let's dive right in and let's build our first own algorithm, maybe this algorithm
here so that we get a feeling for how that works and which steps it involves.