Skip to playerSkip to main content
  • 21 minutes ago
Transcript
00:00Hi everyone and in this chapter we are going to talk about time and space complexity
00:04Now it is a term that we have heard many times
00:07we have done searching and sorting
00:09so we have heard this term
00:11besides recursion time and space complexity
00:13we have talked about time and space complexity
00:16so today we will understand that finally
00:18we were writing math
00:20log n
00:21n
00:22n
00:23n
00:23what does this mean?
00:26and I will say that one of the most important topics
00:29when we talk about Java
00:31you need to use any data structure or algorithm
00:34maximum interviewers
00:36if you have solved questions
00:38then we will ask what was your time complexity of code
00:41or what was your space complexity of code
00:44in fact if we know how the concept of time complexity
00:47this will help us to give online contests
00:50which we will test companies
00:51and with it
00:53and with it
00:53what are our interviews
00:55within them
00:56with it
00:56as we have time complexity
00:59our problem solving
01:00ability
01:01becomes better
01:02how it becomes better
01:04because we have written programs
01:05which are more efficient
01:07which are better
01:08as compared to other programs
01:11we know that
01:12there are different ways to solve
01:15we have time complexity
01:16and we have to pick the best way
01:18we should understand
01:20what is the time complexity
01:22and what is the space complexity
01:25and a program complexity
01:26when we are talking about time
01:28we can talk about time
01:29we are talking about between
01:30we are not exactly
01:31but with relation to
01:32that time
01:34that time
01:35is running
01:35we can know that
01:37whatever we are writing
01:38we can click on code
01:40we can say
01:40or do a command type
01:42in the terminal
01:42In the same way, our program is running.
01:45But in the computer, there is a little time.
01:49What time is it?
01:50This time is in our milliseconds.
01:52It is a very little time that we don't realize.
01:55But the real-life applications,
01:57such as Facebook,
01:58to store Facebook in its database,
02:01to load a page,
02:03there is a little time.
02:04And we want to write a program
02:06in which time is less and less.
02:08When is it less and less?
02:09Our code is such a way,
02:13that many people are using.
02:16For example, Facebook has made a website.
02:19There will be some code.
02:21Many people are trying to go on Facebook,
02:22and try to click on the link.
02:26And then, the website is working very well.
02:28Then, we will say that the code is good.
02:31Another thing is space.
02:33This is not the space.
02:35This is the space that is in the computer,
02:37in the memory form.
02:39That space should be optimized.
02:42Our program should not occupy the file-to-space,
02:44file-to-memory.
02:46Because in the computer,
02:48there are a lot of work.
02:49Our code will solve a problem in the most optimal way,
02:52without any file-to-memory.
02:55So, we will talk about the space complexity.
02:58And the other thing is our time complexity.
03:00So, we will analyze them all in detail.
03:03In this chapter,
03:04we will understand what happens.
03:06We will understand how we represent it.
03:08We will actually apply it.
03:11So, first of all,
03:13let's talk about our chapter.
03:14Order complexity analysis.
03:17What is complexity?
03:20Some people will be interested in cars.
03:23Some people will be interested in cars.
03:25Some people will be interested in books.
03:27So, it will be interested in books.
03:28I will take a example of cars.
03:30If we want to see which cars I want to buy,
03:33we will analyze many different parameters.
03:36We can see the speed of it.
03:40How many seconds is it?
03:42We can see the price of it.
03:44How much is it?
03:46How much is it?
03:46We can see the capacity of it.
03:49It is 5-seater, 6-seater, 7-seater.
03:52Or, we can see the size of it.
03:55So, these are different parameters
03:56which we can analyze on the basis
03:58that some car is good or some car is good.
04:01So, if any code is good or some good,
04:06we will analyze it.
04:08We have two parameters.
04:10The first parameter is our time complexity.
04:13The other parameter is our space complexity.
04:17This is not something.
04:18Like cars, speed, price, capacity.
04:22So, in some code, in some program,
04:25the time complexity is a parameter
04:26and space complexity is a parameter.
04:28The time complexity is good.
04:31The program will be good.
04:32The time complexity is good.
04:33The time complexity is good.
04:34The program will be good.
04:35The time complexity is bad.
04:36The program will be good.
04:38So, we have logic in this way
04:40whenever we talk about complexities.
04:42Because as humans,
04:43we like to choose that thing
04:45that is better performance-wise,
04:47that is more efficient,
04:49that is more efficient,
04:49that is the best thing
04:50that is more efficient,
04:51In the smallest amount possible.
04:53So, in the less time,
04:55in the less time,
04:56in the less space,
04:58in the less efficient,
04:59the programs,
05:00the same work we do,
05:02we like more we use.
05:05and we want to use it.