[User] Please transcribe this text

[Assistant] Just helps us give some theoretical estimations.


[User] Please transcribe this text

[Assistant] Now the reason why I have highlighted estimations is because we do not get an accurate value. Because to find out accurate value is very difficult.


[User] Please transcribe this text

[Assistant] And that's why we can only make some theoretical estimations using this algorithm analysis techniques, which overall gives us how the behavior of the algorithm will be and we'll talk about that in detail as we move ahead.


[User] Please transcribe this text

[Assistant] Also known as time complexity or volume of memory known as space complexity. So it makes sense, right? If your algorithm has 10 steps, it would take some particular amount of time. But if that step increases, let let's say it becomes 20 steps, obviously the time also will increase.


[User] Please transcribe this text

[Assistant] How much memory your algorithm is occupying in memory when it is running. So whenever you are running a program, it is occupying some memory in the RAM. So that is space complexity. So we are going to be focusing on time complexity in detail.


[User] Please transcribe this text

[Assistant] And we'll talk more, but I hope you've got a very basic idea of what is algorithm analysis. So with this idea in mind, if you want, you can take a screenshot.


[User] Please transcribe this text

[Assistant] Let's move ahead and understand why do we need algorithm analysis because that is very important. So when it comes to why do we need algorithm analysis,


[User] Please transcribe this text

[Assistant] So to make it clear, let's take an example. Let's say you're working in NASA or you're working in ISRO or SpaceX and these companies basically launch space rockets and satellites into space, right?


[User] Please transcribe this text

[Assistant] So 10 seconds is your maximum limit.


[User] Please transcribe this text

[Assistant] So that is the reason why you need to know how much amount of time your algorithm will take or at least have a rough estimate about the maximum time, right? Another example can be the ejection of airbags in a car.


[User] Please transcribe this text

[Assistant] So nowadays cars are equipped with airbags. So whenever you meet with an unfortunate accident, these airbags eject and they save


[User] Please transcribe this text

[Assistant] Now obviously there must be some algorithm which is written behind which detects that there is a crash happening or there is an impact and then it ejects those airbags on time. Now imagine if that algorithm takes more than 2 seconds. Now accidents happen in like less than 1 second, right?


[User] Please transcribe this text

[Assistant] If your airbags does not get ejected in time, a person's life might get lost. So this is a very mission critical task and hence you need to know exactly or at least have a rough estimate about the maximum time the algorithm or the program would take to execute or complete its execution.


[User] Please transcribe this text

[Assistant] So this was point number one and the point number two is even more important or even more interesting actually and that is generally there are multiple approaches or multiple methods to solve one problem statement. So algorithm analysis is performed to figure out which is a better or optimum approach out of the different options for us. For example,


[User] Please transcribe this text

[Assistant] Another example can be there are like n number of ways in which you can reverse a string. So all of them are different approaches, but they're doing the same thing. And we are also going to see an example as we move ahead in this video about an example which has two different approaches to do the same thing. Make sure you watch this video till the end. I know I'm reiterating it because it is very important.


[User] Please transcribe this text

[Assistant] And this video is probably the most important one in the data structures series. So that's why I'm constantly telling you guys to watch this video till the end.


[User] Please transcribe this text

[Assistant] So I hope you are getting that since there are multiple approaches, we need to figure out what is the best for us, right? So that's why I said better or optimum.


[User] Please transcribe this text

[Assistant] So different situations require different criterias and that's why when you have multiple choices you need to select the one that is best suitable for you. So these are two major reasons why we need to have a good algorithm analysis. So talking about


[User] Please transcribe this text

[Assistant] So the next obvious question arises, what does a better algorithm mean? Does it mean it is faster? Which means it requires less execution time and that's basically time complexity, right? So we're also going to talk about time complexity more when we go to big O notation in this video. Just hold on.


[User] Please transcribe this text

[Assistant] Now another criteria can be less memory. Is your algorithm


[User] Please transcribe this text

[Assistant] Taking up less memory compared to some other algorithm doing the same thing.


[User] Please transcribe this text

[Assistant] So that is dealing with space complexity. Now generally these first two criterias are the most focused on because those are the most important ones, especially the time. Nowadays our computer systems have lots of memory, so we don't really focus much on memory.


[User] Please transcribe this text

[Assistant] But we are more interested in reducing the time. So we want our algorithms to run very very fast. You don't want your website to wait like 10 seconds to load all the data right? You want it in seconds. Now some other things that may be considered for a better algorithm is, is the algorithm easy to read? The readability of the algorithm.


[User] Please transcribe this text

[Assistant] They are not running on Windows 7. So you can see that some programs also have software requirements. So it's not just hardware requirements.


[User] Please transcribe this text

[Assistant] Now because there are so many different criteria, there are so many different conditions, you cannot pinpoint and say that my algorithm is gonna run in exact 2 seconds. Because let's say you and I have the exact same


[User] Please transcribe this text

[Assistant] laptop, exact same specifications, all the hardware and software specifications are exactly same. However, on your system, along with your algorithm, you have 10 programs, but on my system, I don't have any other programs. So CPU is directly only gonna focus on my program and my program will execute faster.


[User] Please transcribe this text

[Assistant] So you can see just by addition of extra programs in your


[User] Please transcribe this text

[Assistant] System, even though everything else was same, still my algorithm ran faster, right? So you can see there are so many different criterias.


[User] Please transcribe this text

[Assistant] So that's why algorithm analysis does not give you accurate values.


[User] Please transcribe this text

[Assistant] Then what is asymptotic algorithm analysis? Now we've understood overall what is algorithm analysis. Basically studying the time and space complexity, how much time the algorithm takes, how much space the algorithm takes.


[User] Please transcribe this text

[Assistant] So we have a category of analysis which is known as asymptotic analysis. So let's take a look at that. So when you're studying data structures and time and space complexity and this algorithm analysis, you must have come across this asymptotic algorithm analysis concept.


[User] Please transcribe this text

[Assistant] Over here you can see in simple words what it is doing is it is used to mathematically calculate the running time of any operation inside an algorithm. That's the easy way to put it. So what happens is when you are measuring


[User] Please transcribe this text

[Assistant] So, what we are doing is we are using this technique to define the mathematical boundaries. When I say boundaries it means the upper and lower limit.


[User] Please transcribe this text

[Assistant] So runtime is basically the time required for an algorithm to execute. And now you can see that asymptotic algorithm analysis is more dealing with the time complexity. So you can see point over here. Asymptotic algorithm analysis is used to estimate the time complexity function for arbitrarily large input.


[User] Please transcribe this text

[Assistant] So when you're talking about algorithm, if everything else is kept constant, when I say everything else, it means the PC, the hardware, the, the CPU, the RAM, whatever hardware things you're using, whatever software you're using, if all those things are constant, which in usual cases are constant in an environment,


[User] Please transcribe this text

[Assistant] So when I'm talking about average, best and worst case, it means the time, okay. So the best time in which the algorithm can execute, that is how fast can an algorithm execute.


[User] Please transcribe this text

[Assistant] How slow can an algorithm execute and what is the average case? Okay.


[User] Please transcribe this text

[Assistant] So ultimately, time complexity is a computational way, basically a mathematical way to show how


[User] Please transcribe this text

[Assistant] Now I know this was a lot of theory, right? So let's actually take some example. Because then we can easily jump on to the next big topic that is Big O notation.


[User] Please transcribe this text

[Assistant] Okay, so as you can see on the screen, I have switched to our digital blackboard and now we are actually gonna take a practical example to understand asymptotic algorithm analysis and understand what is Big O notation. Okay.


[User] Please transcribe this text

[Assistant] So what is the problem statement over here? Now we've been given a problem statement over here, which is write algorithm slash program, which we are kind of assuming one and the same thing. So essentially what is algorithm? It is a step by step process. And when we convert that algorithm into programming code, we call it program, right? So we are assuming it as one and the same thing.


[User] Please transcribe this text

[Assistant] So what we have to do is we have to write an algorithm or program to find the sum of n numbers. So n numbers would be ranging from 0 to n and this n is supposed to be accepted from the user. So we will take n from the user. Let's say user enters 3.


[User] Please transcribe this text

[Assistant] So it would be 1 plus 2 plus 3 and the total would be 6. So you have to print out 6. Okay. So that is the problem statement.


[User] Please transcribe this text

[Assistant] If the user enters 5, it would be 1 plus 2 plus 3 plus 4 plus 5 and then we have to print out the total.


[User] Please transcribe this text

[Assistant] So here's algorithm number one or method number one. You create a function and this is not exactly any kind of programming code. It is kind of like a pseudo code, but it's pretty understandable. You're creating a function.


[User] Please transcribe this text

[Assistant] You're naming the function as sum of numbers and you're passing arguments as n. So this is something that the user will enter. First step is you declare a variable sum, assign zero to it.


[User] Please transcribe this text

[Assistant] Second step is a for loop. Now you run a loop from 0 to n or you can say 1 to n also and then you say sum is equal to sum plus i and all the values stored in the sum variable itself and ultimately at step number 4 you print the sum.


[User] Please transcribe this text

[Assistant] So if you enter 3, your for loop will run from 0 to 3. That is 4 times. Okay. You can also run it from 1 to 3. It would run one, one time less, but that's okay. What will happen? Initially sum would be 0. So it would be 0 plus i is 0 for the first time.


[User] Please transcribe this text

[Assistant] So zero will be stored. So next time it would be sum which is zero plus i will become one. Zero plus one. So one will be stored over here.


[User] Please transcribe this text

[Assistant] Next iteration, it would be 1+, i will now become 2, so 3 will be stored over here. For the next iteration, 0 will become 3.


[User] Please transcribe this text

[Assistant] So it will be 3 plus 3, so 6 will be stored over here. And now,


[User] Please transcribe this text

[Assistant] The loop will exit because I will become 4. We are only interested in running from 0 to 3. So after this we will print the value of 6. So basic enough. Now what we'll do is we'll assign some time for individual instructions.


[User] Please transcribe this text

[Assistant] So you can see this algorithm is nothing but uh, step by step instructions. So we have instruction number one, two, three.


[User] Please transcribe this text

[Assistant] So let's assume this first instruction is taking 1 microsecond. Now we are just making some assumptions. Obviously every instruction is gonna take some time, but it is not gonna be 1 microsecond. I'm just making an assumption, okay? But obviously every instruction is gonna take some time.


[User] Please transcribe this text

[Assistant] Let's see the second instruction is the initialization of for loop. It will also take some time. We'll again assume it as one microsecond.


[User] Please transcribe this text

[Assistant] Now this third step is totally dependent upon this n value, right, because


[User] Please transcribe this text

[Assistant] Whatever value we enter over here, let's say we enter 5. So this for loop will run for 5 times. If it starts from 1, let's assume it is starting from 1. It will, it will execute for 5 times from 1 to 5. If you enter 6, it will run for 6 times.


[User] Please transcribe this text

[Assistant] For this, let's say one step, running it for one iteration takes one second, so for n iterations it will take n microseconds, right.


[User] Please transcribe this text

[Assistant] And then again, this last step is just printing the sum out. Let's assume it takes 1 microsecond.


[User] Please transcribe this text

[Assistant] So after assuming all these values, we can conclude that the time required by this algorithm is something like n plus 1, 2 and 3. 3 microseconds, right? And this 3 microseconds is always gonna be constant. Only this n is gonna be a variable.


[User] Please transcribe this text

[Assistant] So depending upon this n, the time will change, right? So you can make a clear observation over here and you can make a graph of this. So how will the graph look like?


[User] Please transcribe this text

[Assistant] So as you can see over here, this is how the graph would look like for this algorithm 1. So what is this graph? On the x-axis, we have the n value, which is whatever value entered by the user. So 1k is basically 1000, okay? So I'm assuming it for large numbers. If the user enters 1000 over here,


[User] Please transcribe this text

[Assistant] Now again, I'm telling these are just estimations. These are not actual values, but this is something that would happen, right? In reality also, something


[User] Please transcribe this text

[Assistant] Like this only will happen. So over here you can see that for 1k value of n,


[User] Please transcribe this text

[Assistant] This y-axis is basically the time in microseconds. Okay, so this is in microseconds. For 1k, it is taking 1 microsecond. So we are assuming it is taking 1 microsecond when you enter 1000.


[User] Please transcribe this text

[Assistant] When you enter 2000 as sum of 2000 numbers, it is approximately taking 2 microseconds. It is a little above 2 microseconds because obviously we cannot have exact values. We've just talked about that and you cannot never estimate exact values.


[User] Please transcribe this text

[Assistant] For 3k, if you enter 3000, that is sum of 3000 numbers, it is somewhere taking 3 microseconds. And you can see that this trend is going in this direction.


[User] Please transcribe this text

[Assistant] So this basically is called a linear behavior.


[User] Please transcribe this text

[Assistant] So when I say linear behavior, it means that as the size of the input increases, obviously this n is representing the


[User] Please transcribe this text

[Assistant] The time complexity you can say is linear. Okay?


[User] Please transcribe this text

[Assistant] So that's why I've said linear. Let's take the same problem statement and let's see one more algorithm for the same problem statement.


[User] Please transcribe this text

[Assistant] Okay, so as you can see on the screen, this is algorithm number two and it is surprisingly very small. So you're wondering, okay, is it doing the same thing?


[User] Please transcribe this text

[Assistant] So again the same function sum of numbers it is taking n from the user. However, in step number one, we are declaring a variable sum and we are saying it is equal to n star n plus one the whole divided by two. So where did I get this? Now, this is a mathematical formula for calculating sum of n numbers. So for those who don't know,


[User] Please transcribe this text

[Assistant] It's a mathematical formula. You can Google it out and that is the reason why you have mathematics in computer science and information technology oriented domains also. So whenever you're going out with a course of IT or computer science, students generally complain about why do we have mathematics. It is for this reason. Okay.


[User] Please transcribe this text

[Assistant] This step is only gonna take around 2 microseconds. I'm not saying it is gonna take exactly 2 microseconds, but


[User] Please transcribe this text

[Assistant] So you can see even when the n number is increasing, the total time over here you can say that t is equal to this 2 seconds or 2 microseconds plus this 3 microseconds or we can just consider it as 1 microsecond because printing does not take a lot of time. So 2 plus 1 is


[User] Please transcribe this text

[Assistant] So this is some weird behavior, right? This is not the same behavior as algorithm 1. In algorithm 1, as the size of the n value was increasing, as this n value is increasing,


[User] Please transcribe this text

[Assistant] The time is also increasing. However, here no matter what the value you enter, your time is approximately gonna be the same.


[User] Please transcribe this text

[Assistant] So how does the graph of this algorithm look like? So this is how the graph for this algorithm 2 looks like. Now you can see it is a straight line, however it is not an increasing line. So no matter what the size of n, so you can see n is over here 1k. So n is 1000. When n is 1000, it is taking 2 microseconds.


[User] Please transcribe this text

[Assistant] When n is 2k, it is still taking 2 microseconds. When n is 3k,


[User] Please transcribe this text

[Assistant] It is still taking 2 microseconds where in NS4K it is taking slightly greater than 2 microseconds because obviously it is not gonna be accurate values. But you can see overall the time is not increasing.


[User] Please transcribe this text

[Assistant] It is not increasing, it is constant. So this behavior is known as constant time behavior. Okay. So when you're doing analysis of algorithm 1, we are getting linear behavior. But for the same problem statement, we are typing or writing algorithm 2 and it is giving us constant time behavior. Now just by observing it,


[User] Please transcribe this text

[Assistant] You can say that obviously algorithm 2 is much more efficient than algorithm 1. Now if you're still confused or if you're still wondering does it actually give the same value, let's actually jump to the code.


[User] Please transcribe this text

[Assistant] Let's actually open up Dave C++ and type a C++ program.


[User] Please transcribe this text

[Assistant] To execute these two algorithms and I will show you live what happens, okay?


[User] Please transcribe this text

[Assistant] Okay, so as you can see on the screen, I have already typed in the code because the algorithm was pretty basic. So this is...


[User] Please transcribe this text

[Assistant] The hash include iostream and the basic boilerplate that you have to type when you're typing C++ programs. So this is function number one or you can say this is algorithm one. Let me just type it and this is algorithm two. So I've typed in two different functions which are those two different algorithms that we just saw. If you want, I'll put it on the right hand side on the screen. You can see an


[User] Please transcribe this text

[Assistant] Correlate with the algorithm steps as well as the program steps. They are the same. This is algorithm two and in the int main you can see I'm just declaring a double


[User] Please transcribe this text

[Assistant] We are asking the user to enter that number. We're taking it from the user cin and we are passing it into either of these two functions. So function number one is sum of numbers one. Function number two is sum of numbers two.


[User] Please transcribe this text

[Assistant] Basically, algorithm 1 and algorithm 2. Okay. So, let's first call algorithm 1. Okay. Sum of numbers 1. Save this.


[User] Please transcribe this text

[Assistant] I've already written it properly. If you want this entire code, I will share in the video description, but I would recommend that you type it. But now it is asking enter a number till which you want to find the sum. So let's enter a very large number. Let me go to the notepad.


[User] Please transcribe this text

[Assistant] And type in some large number. This is 100, 1000, 10,000, lakh, 10 lakh crore. Right? So this is 1 crore. Let's copy this and paste it over here. If I hit enter, we are directly getting the sum very easily because we still need to put a very large number. Okay?


[User] Please transcribe this text

[Assistant] So this is 1 crore, let's enter 10 crore, 100 crores. Let's copy this and let's try to again actually execute this and enter a large number. Okay, enter 100 crores.


[User] Please transcribe this text

[Assistant] So I'm putting 100 crores as the number because it is a very large number and it should take some large amount of time.


[User] Please transcribe this text

[Assistant] Paste, so this is 10 crores. If I hit enter and start the countdown, I'm gonna hit enter and start the countdown. 1, 2, 3.


[User] Please transcribe this text

[Assistant] And you can see it took around 8 seconds. So this is 100 crores, okay. Let's close this. Now let's come to our code.


[User] Please transcribe this text

[Assistant] And so this was algorithm 1, which was linear complexity, which was


[User] Please transcribe this text

[Assistant] First compile it. Okay, make sure you compile it because otherwise the previous code will run. So I'm going to hit compile. It's compiled successfully close this and now I'm going to say run. So now we are basically running method number two.


[User] Please transcribe this text

[Assistant] So we'll also see the output in method number two. This output will be printed. Earlier it was method number one.


[User] Please transcribe this text

[Assistant] Let's come back to this notepad. Let's copy this number, which is more than 100 crores. Copy. Come over here. Just paste it.


[User] Please transcribe this text

[Assistant] If I hit enter and start the countdown, actually it will give us the answer immediately. It will not take 8 seconds. It will not take 10 seconds because it is constant time.


[User] Please transcribe this text

[Assistant] It will not get affected by the size of the input. Let me just show you.


[User] Please transcribe this text

[Assistant] Like, I'm now hitting enter and there you go, directly I got the answer. You can see method two sum of


[User] Please transcribe this text

[Assistant] And you are also getting the answer in a large weird number. Don't go on the number, but you can see that when I hit enter, it literally printed out the


[User] Please transcribe this text

[Assistant] Output instantly, we did not even have to wait for 2 seconds, but for algorithm 1 we had to wait for 8 seconds.


[User] Please transcribe this text

[Assistant] So you can see that this algorithm 2, which is of constant time behavior was much much faster than algorithm 1 for larger amount of inputs. So if you had to make a choice between the two, you would obviously go with algorithm number 2.


[User] Please transcribe this text

[Assistant] It's not showing some random values. You guys can put in some small numbers to see the actual output. Okay? That is the sum of n integers.


[User] Please transcribe this text

[Assistant] Okay, so now this actually brings us to the very last topic, which is one of the most important one of this entire video, which is the Big O notation. So what is this Big O notation? Now we just saw two different types of time complexities, which was linear time and constant time. Now similar to that,


[User] Please transcribe this text

[Assistant] We have some more time complexities depending upon the behavior. So we have constant time which we just saw.


[User] Please transcribe this text

[Assistant] Okay, so instead of telling this algorithm is linear time or this algorithm behavior is quadratic or this algorithm's behavior is constant time, we say big O of n for linear, okay or big O of n square


[User] Please transcribe this text

[Assistant] So, bigot notation is nothing but the formal or mathematical way


[User] Please transcribe this text

[Assistant] So what it does is it measures the worst case time complexity or the longest amount of time an algorithm can possibly take to complete.


[User] Please transcribe this text

[Assistant] So now you are wondering, okay, so if Big Oon rotation is measuring the longest amount of time, what is measuring the shortest amount of time?


[User] Please transcribe this text

[Assistant] So we have other two notations also which is omega and theta notations, but they are not as relevant as big O notation because whenever you are running an algorithm,


[User] Please transcribe this text

[Assistant] How much maximum amount of time will it take to execute? Because that is more critical.


[User] Please transcribe this text

[Assistant] Important and relevant. Not to say that others are not important, but Big O notation is more important. So the way some asymptotic notations are is for constant time we say O of 1.


[User] Please transcribe this text

[Assistant] Okay, you can see O of 1 or big O of 1, that's how you say it. For linear you say O of n, which means that


[User] Please transcribe this text

[Assistant] The time might be 4, but if n becomes 3, the time taken would be 3 square, which is 9. If it becomes 4, so n is the input size, this is n.


[User] Please transcribe this text

[Assistant] And this is the time. So if it becomes 4, 4 square will become 16. So on a graph, if this is n, and if this is basically the time, so the graph would look something like this. Okay? This would be 2. This would be 2 somewhere over here. Then we have 3. We have 3 somewhere over here. Then we'll have 4. We'll have 4 over here. And the time is gonna be 16. This is gonna be 9.


[User] Please transcribe this text

[Assistant] And you can see there is an exponential growth over here. It's not linear. It's not like this. It's not a line. It's a curve. Okay? This is quadratic growth.


[User] Please transcribe this text

[Assistant] Okay, so as you can see, we have this algorithm 1 which we just saw previously, which was having a linear time.


[User] Please transcribe this text

[Assistant] Coming to this conclusion that algorithm 1 is O of n.


[User] Please transcribe this text

[Assistant] So let's actually go step by step. So in the algorithm analysis, we know that this step is taking 1 microsecond. So we are making assumptions, it can be 2, it can be 3, but it is gonna be some value itself which is not gonna change, right?


[User] Please transcribe this text

[Assistant] So analyzing this totally the time let me use another color t is equal to


[User] Please transcribe this text

[Assistant] So these are the two steps when you want to find out Big O notation by yourself.


[User] Please transcribe this text

[Assistant] In a practical sense. So it's not exactly how a systematic way goes when it comes to calculate big O notation. That can be a separate tutorial itself. You can Google it out also, but


[User] Please transcribe this text

[Assistant] In a practical sense, you can also do it yourself just by studying the entire algorithm and the two major steps are, first thing is we have to find out the fastest growing variable term.


[User] Please transcribe this text

[Assistant] Then we have a plus in between and this is the second term.


[User] Please transcribe this text

[Assistant] Now looking at this, you can see that this 3 microseconds will never change. Whatever the n value, this 3 microseconds is because


[User] Please transcribe this text

[Assistant] Step number 1, 2 and 4 always takes 1 microsecond. So this can be considered as a constant, right? So I'm gonna write constant over here. However, if you see


[User] Please transcribe this text

[Assistant] So this is the fastest and this is actually the only variable, right? So we found the variable.


[User] Please transcribe this text

[Assistant] So what is step number two? Step number two is we have to eliminate the coefficients and the constant terms. So over here, the only constant term is this, which is the extra time required for these extra steps, but they will always take some constant time. So that is the constant term. So what is this coefficient? So the coefficient can be some value attached with this n.


[User] Please transcribe this text

[Assistant] Okay, right now we don't have any value, but it could be something like t is equal to 2n plus 3 microsecond.


[User] Please transcribe this text

[Assistant] Is essentially a coefficient, okay. It's a coefficient. This n is a variable and this component is a constant. So what we have to do, we have to find the fastest growing variable which is n.


[User] Please transcribe this text

[Assistant] So we found that and we have to eliminate all the other coefficients and constants. So ultimately the time complexity t will be equal to


[User] Please transcribe this text

[Assistant] N, right? And it is also denoted as O of N or O of capital N or whatever the value over here. What is more important is the term that we are left with. We took capital N so it would be O of capital N.


[User] Please transcribe this text

[Assistant] Okay, so this is the time complexity, which is O of n. So this is how you found out the Big O notation for this algorithm, which is basically having a linear time behavior, which is represented by O of n.


[User] Please transcribe this text

[Assistant] Now quick note, these constants and these different coefficients can be added in any algorithm because as I mentioned,


[User] Please transcribe this text

[Assistant] Whenever an algorithm is running in your system, it is not just dependent upon the number of steps. It is also dependent upon how fast is your processor, how fast is your RAM, what is the size of your RAM.


[User] Please transcribe this text

[Assistant] Is your processor 7th gen? Is your processor 9th gen? Right? What is the CPU speed of your processor? So all those things basically are these coefficients and constants which get added to this entire equation and then ultimately we just have to figure them out and


[User] Please transcribe this text

[Assistant] And so on and so forth. So in that case, which is the fastest growing variable, obviously n square will grow faster than 2n when the n is very large, right? Because we are doing asymptotic analysis when the input size is very large. We want the worst case scenario. So in that case, we have to eliminate this part.


[User] Please transcribe this text

[Assistant] So, I hope you are understanding how we calculate Big O notation by ourselves in a practical sense.


[User] Please transcribe this text

[Assistant] Big O notation is nothing but a formal or mathematical way to express the upper limit of an algorithm's running time.


[User] Please transcribe this text

[Assistant] And lots more are coming soon based on programming and information technology and computer science tutorials. So that's it for this video guys. See you in the next one. Peace!


[User] Please transcribe this text

[Assistant] Wow. This is the best day of my life.


[User] Please transcribe this text

[Assistant] You know, when I found out I was nominated for Best Actor, I really felt like I was walking on air, but today, to actually win this award, I just, I feel like I'm dreaming. I can't believe this is happening. I want to take this moment now to thank the Academy, to thank my family and my friends, to thank the United States of America for providing me with the American dream, and of course, Tomato English. Thank you.


[User] Please transcribe this text

[Assistant] You know what? We still have uh, two hours until the after party. Why don't I give you a little tour of Hollywood Boulevard? What do you think?


[User] Please transcribe this text

[Assistant] Moonlight won best picture in 2016, but there was a controversy because


[User] Please transcribe this text

[Assistant] At the Academy Awards they announced La La Land. And this happened because I think the winner of Best Actress was in La La Land and they somehow got the envelopes swapped around for Best Picture.


[User] Please transcribe this text

[Assistant] You just had one job and you screw it up. How do you mess that up? But anyway, Moonlight is up there and not La La Land.


[User] Please transcribe this text

[Assistant] Well of course. I mean, as an insider in the industry, who better to show you around than me, right? So come on.


[User] Please transcribe this text

[Assistant] And I believe Donald Trump also has his name on one of these stars. So now, I want to find the Trump star, because there's actually a pretty interesting story about this star.


[User] Please transcribe this text

[Assistant] I know. She says that her award is bigger than mine. Check it out!


[User] Please transcribe this text

[Assistant] Hers is bigger than mine. But you think I'm insecure about that? No. I'm fine with mine the way it is. Doesn't need to be any bigger or longer.


[User] Please transcribe this text

[Assistant] And do you know why he got his name here on the Hollywood Boulevard? Was it A, because he's super famous? B,


[User] Please transcribe this text

[Assistant] The person who leases this house out is notorious for not leasing it out to one particular type of tenant. Do you know what type of tenant that is?


[User] Please transcribe this text

[Assistant] Okay, I'll give you, I'll give you a few options.


[User] Please transcribe this text

[Assistant] B, politicians, or C, military personnel.


[User] Please transcribe this text

[Assistant] Well, true. Not everyone hates politicians, but... Actually, it's actors! Why?


[User] Please transcribe this text

[Assistant] Well, you know, for the most part, a lot of people come to Hollywood to become famous, to pursue a career in acting, but actors really don't make a lot of money. It's really difficult to make ends meet as an actor. So, you see a lot of people out here trying to become famous and do their thing. For example,


[User] Please transcribe this text

[Assistant] Guys like Brad Pitt came out here and they were doing the chicken dance in these chicken suits. And people like Megan Fox came out here and she was dressed like a banana. Right? Let that sink in for a moment. These are really famous people that came out here and they were willing to stand on the street and dress like bananas.


[User] Please transcribe this text

[Assistant] Well folks, we're just about to go into the after party. It's about time for the party to start. I gotta go for this party. Come on.


[User] Please transcribe this text

[Assistant] I was nominated for best actor. I want to take this moment now to thank the Academy. How do you mess that up? Who better to show you around than me, right? I'm fine with mine the way it is. You name it. Let that sink in for a moment. It's really difficult to make ends meet as an actor.


[User] Please transcribe this text

[Assistant] I hope they can somehow make their way to the final tribal council, but if not, I'm sure they'll be seeing me soon in Duryvilla.


[User] Please transcribe this text

[Assistant] Yes, so Sian is the one that didn't vote with me tonight, which is why I'm evicted. I was working it, like I got to the new tribe, and I had three of my enemies on there, and instantly I was like, got my people, told them what they needed to hear.


[User] Please transcribe this text

[Assistant] I doggy paddled for two hours and five minutes. With one hand, with one hand.


[User] Please transcribe this text

[Assistant] No, we're not starting, a mullet, rat nest at the back, professional at the back.


[User] Please transcribe this text

[Assistant] After you got evicted we had like a spa reward and I literally like held on this thing for 40 minutes and I was like, Dave, like, I need to wash my hair. Anyway, the bastard won.


[User] Please transcribe this text

[Assistant] I wanted to be friends with like all like the villainy type people.


[User] Please transcribe this text

[Assistant] Survival has definitely given me a greater appreciation for my silk pillowcase. I'm never taking that thing for granted ever again. They don't absorb your face creams and they don't give you wrinkles.


[User] Please transcribe this text

[Assistant] Yeah, I know. Aw heaps. I mean, she's so determined, she's so courageous. She's got it all, really.


[User] Please transcribe this text

[Assistant] That is the biggest regret of my game. And my surviving mantra is to have no regrets.


[User] Please transcribe this text

[Assistant] And it was all because you didn't want to gamble your game.


[User] Please transcribe this text

[Assistant] But to win my vote tonight, you might have to do just that.


[User] Please transcribe this text

[Assistant] Would you rather back your game and back your performance here tonight and you can try and convince me as to why I should write your name down?


[User] Please transcribe this text

[Assistant] And when I go to vote tonight, if I draw that white rock, I will 100% vote your name.


[User] Please transcribe this text

[Assistant] I have a bag here with four rocks in it. And one of those rocks is white. And that white rock represents you.


[User] Please transcribe this text

[Assistant] Would you rather back your game, or would you like to gamble?


[User] Please transcribe this text

[Assistant] I respect your decision. I respect you as a game player. I've said it from day one.


[User] Please transcribe this text

[Assistant] I was asked who the biggest threat coming into All-Stars was. I said Shaan is. And I think you sitting there tonight has proven that.


[User] Please transcribe this text

[Assistant] Carry the eggs.


[User] Please transcribe this text

[Assistant] Crack the eggs.


[User] Please transcribe this text

[Assistant] Uh, on several occasions there were moments where you sort of, uh, pulled out of new alliances being formed.


[User] Please transcribe this text

[Assistant] That way, okay. And then what exit do I get off on? Is it just-


[User] Please transcribe this text

[Assistant] Okay, it tells you how often the trains come, I think. So today is Sunday, and it's kind of early morning.


[User] Please transcribe this text

[Assistant] If I remember correctly in Beijing, they have like set times. So like, you can just say, oh, I know this bus will always be picking me up at this time. Whereas here it's like,


[User] Please transcribe this text

[Assistant] Uhm, well, okay, that makes sense. So that's one difference between the Melbourne tram and the Beijing bus system. So now I guess we just need to wait for the 3A tram to get here and then we take that all the way down to Luna Park and we should be, should be at the beach pretty soon.


[User] Please transcribe this text

[Assistant] She got her credit card back, and she'll be...


[User] Please transcribe this text

[Assistant] Hello old friend, good to see you again. We finally got our Mikey cards and now we are going to the beach.


[User] Please transcribe this text

[Assistant] We need to press stop to get off. And then we exit here. Stop.


[User] Please transcribe this text

[Assistant] Command card, do you guys remember? Earlier it said that if I get all three correct, I can command you all to do whatever I want.


[User] Please transcribe this text

[Assistant] Let's first figure out how to get to the tram. What exit do I get off on? I wouldn't have known how to do anything otherwise. If I remember correctly, in Beijing they have like set times.


[User] Please transcribe this text

[Assistant] Monday through Thursday is one thing. Friday is a different thing. Do you mind pointing me in the right direction? We have one more stop until we need to get off.


[User] Please transcribe this text

[Assistant] Yo, what's going on guys? Tanmay here for simple snippets and welcome back to another video tutorial on data structures and algorithms. And today's topic is going to be RADIC sort sorting algorithm.


[User] Please transcribe this text

[Assistant] So as the title of the video suggests, I'm going to be dividing this radix sort sorting algorithm into three parts. That is three videos. And this is the first part where we are going to discuss a little bit of theory and


[User] Please transcribe this text

[Assistant] We are gonna take an example and go through the working, that is the step by step process of how radix sort algorithm works. So if this topic or this sorting algorithm is completely new, make sure you watch this video till the end and I can assure you, you will understand the entire working.


[User] Please transcribe this text

[Assistant] Because we are going to take a visual diagram and dry run that working onto this example that we are going to take. And in the second part, we will take the pseudo code. We will again dry run the pseudo code on the same example. And the third part is where we write a C++ program to implement the Radix sort sorting algorithm.


[User] Please transcribe this text

[Assistant] But make sure you watch this in this proper sequence that is part one, part two and part three. And also make sure that you watch this video in one go till the end.


[User] Please transcribe this text

[Assistant] Because that's how you get the best understanding. And with that being said, let's get started.


[User] Please transcribe this text

[Assistant] If you're new to my channel, my name is Tanmay Sakpal and I do a lot of computer science and information technology video tutorials like computer programming, development, technology talks and a lot more on this channel. So if that's something you're interested into, then definitely subscribe and turn on the notifications to get the latest updates and never miss out on such important topics. Okay, so starting off with a little bit of theory, if you're making some notes, if you're preparing answers, you can note these


[User] Please transcribe this text

[Assistant] Points down. I'm obviously gonna be sharing them on our official website. So you can go check that out.


[User] Please transcribe this text

[Assistant] But starting off, radix sort is a non-comparative sorting algorithm. So, this non-comparative is very important.


[User] Please transcribe this text

[Assistant] So typically the sorting algorithms that we've seen, that is the selection sort, insertion sort, bubble sort, we have quick sort, we have merge sort.


[User] Please transcribe this text

[Assistant] And depending upon which one is smaller or larger some kind of swapping, some kind of switching, some kind of replacement is happening. So this is where comparison is happening.


[User] Please transcribe this text

[Assistant] However, Radix sort is a non-comparative sorting algorithm.


[User] Please transcribe this text

[Assistant] Now if you've been following this data structures course, in the previous couple of videos of this playlist, we've covered counting sort and radix sort actually uses counting sort also. So even counting sort was a non-comparative sorting algorithm which uses some mathematical arithmetic to determine the exact position of every individual element.


[User] Please transcribe this text

[Assistant] And as I mentioned since radix sort pretty much implements counting sort in a different way. Hence it is also a non comparative sorting algorithm. Moving on.


[User] Please transcribe this text

[Assistant] The way this radix sort works is by creating and distributing individual elements into buckets according to the radix.


[User] Please transcribe this text

[Assistant] Hence it is also known as bucket sort or, you know, digital sort. We'll talk about it. And these points might not make sense as of now because we're just going through them in terms of theory. But as you see the working, all these points will make sense. So make a note of them. Everything will make sense by the end of this video.


[User] Please transcribe this text

[Assistant] So for elements with more than one significant digit, that is multi-digit elements, kind of like this 170, 45, 75, this bucketing process


[User] Please transcribe this text

[Assistant] is repeated for each digit while preserving the ordering of prior step.


[User] Please transcribe this text

[Assistant] Until all digits have been considered and for this reason radix sort has also been called bucket sort and digital sort. Again this point also will not make sense as of now but as you move ahead you'll understand every point.


[User] Please transcribe this text

[Assistant] Moving on, typically radix sort uses counting sort as subroutine. Now the obvious question arises that if radix sort ultimately uses counting sort, why not use counting sort directly, right? So if you take this example over here in our array, you can see we have elements or integers which have


[User] Please transcribe this text

[Assistant] So if you apply counting sort for this, counting sort has a principle where we have to declare the range, right? So if you see these numbers, the largest number is 802. So the range here is from 0 to 802.


[User] Please transcribe this text

[Assistant] So we are considering a range which is around 800 elements, which means that the count array is gonna be of size 800.


[User] Please transcribe this text

[Assistant] Because every individual element, every unique number has its own


[User] Please transcribe this text

[Assistant] Index position in the count array. That's how the mapping works, right? So elements in the input array are mapped to the index position in the count array. Remember that statement? We've talked about it in counting sort.


[User] Please transcribe this text

[Assistant] And please make sure you watch counting sort first. It is very, very important because radix sort pretty much works completely on counting sort, at least in our example. So it's very important that you understand that. So in that case, the range is gonna be around 800. So the count array,


[User] Please transcribe this text

[Assistant] We'll have a size of 800. However, if you see the array elements, that is the size of an input array is only 8. So only 8 elements require count of 800 sized array.


[User] Please transcribe this text

[Assistant] So 170 will be marked somewhere, the count will go plus plus. Then there will be 45 somewhere over here. That would be plus plus. And remaining all the values, that is the 800 elements, are gonna be zero. Except for 170, 45, 75, 90, 80 to 24.


[User] Please transcribe this text

[Assistant] Only these values or only these index positions in the count array will store plus plus values that is one value. That's how the count is measured.


[User] Please transcribe this text

[Assistant] So this is why RadixSort uses CountingSort in a way that RadixSort takes this number, applies CountingSort on one digit


[User] Please transcribe this text

[Assistant] Then it applies counting sort on the next significant digit and then it applies counting sort on the last digit starting from right to left. So starting from the units place till the hundreds place or starting from the least significant bit to the most significant bit.


[User] Please transcribe this text

[Assistant] So that's the crux of radix sort and you'll understand more as we take an example.


[User] Please transcribe this text

[Assistant] Ultimately, radix sort also has linear time complexity because it technically implements counting sort only, right?


[User] Please transcribe this text

[Assistant] So the time complexity of counting sort remember was O of O of n plus k, n is the number of elements.


[User] Please transcribe this text

[Assistant] So number of elements in the array and k is the range. But here if you see there is an extra d. So this d stands for the number of digits. Number of digits.


[User] Please transcribe this text

[Assistant] That the maximum element in the input array or in the input list has.


[User] Please transcribe this text

[Assistant] Okay, so over here if you see the maximum element is 802, right? So the number of digits it has is 3.


[User] Please transcribe this text

[Assistant] Counting sort will be called three times, and hence this d extra is added over here in the time complexity. Talking about the space complexity, it's gonna be the same as the space complexity of counting sort, which is O of n plus k.


[User] Please transcribe this text

[Assistant] Because an auxiliary array, that is an extra array is created to store the count.


[User] Please transcribe this text

[Assistant] But now moving forward, we've got a basic idea that Radix sort is gonna implement counting sort.


[User] Please transcribe this text

[Assistant] So these are plain algorithmic English steps. Step by step, we go from step 1 to step 7. On the right hand side, we have our very same example that is this array of size 8. And if you notice, I have added extra zeros on the left hand side, which does not actually change the value, but we've added the zeros because


[User] Please transcribe this text

[Assistant] The maximum number here is 802 which is of 3 digits. So we want to make everything 3 digits. Just for comparison and you know, calculation purpose as we move ahead. You'll understand that.


[User] Please transcribe this text

[Assistant] But let's go step by step and apply this radix sort sorting on this array and let's see how it works. Okay.


[User] Please transcribe this text

[Assistant] So step number one, we have to take the input array and find the max number in the array.


[User] Please transcribe this text

[Assistant] So take the input array, we have to take this and we have to say or calculate the max number. So here max is 802.


[User] Please transcribe this text

[Assistant] Of course, when we implement the code, we will use some for loop to iterate through this array and actually calculate the maximum number. Right now, we're just going through step by step in the English steps format in the algorithmic way. So max number is 802.


[User] Please transcribe this text

[Assistant] Okay, with this we understand that we have the maximum number 802 which has number of digits 3. Number of digits equals to 3. Okay.


[User] Please transcribe this text

[Assistant] Now step 2 is to define 10 queues each representing a bucket for each digit from 0 to 9. So let's first visually see this and then we'll understand step 2. So step 2 says define 10 queues.


[User] Please transcribe this text

[Assistant] Each representing a bucket for each digit from 0 to 9.


[User] Please transcribe this text

[Assistant] In counting sort, when we were applying plain counting sort, we were applying it on a range of 0 to 9. That is, all the numbers were single digit numbers. So the range was 0 to 9, which means 10 unique elements.


[User] Please transcribe this text

[Assistant] Right, so the range was 10, which is kind of like a constant.


[User] Please transcribe this text

[Assistant] In this case also, even though our numbers are more than 0 to 9, obviously the range


[User] Please transcribe this text

[Assistant] Can go around 802 because the maximum number is 802.


[User] Please transcribe this text

[Assistant] In radix sort, we apply counting sort to individual digits and not the entire number.


[User] Please transcribe this text

[Assistant] So if you take one digit at a time, obviously it is gonna fall between 0 to 9 only. Hence, we only require 10 unique queues, each representing a bucket for each digit.


[User] Please transcribe this text

[Assistant] So that's why we've created 10 queues over here, you can see. Let me just erase a few things over here.


[User] Please transcribe this text

[Assistant] Okay, so we've defined 10 queues and even if things are a little confusing right now, let's move to step 3. Let's follow the steps and things will get clearer and clearer.


[User] Please transcribe this text

[Assistant] So step 3 is consider the least significant digit of each number in the list which is to be sorted. Now which is the least significant digit


[User] Please transcribe this text

[Assistant] For all these numbers, so least significant digit starts from the unit's place, that is from the right to left.


[User] Please transcribe this text

[Assistant] For the first time, that is the pass one, you can say I've written pass one over here, it's for a reason. For pass one,


[User] Please transcribe this text

[Assistant] The least significant bit to be considered is this units place which is marked in square ping boxes. So for all these numbers, this is the units place. So that's what we've considered. Now step 4 is insert each number


[User] Please transcribe this text

[Assistant] into the respective queue based on that least significant digit. So we have to take 170. We have to go from left to right. Okay?


[User] Please transcribe this text

[Assistant] The least significant bit that we are considering for the first pass is the unit's place which is 5. So 0, 4, 5 goes in Q5. So it's gonna be inserted over here. So I'll write 0, 4, 5. Okay?


[User] Please transcribe this text

[Assistant] Now these are resembling buckets, also known as queues. So the basic concept of queue is first in first out. So whichever element goes first, comes out first. So you'll understand that use case as we move ahead.


[User] Please transcribe this text

[Assistant] But let's move to the next element. The next element is 0 7 5. Again, the unit's place is 5, so it goes in Q 5. So I'm gonna write 0 7 5. Similarly,


[User] Please transcribe this text

[Assistant] 090 will go in the Q0 because the least significant bit is 0.


[User] Please transcribe this text

[Assistant] 4 is the least significant bit in the units place, so we write 0 to 4 over here, then we have 002, again it goes in queue to 002.


[User] Please transcribe this text

[Assistant] Step 5 says group all the numbers from q0 to q9 in the order they have inserted into the respective q's. So starting from the left q, that is q0 to q9, we have to


[User] Please transcribe this text

[Assistant] Take each and every number in the way it was inserted and enter it into our original array. So in pass 1.


[User] Please transcribe this text

[Assistant] We are performing counting sort in a way, obviously, because it doesn't look like counting sort right now because we are representing it in the form of buckets and queues, but when we implement the code, it is gonna be counting sort. But what we're doing is we are sorting this array by considering only the units placed in pass1. Okay?


[User] Please transcribe this text

[Assistant] So 170 was entered in Q0 at the very beginning because we started from 0, right? So we'll write 170 over here. Okay, so 170 comes over here. This is done.


[User] Please transcribe this text

[Assistant] Then we have 090, so I'll enter 090. So Q0 is done.


[User] Please transcribe this text

[Assistant] Then I'll move to Q1. We don't have anything in Q1, we move to Q2.


[User] Please transcribe this text

[Assistant] This is done. Then the next was 002, so I'm gonna write 002. This is done. Then I move to Q3. There's nothing in Q3. In Q4 we have 024, so I'm gonna write it as it is. This is done.


[User] Please transcribe this text

[Assistant] Then I'm gonna move to Q5. In Q5 we have 0, 4, 5.


[User] Please transcribe this text

[Assistant] Step 5 is done, grouping of all the numbers from q0 to q9, so starting from q0 to q9.


[User] Please transcribe this text

[Assistant] And in the order that they have been inserted in their respective queues, that's how we wrote them in our original array.


[User] Please transcribe this text

[Assistant] And what we've done is we've sorted this array one time, that is for the first time, based on just the unit's position.


[User] Please transcribe this text

[Assistant] Now if you observe, this array obviously is not sorted, right? 170 is coming at the first place, where 002 has to come. But this is not the end of this erratic sort sorting algorithm.


[User] Please transcribe this text

[Assistant] And we are still more steps. So let's move to step 6. And in step 6, it says repeat step from step 3, step 4, step 5.


[User] Please transcribe this text

[Assistant] Based on the next least significant digit. So you can see now that the next least significant digit is the tens place. Because we have three digits in the maximum element.


[User] Please transcribe this text

[Assistant] We have to do this pass three times. So we have just done one pass. Now,


[User] Please transcribe this text

[Assistant] We will move on to the next least significant digit which is the tens place. Also this time,


[User] Please transcribe this text

[Assistant] The sorting will be applied on this newly formed array. So the tens place to be considered is for this array and not the very first one because


[User] Please transcribe this text

[Assistant] We've transferred the elements into the same array, right? So you can see arr and arr. So now we have to apply this radix sort on this newly formed array.


[User] Please transcribe this text

[Assistant] By considering the tens place. Okay, so I'm marking them in pink circle so that you can see it clearly. And now let's do the pass 2.


[User] Please transcribe this text

[Assistant] Now pass 2 again is repetitive. We have to do step 3, step 4 and step 5 again, but this time we have to consider the tens place. So let's start from left to right, that is the first element in this new array.


[User] Please transcribe this text

[Assistant] I'll use some other color. Let me use yellow. Okay, so first we have to take


[User] Please transcribe this text

[Assistant] Then we have 802. So 0 is for Q0. So I'll put 802 over here. Then we have 002. And the tens place has 0. So again, 002. Moving forward, we have 024.


[User] Please transcribe this text

[Assistant] And we are considering 10's place that is 2, so it goes in Q2. So 0, 2, 4.


[User] Please transcribe this text

[Assistant] Moving forward, we have 0, 4, 5. We're considering 4, so it goes in Q4.


[User] Please transcribe this text

[Assistant] We've considered least significant digit this time is the tens place because units place is done, pass 1 is done, we are doing the pass 2. Step 4 is also done, inserting each number into their respective queue. Now step 5 again, we have to group them together starting from Q0 to Q9 in that particular order the way it was inserted. So 802 comes first, right? Then we have 002.


[User] Please transcribe this text

[Assistant] We don't have anything in Q1. We move to Q2. We have 024. We move to Q3. We don't have anything in Q3. We move forward to Q4. We have 045 over here. Then we move to Q5. We don't have anything. Q6 has 066. We move ahead. We have 170.


[User] Please transcribe this text

[Assistant] Then we have 075. So it's pushed out from over here. So 170 goes first then 075 and lastly we have Q9 which is 090.


[User] Please transcribe this text

[Assistant] Okay, so this was pass 2. Again, step 5 done, we come to step 6. In step 6 again, we have to say repeat the steps 3 to


[User] Please transcribe this text

[Assistant] This and this. Okay, so let's do the pass 3.


[User] Please transcribe this text

[Assistant] And I'll use another green color. Okay. So starting off again, consider the least significant digit. This time it's the hundredth digit. Step three is done. Move forward.


[User] Please transcribe this text

[Assistant] To step 4, in step 4 insert each number into the respective queues based on the least significant digit. So this time, the first number 802, we are considering 8. So it goes in queue 8. So I'm gonna write 802 over here. Then move forward 002.


[User] Please transcribe this text

[Assistant] This time we are considering zero and this is the reason why I added two extra zeros to the left. I hope you understand now why we've added extra zeros. It doesn't add any real value to this number, but it helps us do this proper comparison or you know proper calculation. So 002 we are considering the hundreds zero place. So I'm going to write.


[User] Please transcribe this text

[Assistant] 0 0 2 in Q0, move forward, then we have 0 2 4, so I'll write 0 2 4, then I'll move forward, we have 0 4 5, we are considering zeros, so everything is going in Q0, then we have 0 6 6, I'll write 0 6 6,


[User] Please transcribe this text

[Assistant] Again another 0, 0, 7, 5. And we are pretty much losing space. So 0, 7, 5. And lastly we also have 0, 9, 0. So I'll write 0, 9, 0.


[User] Please transcribe this text

[Assistant] Please excuse me for this bad representation, but we didn't have space over here. But anyways, now step 4 is done. Moving on to step 5, which is group all the numbers from q0 to q9 in that


[User] Please transcribe this text

[Assistant] And so, 002 comes over here. That comes out first. Again, 024. Then we have 045. Then we have 066. We have 075. And lastly, we have 090. So this is in Q0. Then we move on to Q1. We only have one value, 170. And lastly, we have only one value in Q8. That is 802. Between all the Qs are empty. We have nothing over here. But now, if you observe this array,


[User] Please transcribe this text

[Assistant] This is in proper ascending order. So if I just erase out these extra zeros,


[User] Please transcribe this text

[Assistant] So there you go, we have 2, 24, 45, 66, 75, 90, 170, 802 which is exactly in proper sorted ascending order. So lastly we come.


[User] Please transcribe this text

[Assistant] Out of step 7 because step 7 says repeat step 2 until all the numbers are grouped based on the most significant digit and the most significant digit is the 100th digit over here because that's the maximum numbers, number of digits which is 3 for 802 and this is where the algorithm will stop. And now you can see we have a proper sorted array.


[User] Please transcribe this text

[Assistant] So a quick summary to what we did in the radix.algorithm.


[User] Please transcribe this text

[Assistant] We take all the elements we calculate or find out the maximum number from those elements. Then we calculate the number of digits it has and that becomes the number of passes. So if we have a number which is in thousands, it would have four digits, right? So we would have one more extra pass.


[User] Please transcribe this text

[Assistant] From 0 to 9, because we only have 0 to 9 in the decimal system. So Q0 will be for 0 number. Q1 will be for 1 number. Q2 will be for 2 number and so on and so forth.


[User] Please transcribe this text

[Assistant] After this creation of buckets, we take every number, we take its least significant digit. So in past one, that would be units place. We see which number is that. If it is zero, we put it in Q0. If it is one, we put it in Q1 and so on and so forth. We do that to all the numbers


[User] Please transcribe this text

[Assistant] And then we group all those numbers from q0 to q9. So we'll start from q0 to q9 and we


[User] Please transcribe this text

[Assistant] Then we move to the thousandth place if we have that and so on and so forth. So we repeat this process and ultimately at the end of exhausting all these digits, we have our sorted array.


[User] Please transcribe this text

[Assistant] So yeaah, this was the overall working and visual diagram of how the buckets are created. In the next video, we will see the pseudocode for RadixSort algorithm where the counting sort algorithm comes into picture because over here I just showed you the concept of RadixSort that is the working.


[User] Please transcribe this text

[Assistant] But programmatically how it works and how counting sort is added and used inside Radixort is what we will see in the next tutorial in the form of a pseudocode and we'll implement that pseudocode on this very same example.


[User] Please transcribe this text

[Assistant] And again visually see how step by step the working goes. So that's it for this video guys. If you like this video, if you understood the overall working of Radix sort.


[User] Please transcribe this text

[Assistant] Do turn on the notifications because the next video is part 2 of RadixSort where we discuss the pseudocode and then obviously the part 3 where we write a program.


[User] Please transcribe this text

[Assistant] So all these videos will be there in this DSA playlist. I will link that in the video description. Do check them out. There are many other tutorials also. And with that being said, see you in the next one. Peace.


[User] Please transcribe this text

[Assistant] My House, written by Bev Osborne.


[User] Please transcribe this text

[Assistant] More proof that Mars is alive and kicking. That water is flowing beneath its surface right now. Water that could be sustaining Martian life.


[User] Please transcribe this text

[Assistant] An asteroid impact could have blasted fragments of Mars, complete with tiny microbes, out into space.


[User] Please transcribe this text

[Assistant] The Mars we thought we knew was gone. Replaced by this new active changing planet.


[User] Please transcribe this text

[Assistant] And if we don't know Mars, our next door neighbor, how can we imagine what surprises lie ahead?


[User] Please transcribe this text

[Assistant] So vast you could fit all the other planets inside it. Something this massive dominates its neighbors. Its gravity is pulling the asteroids apart.


[User] Please transcribe this text

[Assistant] At least three times the size of Earth, it's been raging for over 300 years.


[User] Please transcribe this text

[Assistant] Looks like the safest place to see Jupiter is from a distance.


[User] Please transcribe this text

[Assistant] Up there, at the poles, those dancing lights, they're like the auroras back home.


[User] Please transcribe this text

[Assistant] Our journey across the universe is turning into a struggle for survival. We've got to hope that if we outlast the dangers, we'll be rewarded by wonders beyond imagination.


[User] Please transcribe this text

[Assistant] And yet, strangely familiar. A bit like the Arctic, with all that ice. All those ridges and cracks.


[User] Please transcribe this text

[Assistant] Unless Jupiter's gravity is creating friction deep inside.


[User] Please transcribe this text

[Assistant] Its spectacular rings would stretch almost from Earth to the Moon.


[User] Please transcribe this text

[Assistant] Oh, you're going to enjoy it. It's a quintessentially British experience. You'll love it. Quintessentially British experience. I like that. So I have a selection of teas for you to enjoy as well. Okay. Black, green and infusion teas.


[User] Please transcribe this text

[Assistant] What tea would you suggest that I get? I would go for a traditional tea, so maybe Earl Grey, or you can have English tea as well.


[User] Please transcribe this text

[Assistant] Yeah. So we charge per person. Per person. Yes.


[User] Please transcribe this text

[Assistant] If you have an allergy or dietary requirements, I'm very happy to amend it.


[User] Please transcribe this text

[Assistant] And a glass of champagne. Champagne too! Let me get your food for you. Okay.


[User] Please transcribe this text

[Assistant] So traditionally, you'll start at the bottom with the savory items, then you'll go to the scones, and then you'll finish with the pastries at the end. Okay. So you start at the bottom, and you work your way up. But, that's just etiquette, if you prefer, you're welcome to start at the top.


[User] Please transcribe this text

[Assistant] So there's a big debate in England, whether you're from Devonshire or Cornwall. Okay. So if you're from Cornwall, you'll take the scone, you'll break it in half. Like this? Yes. So you place it down. So then if you're from Cornwall, you'll put the homemade strawberry jam on. Homemade strawberry jam. Okay.


[User] Please transcribe this text

[Assistant] Look at that, strawberry jam. And then what you're gonna do is you're gonna take some of the clotted cream and put it on top. And then do you eat it? No, you can't eat it yet. Okay. So if you're from Devonshire, you take another scone.


[User] Please transcribe this text

[Assistant] But this time, you break it in half, and you do cream first, and then jam on top. Cream on top or jam on top? I see, I see, okay. So you have to try and see which one you prefer.


[User] Please transcribe this text

[Assistant] It's the exact same to me. Don't go to any of those places and say that.


[User] Please transcribe this text

[Assistant] Hello grammarians, today I'd like to introduce you to the verb, which is another part of speech. But I suppose the most fruitful place for us to begin is by asking, what is a verb?


[User] Please transcribe this text

[Assistant] Well, verb is a part of speech that has a bunch of different functions, but one of its most important functions is that it can express or show action. Verbs can show.


[User] Please transcribe this text

[Assistant] And I'm going to use this bear in several sentences, each of which will contain a verb, because all sentences contain verbs. So I'm gonna write a couple of sentences about the bear, and every time I use a verb, I'm gonna write it in yellow like that. Here we go. The bear roars.


[User] Please transcribe this text

[Assistant] Now each one of these words in yellow is a verb.


[User] Please transcribe this text

[Assistant] Each one of them is an action. And this is the first thing that verbs can do. Verbs can show action in sentences. And in fact, all sentences must contain verbs. You can learn anything. David out.


[User] Please transcribe this text

[Assistant] Hello grammarians. Today we're going to be talking about the irregular plural. Uh, previously I had said that if you take any English word, any noun, say the word dog.


[User] Please transcribe this text

[Assistant] And you tack an S onto the end of it like so. Boop, you get the word dogs. And that's how you form the plural, uh, in all cases.


[User] Please transcribe this text

[Assistant] I was lying. Sorry. It turns out that English is a little bit more complicated than that. While adding an S to things is the way you usually make things plural, sometimes there are other changes and sometimes you don't even pluralize using an S at the end. But we're not going to talk about that now. That's for another time. What I want to talk about today is the


[User] Please transcribe this text

[Assistant] Most basic kind of irregular plural. So we have the difference in English between regular


[User] Please transcribe this text

[Assistant] And remember a plural, uh, is when there's more than one of something. It comes from the Latin plus, which means more. As opposed to the singular, when there is just one of something.


[User] Please transcribe this text

[Assistant] So there's a handful of words in English, and it really is a handful, that don't pluralize regularly. Words like leaf and loaf.


[User] Please transcribe this text

[Assistant] If you try to pluralize these as though they were regular plurals, you're gonna return something that is not.


[User] Please transcribe this text

[Assistant] Correct, or at least is not conventional within modern, standard American English, right? So, Leafs, for example, unless you're talking about the Toronto hockey team, is not correct. In fact, the proper term,


[User] Please transcribe this text

[Assistant] So there are several different kinds of irregular plurals, that's why this video is called part one, but I'm only going to cover one such irregular plural today, and that is the change from singular F to plural VE.


[User] Please transcribe this text

[Assistant] So if you see a word, generally, that ends in F, the plural is going to become V-E. You can learn anything. David out.


[User] Please transcribe this text

[Assistant] Hello grammar pals and welcome to the future full of jetpacks and spaceships and shiny jumpsuits, uh, and also the word will.


[User] Please transcribe this text

[Assistant] There's a lot of will in the future, uh, by which I mean that we use this word.


[User] Please transcribe this text

[Assistant] Will. To form the future tense in English. So in the present tense you'd say,


[User] Please transcribe this text

[Assistant] I will eat this cupcake because we use the future to talk about stuff that's happening later than now.


[User] Please transcribe this text

[Assistant] As opposed to the present, which talks about now, and the past, which talks about stuff that has already happened earlier.


[User] Please transcribe this text

[Assistant] So the most common way to form the future is to just make a sentence in the present tense and then before the verb, just shoop, stick will in there. So, I pet the triceratops.


[User] Please transcribe this text

[Assistant] I pet the Triceratops, but in the future, maybe when they clone dinosaurs, I will pet the Triceratops.


[User] Please transcribe this text

[Assistant] So that's the most basic way of forming the future. You can also use, you know, is going to.


[User] Please transcribe this text

[Assistant] So you could say, you know, Lorraine.


[User] Please transcribe this text

[Assistant] The future. But the most common way to do it is to just put in will.


[User] Please transcribe this text

[Assistant] Just write the sentence as you would for the present tense, but then you just gotta pop in, zoop, will.


[User] Please transcribe this text

[Assistant] I eat this cupcake is the present. I will eat this cupcake in the future. That's the future tense. You will be able to learn anything. David out.


[User] Please transcribe this text

[Assistant] Alright, good morning. Geez, you guys really start recording early today.


[User] Please transcribe this text

[Assistant] Oh my goodness, I'm excited and a little bit nervous to see this. Okay, let's see. Should I read it out loud? Okay.


[User] Please transcribe this text

[Assistant] If you manage to jump from high altitude, Tomato Team will treat you to a feast at an authentic Hawaiian food restaurant. If you fail the challenge, you have to go home by yourself. Okay, well.


[User] Please transcribe this text

[Assistant] Alright, about to go skydiving. Oh man, I'm nervous. You can see the people parachuting right now. They're coming down from the sky.


[User] Please transcribe this text

[Assistant] So, uh, I got some more questions. What's the, what's the altitude that we're gonna be jumping from?


[User] Please transcribe this text

[Assistant] I can't wait. Uhm, so where exactly do we land?


[User] Please transcribe this text

[Assistant] Has, has anyone, whenever you've done this, has anyone ever chickened out and gotten cold feet up in the air?


[User] Please transcribe this text

[Assistant] There's absolutely no way that I'm gonna walk all the way back.


[User] Please transcribe this text

[Assistant] Oh my goodness, that is something I will never forget.


[User] Please transcribe this text

[Assistant] It's hard to describe my feeling right now.


[User] Please transcribe this text

[Assistant] It's a hundred percent my responsibility. I'm still confident that nothing is going to go wrong though, so.


[User] Please transcribe this text

[Assistant] I mean there's fancy artwork all day long, but it's like, it is the simplicity I think that draws you to it. It's more about the focus of the person than the wall, so.


[User] Please transcribe this text

[Assistant] Hi grammarians. Today I want to talk about this idea in English that we call agreement. So I'm going to teach you how to be agreeable and make it so that all of your sentences get along really well. Let me, let me give you an example. The dog barks.


[User] Please transcribe this text

[Assistant] As opposed to the dog's bark. Do you see the difference?


[User] Please transcribe this text

[Assistant] It's funny because the S seems to, seems to migrate, seems to move from one part of the sentence to the other. So what you wouldn't say is,


[User] Please transcribe this text

[Assistant] I know that's, that seems strange that you wouldn't want to have the S follow the other S, but you actually only want to have one of these in a sentence. So the dog barks, the dogs bark. When there's only one of something,


[User] Please transcribe this text

[Assistant] Strangely, in the present, you know, in the present tense, it takes this S. So Jake bakes a cake. We bake a cake. Not Jake


[User] Please transcribe this text

[Assistant] Bake. A cake. Which admittedly is a fun sentence to say. But this is not, in standard English, this is not correct.


[User] Please transcribe this text

[Assistant] It doesn't, it doesn't exhibit what we call agreement. Similarly, you also wouldn't say, we bakes a cake.


[User] Please transcribe this text

[Assistant] If you're familiar with the Lord of the Rings books or movies, if you remember Gollum, the character Gollum, this is a weird little bug-eyed critter. He was just kind of obsessed with the one ring.


[User] Please transcribe this text

[Assistant] He has this very particular way of speaking that is not, strictly speaking, a standard. Uhm, he's just wild about that ring.


[User] Please transcribe this text

[Assistant] And the way he refers to everything is he just throws on an S, uh, on the end of every word he uses, every verb. So if he's talking about, you know,


[User] Please transcribe this text

[Assistant] This, this magic ring that he's very fond of, which he calls the precious. Uh, he wouldn't just say, I love it. He'd say, I loves it.


[User] Please transcribe this text

[Assistant] Like so. And that's not correct. That does not, that does not show agreement. So the test here is really


[User] Please transcribe this text

[Assistant] You can figure out whether or not you are using agreement in your sentences if you sound like Gollum.


[User] Please transcribe this text

[Assistant] Because if Gollum were being grammatical, he would say, I love it.


[User] Please transcribe this text

[Assistant] So this is, this is the sense that I want you to develop, is you listen to yourself speak and you ask, do I sound like Gollum, the little ring monster?


[User] Please transcribe this text

[Assistant] Because if you do sound like Gollum, then you're probably not operating under the, the agreement rules of standard American English. Or you're just doing a Gollum impression.


[User] Please transcribe this text

[Assistant] That's the basic idea behind agreement.


[User] Please transcribe this text

[Assistant] Is you just want to make sure that the parts of the sentence match up. Sentence parts.


[User] Please transcribe this text

[Assistant] We are here at the Griffith Observatory. It's gonna be such an exciting experience. Okay, let's see. What is my mission?


[User] Please transcribe this text

[Assistant] Tomato English Los Angeles College, Department of Geography and Astronomy, 2018-2019. Fully utilize all the elements in the observatory. All the answers can be found at the observatory in front of you. So this is it? This is my, this is my exam right here? This is my whole exam, huh? Okay, this doesn't seem that hard.


[User] Please transcribe this text

[Assistant] Oh, I have to use some kind of archaic method for determining the time.


[User] Please transcribe this text

[Assistant] I think the designer who created the statue is also responsible for the creation of the Oscar award. Right, the guy who stands like this?


[User] Please transcribe this text

[Assistant] Correct watch time on the ring.


[User] Please transcribe this text

[Assistant] So I would say this, this clock is a few minutes off, but still very impressive for an archaic time telling piece. It's still within 10 minutes of my phone. That is awesome.


[User] Please transcribe this text

[Assistant] If you really want to take a look at the big picture, this is what I call a big picture.


[User] Please transcribe this text

[Assistant] Is a cluster of probably tens of millions, if not billions of stars. It's incredible, it's enough to blow your mind.


[User] Please transcribe this text

[Assistant] I mean, this has to be Earth. I mean, this has to be Earth. I mean, this has to be Earth.


[User] Please transcribe this text

[Assistant] And you can see this seismograph. The pulse moves a little bit. There's a needle that records on paper. And the needle jumps any time I make a movement.


[User] Please transcribe this text

[Assistant] But I think that if I recruit some help from other people, we can make some really big waves, so. Excuse me, do you want to jump with me?


[User] Please transcribe this text

[Assistant] Oh yea, no worries. I'm gonna try to recruit some others. Yo, man, you wanna jump with me for a second? We can, uh, try to make a big earthquake right here. You see whenever you jump, the seismograph goes up and down. If we jump together, I think we can make a really big earthquake.


[User] Please transcribe this text

[Assistant] I passed- unlike my regular science classes back in high school, I passed!


[User] Please transcribe this text

[Assistant] What kind of show? Okay, let's go.


[User] Please transcribe this text

[Assistant] As a reward, I get to view the show, and I'm so excited about it. Looks like everyone's getting in line over here, so come on, Patrick. But before we get in line for this show...


[User] Please transcribe this text

[Assistant] Can I just say how beautiful this view is from up top here at the Griffith Observatory? This truly is the sweet spot to view all of Los Angeles and the Hollywood sign behind you.


[User] Please transcribe this text

[Assistant] This has to be it. My phone says 210.


[User] Please transcribe this text

[Assistant] There are two things you can find in almost every country. Chinese people and Chinatown.


[User] Please transcribe this text

[Assistant] So today, we're going to have a look at what an American-made Chinatown looks like.


[User] Please transcribe this text

[Assistant] Los Angeles has the largest Chinese population of any city in the United States. This Chinatown was built in 1938.


[User] Please transcribe this text

[Assistant] Although not as famous as New York's, it is one of the oldest Chinatowns in the United States.


[User] Please transcribe this text

[Assistant] Near this place, you can find the antique Chinatown Gateway and the iconic Sunny At Sin statue.


[User] Please transcribe this text

[Assistant] There are many shops in Chinatown with Chinese signs, as well as porcelain, painted paper umbrellas, silk dresses, and other traditional Chinese goods.


[User] Please transcribe this text

[Assistant] This is my belly.


[User] Please transcribe this text

[Assistant] Hey, what's going on guys? Tanmay here for Simple Snippets and welcome back to another video tutorial on data structures and algorithms. And as the title of the video suggests, today's topic is rules and pseudocode of postfixed prefix expression conversion using stack data structure.


[User] Please transcribe this text

[Assistant] So in this tutorial, we're gonna see the rules as well as the pseudo code which is required to convert a postfix expression into a prefix expression.


[User] Please transcribe this text

[Assistant] So this is like part one and in part two we will write a C++ program so implement it practically. But for that we need to understand the rules as well as the pseudo code. And if you've missed any of the previous tutorials on prefix, postfix, infix and stack data structure, do check out this entire course. I've pretty much explained it in detail.


[User] Please transcribe this text

[Assistant] Also in previous tutorial, we saw the manual conversion of postfix to prefix and vice versa. So you can check that out as well. And with that being said, let's get started.


[User] Please transcribe this text

[Assistant] If you're new to my channel, my name is Tanmay Sakpal and I do a lot of computer science and information technology video tutorials like computer programming, development, technology talks and a lot more on this channel.


[User] Please transcribe this text

[Assistant] So if that's something you're interested into, then definitely subscribe and turn on the notifications to get the latest updates and never miss out on such important topics. So before we go to postfix to prefix using stack,


[User] Please transcribe this text

[Assistant] You can see on the top we have convert postfix to prefix, manual conversion.


[User] Please transcribe this text

[Assistant] And on the right hand side, we have the same question that is same postfix expression, which we have to convert using stack data structure.


[User] Please transcribe this text

[Assistant] So I'm just quickly gonna show you the result because then we will take that result


[User] Please transcribe this text

[Assistant] And cross check it with our conversion using stack data structure.


[User] Please transcribe this text

[Assistant] Okay, so this is how the entire process would go for the manual process of converting a postfix to prefix expression. You'll take the postfix expression, you'll start from left to right.


[User] Please transcribe this text

[Assistant] And you'll find the first instance of two operands and one operator and convert it to its prefix format. So that's why you can see ab plus becomes plus ab in the prefix format. Then you consider plus ab as x1.


[User] Please transcribe this text

[Assistant] So that's how we get x1 and then you repeat the entire process till all the different sub-expressions are converted to its respective postfix format and ultimately you get this result. Okay. So this is the final prefix expression of this postfix string.


[User] Please transcribe this text

[Assistant] Now this was the exact postfix string which was question number 3 in previous tutorial. So if you are still confused, you can check it out how the process goes. But we're gonna now take this result and let's write it over here.


[User] Please transcribe this text

[Assistant] And now we will use the stack data structure to convert this same poshfix string. You can see there is the same poshfix string to its prefix format and then the answer that we get, we'll cross check it with the manual conversion.


[User] Please transcribe this text

[Assistant] So that we can verify whether our process is going right or wrong. Okay? So this was


[User] Please transcribe this text

[Assistant] Manual method, now let's see the pseudo code because the rules and the pseudo code are pretty much the same, just in different formats.


[User] Please transcribe this text

[Assistant] Okay, so on the leftmost side we have rules for postfix to prefix using stack data structure and in the center we have the same rules which are converted into pseudo code format because obviously when we write a C++ program


[User] Please transcribe this text

[Assistant] This pseudo code is much more understandable and easy to convert into a code, okay? These rules are just English written steps, which are


[User] Please transcribe this text

[Assistant] So we'll go through the pseudocode because these rules and pseudocode are pretty much the same thing, represented in two different ways.


[User] Please transcribe this text

[Assistant] So for every instruction in the pseudo code, we have a corresponding rule in the rules. Okay. So we'll try to explain that. Okay. Now starting off with the function, we create a function named postfix to infix.


[User] Please transcribe this text

[Assistant] You take the postfix string because we have to convert postfix to prefix. Okay. The vice versa process we'll discuss in some other tutorial in next tutorials. Right now we are only dealing with converting a postfix string.


[User] Please transcribe this text

[Assistant] We've already discussed postfix to infix infix to postfix


[User] Please transcribe this text

[Assistant] Prefix to infix, infix to prefix in previous tutorials in this course, in this playlist. So you can check that out. But anyways, moving on.


[User] Please transcribe this text

[Assistant] Step number one, we create a stack S. Okay. So obviously when we write code, we will create a stack data structure, stack object. So on the right hand side, you can see this huge container. Let's call it stack S. Okay.


[User] Please transcribe this text

[Assistant] Next thing is we loop from i equals to zero till the postfix.length.


[User] Please transcribe this text

[Assistant] Now on the top, this is the postfix string, this is the postfix expression. But when we write a program, when we look at it programmatically, this is gonna be a string of characters, right?


[User] Please transcribe this text

[Assistant] So you can think of this as a string array.


[User] Please transcribe this text

[Assistant] With starting index position 0 and ending index position as 12.


[User] Please transcribe this text

[Assistant] So the length of this string is gonna be 13. And that's why we have a loop of starting from 0 to posfix.length.


[User] Please transcribe this text

[Assistant] So we'll start from 0 till 12 in this case because our string is


[User] Please transcribe this text

[Assistant] Having a length of 13 from 0 index to 12, okay?


[User] Please transcribe this text

[Assistant] Now this loop that is step number two in the pseudo code corresponds to rule number one in the rules of postfix to prefix which says can the postfix expression from left to right which essentially means from the start to the end. Okay?


[User] Please transcribe this text

[Assistant] Which means we have two parts in this loop and these two parts are nothing but if and else if conditions.


[User] Please transcribe this text

[Assistant] Postfix string, you can see that we either have variables, that is the operands, or you have operators, which is plus minus, raise to, divide by and multiplication.


[User] Please transcribe this text

[Assistant] So in a postfix expression, in fact, even in a prefix expression, we only have two types of symbols, two types of characters. Either the character is gonna be operant,


[User] Please transcribe this text

[Assistant] Which can be any constant, a variable or a sub-expression.


[User] Please transcribe this text

[Assistant] Or it can be an operator. So operator is this arithmetic operator which is plus minus.


[User] Please transcribe this text

[Assistant] Divide by multiplication and raise to. So these are the 5 characters which are considered as operators in our case.


[User] Please transcribe this text

[Assistant] So if it is an operand, that is, if it is a, b, c, d, any variable, we simply push it onto the stack. Okay, so you can see s.push push fix of i.


[User] Please transcribe this text

[Assistant] So take that postfix of i, which is the character that we're looping. So i is the iterator, right?


[User] Please transcribe this text

[Assistant] And else if the postfix of i is operator, operator is nothing but as I mentioned plus minus divided by multiplication and raised to


[User] Please transcribe this text

[Assistant] So in that case, what you do, you create operand 1, you take the top of the stack, then you pop the top of the stack, that is remove it off, then you create operand 2, op2, again take the top of the stack, remove that also,


[User] Please transcribe this text

[Assistant] Then step number 2.2.5 you create this expression which is a sub prefix expression which says postfix of i which is gonna be the operator plus op2 which is operand 2 plus op1 which is operand 1.


[User] Please transcribe this text

[Assistant] And this will create the sub prefix expression which we will push onto the stack in 2.2.6. And then you end the loop.


[User] Please transcribe this text

[Assistant] And ultimately after this entire scanning of this entire expression, you return the top of the stack. Okay, now 2.1 is corresponding to


[User] Please transcribe this text

[Assistant] Rule number two in the rules, which says if incoming symbol is an operand, you simply push it onto the stack. That's what we are doing. That is,


[User] Please transcribe this text

[Assistant] Pop two operands from the stack, that is remove two operands from the stack. Add the incoming operator at the start of the two operands. Basically make a sub prefix string.


[User] Please transcribe this text

[Assistant] The last line in the pseudocode, which corresponds to rule number four, which says at the end, pop and print the full prefix expression from the stack.


[User] Please transcribe this text

[Assistant] So I know things are not really very clear because I just read out the pseudocode as well as the rules. But now actually let's just apply this pseudocode onto our existing string.


[User] Please transcribe this text

[Assistant] And let's see how these rules apply, okay? Because now we are gonna convert this postfix expression to its corresponding prefix expression using the stack data structure. Okay, so step number one.


[User] Please transcribe this text

[Assistant] Of the pseudocode is to create the stack S that is what we have over here. It is an empty stack right now.


[User] Please transcribe this text

[Assistant] Okay, so next step is to loop from i equals to 0 and we will go till the postfix.length which is 13 in this case. So from 0 to 12 is the iteration. Okay, let's track i, so I'm gonna write i equals to 0. So we are at this position.


[User] Please transcribe this text

[Assistant] Inside this loop, we will take this postfix of i, which is postfix of 0 for now. We will see, is it an operand? Yes, it is an operand in this case. So we will push it onto the stack. Okay? So a is pushed onto the stack. So a is the top of the stack. Okay, let's move forward.


[User] Please transcribe this text

[Assistant] Now since 2.1 got executed, that is the if block got executed, this 2.2 will not be executed, that's how if and else if works, right? So either it will be an operand or it will be an operator. Since 2.2, that is since it is an operand, it is not an operator. So we will come at the end of the loop, i will become 1. Now we will move forward, we will come over here. What is this? This is b, b is also an operand. So we will simply push b also onto the stack.


[User] Please transcribe this text

[Assistant] So this is the new top of the stack. Let's move forward. I will now become 2. So we are at this index position. And now if you see, if posfixify is an operand, no it is not an operand.


[User] Please transcribe this text

[Assistant] Obviously 2.1 will not be executed, 2.2 will be executed because it is an operator. Operator is anything which is plus, minus, divided by, raised to and multiplied. Right?


[User] Please transcribe this text

[Assistant] So since it is an operator, what we do, we say op1, let's write op1 over here, equals to s.top. What is the top of the stack? It is b. So I'm gonna write b over here. The next thing is, we say s.pop. So 2.2.1 is done.


[User] Please transcribe this text

[Assistant] 2.2.2 says s.pop, which means we have to simply remove this top of the stack. So I remove this, and now the new top of the stack is A.


[User] Please transcribe this text

[Assistant] Remember pop function in a stack is to remove the top of the stack. So moving on at 2.2.3 we say op2, let's write op2 over here, equals to


[User] Please transcribe this text

[Assistant] S.top and now the new top of the stack is A, so I'm gonna write A over here. So this is done.


[User] Please transcribe this text

[Assistant] 2.2.3. Now moving on to 2.2.4, which says s.pop, so I'm gonna remove this also. Now the stack is empty. So at 2.2.5, if you observe, you can see, we have to create this expression, I'm gonna write exp over here, equals to, we say postfix of i, what is postfix of i currently? We are at index position 2.


[User] Please transcribe this text

[Assistant] And at index version 2, we have a plus sign. So I'm gonna write plus over here. We have OP2. What is OP2? OP2 is A. You can see I've written over here. What is OP1? OP1 is B. So I'm gonna write B over here. So this is our exp.


[User] Please transcribe this text

[Assistant] Now if you observe, this is exactly a prefix expression for this.


[User] Please transcribe this text

[Assistant] Postfix expression. So ab plus is postfix plus ab is prefix. So you can see we are slowly converting small, small subparts of this postfix expression towards appropriate prefix string. Okay, so let's move forward now.


[User] Please transcribe this text

[Assistant] So now that the 2.2 lsif part is completely done, all the 6 steps, we come at the end of the loop, we go at the start of the loop, and now i becomes 3.


[User] Please transcribe this text

[Assistant] So we are at this index position, it is c, c is operand, we push it onto the stack, right? So c becomes the new top of the stack. Then we move forward, i becomes 4.


[User] Please transcribe this text

[Assistant] Now at index position 4, we have a minus operator. So it is an operator, hence 2.2 will be executed. We say op1 is equal to s.top. What is the top of the stack? C. So C goes in op1. Then at


[User] Please transcribe this text

[Assistant] 2.2.2 we say s.pop, so we remove this c from the stack. The new top of the stack is plus ab.


[User] Please transcribe this text

[Assistant] At 2.2.3 we say op2 is equal to s.top. So op2 will have plus ab now because that is the top of the stack. Then 2.2.4 says remove that by saying s.pop. We remove it. At 2.2.5 we say