DATA STRUCTURES AND ALGORITHMS
We use the Big O notation to describe the performance of an algorithm. This helps us determine if a
given algorithm is scalable or not which basically means is this algorithm going to scale well as the input
grows really large. Just because your code executes quickly on your computer does n't mean it 's gon na
perform well when you give it a large data set. Using the Big O notation to describe the performance of
our algorithms we 're going to look at code snippets and use it to describe performance of algorithms.
Over the next few videos we ''re going to talk about how scalable an algorithm is and finally knowing Big
L will make you a better developer or software engineer. The algorithm is the algorithm that we use for
printing all combinations of items in an array. here we 're using a traditional for loop we could also use a
for each loop for example for int number in numbers we could simply print the number we're still
iterating over all the items in this array. The run time complexity of this method is o of 1 plus n plus 1
which we can simplify to or of 2 plus n however when using the Big O notation we drop this constant
because they do n't really matter.
An algorithm that runs in quadratic time is more efficient and more scalable than a linear algorithm. As
our input grows larger and larger algorithms that run in O of N squared get slower and slower.
Algorithms that run into a linear search are more efficient than those that run through linear time.
Algorithm that runs through an array of sorted numbers from 1 to 10 can be more efficient. An
algorithm with logarithmic time is more scalable than one with linear time. An algorithm that runs in
exponential time is not scalable at all it will become very slow very soon again I can not show you an
example of this in code now because it's a bit too complex to show it in code. The run time of this
algorithm increases linearly and in direct proportion with the size of our array. Marcia explains how we
can use the Big O notation to describe the runtime complexity of our algorithms in an ideal world we
want our algorithms to be super fast and scalable and take minimum amount of memory but
unfortunately that hardly if ever happens it 's like asking for a Ferrari for ten dollars it just does n't
happen most of the time we have to do a trade-off between saving time and saving space. Marcia says
this video is actually part of my ultimate data structures and algorithms course the complete course is
13 hours long.
I highly encourage you to take this course and learn all the essential data structures and algorithms from
scratch. divided it into three parts so you can take and complete each part easily. The course is packed
with almost 100 interview questions that get asked by companies like Google Microsoft and Amazon. Ar
arrays are static which means when we allocate them we should specify their size and this size can not
change later on. To add another item we'll have to resize the array which means we should allocate a
larger array and then copy all the items in the old array into the new array this operation can be costly
can you guess the runtime complexity of this operation? IntelliJ imports an array of 3 items in Java dot
util so we press ENTER and use the dot operator and call the two string method a password array. This
method will convert it to a string and then we 'll print that string on the console no let 's run the
program one more time there you go much much better.
As we learn arrays in Java or static which means they have a fixed size and this size can not be changed
but now we 're going to do something really cool I 've created this array class which is like a dynamic
We use the Big O notation to describe the performance of an algorithm. This helps us determine if a
given algorithm is scalable or not which basically means is this algorithm going to scale well as the input
grows really large. Just because your code executes quickly on your computer does n't mean it 's gon na
perform well when you give it a large data set. Using the Big O notation to describe the performance of
our algorithms we 're going to look at code snippets and use it to describe performance of algorithms.
Over the next few videos we ''re going to talk about how scalable an algorithm is and finally knowing Big
L will make you a better developer or software engineer. The algorithm is the algorithm that we use for
printing all combinations of items in an array. here we 're using a traditional for loop we could also use a
for each loop for example for int number in numbers we could simply print the number we're still
iterating over all the items in this array. The run time complexity of this method is o of 1 plus n plus 1
which we can simplify to or of 2 plus n however when using the Big O notation we drop this constant
because they do n't really matter.
An algorithm that runs in quadratic time is more efficient and more scalable than a linear algorithm. As
our input grows larger and larger algorithms that run in O of N squared get slower and slower.
Algorithms that run into a linear search are more efficient than those that run through linear time.
Algorithm that runs through an array of sorted numbers from 1 to 10 can be more efficient. An
algorithm with logarithmic time is more scalable than one with linear time. An algorithm that runs in
exponential time is not scalable at all it will become very slow very soon again I can not show you an
example of this in code now because it's a bit too complex to show it in code. The run time of this
algorithm increases linearly and in direct proportion with the size of our array. Marcia explains how we
can use the Big O notation to describe the runtime complexity of our algorithms in an ideal world we
want our algorithms to be super fast and scalable and take minimum amount of memory but
unfortunately that hardly if ever happens it 's like asking for a Ferrari for ten dollars it just does n't
happen most of the time we have to do a trade-off between saving time and saving space. Marcia says
this video is actually part of my ultimate data structures and algorithms course the complete course is
13 hours long.
I highly encourage you to take this course and learn all the essential data structures and algorithms from
scratch. divided it into three parts so you can take and complete each part easily. The course is packed
with almost 100 interview questions that get asked by companies like Google Microsoft and Amazon. Ar
arrays are static which means when we allocate them we should specify their size and this size can not
change later on. To add another item we'll have to resize the array which means we should allocate a
larger array and then copy all the items in the old array into the new array this operation can be costly
can you guess the runtime complexity of this operation? IntelliJ imports an array of 3 items in Java dot
util so we press ENTER and use the dot operator and call the two string method a password array. This
method will convert it to a string and then we 'll print that string on the console no let 's run the
program one more time there you go much much better.
As we learn arrays in Java or static which means they have a fixed size and this size can not be changed
but now we 're going to do something really cool I 've created this array class which is like a dynamic