Transcription
Hello everyone. In this video, we will complete DS, i.e., we will complete the data structure, specially for your semester exam.
In this video, I have told you, from an exam point of view, which topics are important, and what questions should you ask exactly from there. In this video, I have given a complete data structure from start to end. If you have not taught data structures before, never read them, or you want to revise them, this video is perfect for you. If you complete this entire video, I guarantee you will learn data structures. I have studied many colleges and university syllabi, and the content is finalized, this is guaranteed. I am sure that more than 95% of your semester or university exam will match whatever we have discussed in this video.
Immediately below, you will find the link to Pro Level Notes: Video in the description. On the timeline, you can see the chapters; by clicking on them, you can go to any topic. You can also directly go to the comment section from wherever you are watching the video. Do it once and let us know your comments. A map of India can be seen being created in this section, so hello everyone, let's get straight to the point.
These are the videos about the topics and chapters that you can see. So I'm understanding again, as I speak to you, I have read the syllabus of different universities. After studying, I posted this video divided into chapters, so we will start with Introduction, Basics, Array, Linked List, Stack, and then the Queue, then the Tree, Graph, and Hash.
There are certain topics which I eliminated because I felt those algorithms should be read separately, and they have been placed in some universities. Like, for example, spanning graph trees and single source shortest path; I have not discussed the algorithms here. I will do Mtoto Shans and full time. The one with the complexion will do everything here and there. Then what will everyone do in the algorithm? I have removed some sections of this detailed syllabus, which I am studying here and discussing. Even if half the man is not there, half the man too I will cover in algorithms; that next video is coming later, so please cross-check. If you miss any topic, then read it once. Please cross-check, because here, I will cover around 10 to 12 algorithms, which should be standard. If you want, then check it out once, and we will take this sequence through the video, keeping following you here always on top. You will always see the chapter number here, which sequence of that chapter will be seen; it's a topic; this is the sequence I will follow. If you want, you can take a screenshot and accordingly, you can take it forward.
Yes, so now let's start directly with the basic idea, and now I will start with the basics, right? Because some people here are obviously like this. Maybe those whose background is not CSIT, or maybe they are preparing for some exam like GATE and NET, something like this, and want to develop a basic understanding; this video is very useful for them too. If it's going to happen, I'm going to start with the basics. Let me start with basically what is the idea of Computer Science. For a Mechanical Engineer, it is not an easy source. We are making cars, we are making air conditioners; there is something like this. Civil engineers are building roads, not electrical engineering. In electrical engineering, we know electric machines and our transformers are like this. If I am working on devices, do the very basic concepts of CSIT. So it's a two-step process. I am looking forward to dealing with computer science.
Solving a problem correctly in the form of an algorithm is, first of all, a problem we have to solve. Some people think that low CSIT means starting to write code; no, it is not so. First, we understand the problem. Step number one: you understand the problem. And better than that, you write an algorithm for it. An algorithm does not mean writing a program. You can also write in natural language. There are yes and then, when we understand that the algorithm is absolutely perfect, the logic we have correctly applied, then we convert it into a program that any programming language could be – C++, Java, Python, whatever it is. Yes, so as you see, it’s a three-step process and a two-step process. Step number one: first you let's understand the problem. In step number two, you generate it; basically, you write an algorithm for this. And then, in step number three, you convert it into a program.
Look at one very important thing here. I am mentioning efficient in brackets. From a program, it is just about writing programs. No, many people can write programs; nowadays, even a 4 GB drive can be written. Yes, but the point is how time-efficient, or you have that problem in efficient space. If you are solving it, then it is important. Don't just write a program. Conclusion: How to write an efficient program. The idea of an efficient program, how to write. Now look at this: to write an efficient program, we need the knowledge of both data structures and algorithms. This is a very important thing, isn't it? This is how some people feel: "Sir, my programming is very weak." Brother, if it's weak, then what program did you know? Found a problem and started writing the program. I didn't do it like this until I saw you. Basically, I want to understand that this is complete. Why are we studying this subject unless we have a solid-level understanding of data structures? Unless you have algorithms, you will have a good program; it ends up being a process. If you will not be able to write an efficient program, why are you studying data structures, sir? The anchor run, we are a good programmer, but a lot of DS and Algo will be made for him. It is important to have good knowledge; yes, this is why we are moving forward now. This is the whole story I told you: we want to code efficiently by studying data structures. And there are many parameters of efficiency. Could be time, could be space. Nowadays, battery-intensive mobiles, phones, laptops, you know, battery backup, how much is the system bus, routers, then the story. There are many, but ultimately only two ideas. Or to be processed, same idea we long discussed in the run. That's the time. The less time the algorithm takes to execute the program, the less time it would be better. Okay, here's one more thing. Let me tell you, because I also remember when in the beginning we started reading that sir's first year and second year people used to talk about a program. Guess whatever it is, isn't it? I have written a program in 15 lines. Can anyone write it in 12 lines? If you can write in one line, then don't think so. Imagine a program as small as it takes less time to execute. If this does not make any sense, then efficiency is like related to the execution time, and it depends on how well you use data structures and algorithms. Have you done that in the least line of code? Have you tried to complete it? We understand now, let's talk; our algorithm is a different part of the we will cover a complete story later.
Have you understood the ecosystem and not the age data structures and algorithms? Are data structures important now? They understand that look wherever they want. You may have a kitchen in your home or a shop. If I go, he will arrange some things. If you have a room or where we will keep anything as our luggage, you are arranging, isn't there something new in this? It doesn't matter, and this arrangement is done by the computer. If it is inside, then inside the computer we have a lot of memory and data. How do we arrange data in memory? This is the easiest data structure. Logic means you know the definition after studying. Sometimes we forget the basic fundamentals. Brother, now you know the medical store; you can go sometime. Will show a form that the doctor's prescription is, and what is that, brother? Let's say we will call someone for help. The one who does it is the fourth one. Take out all those medicines from the cupboard. Know something about arranging data properly. This medicine is kept in the fourth box. You will find a strip inside, check once. Something like this won't expire. Here, I want to take an example of a supermarket like Big Bazaar or Peacock like this. This is normal for any elder these days. You will find such shops in stock. So here you will see, if random arrangement is what you do and keep it, otherwise, one how to arrange goods in a supermarket. People should do a full PhD on this. Isn't this such an important idea? Due to this, the cells fluctuate a lot. What will be the temperature inside, and what will be the music like? Everyday items that will do. Will you ever notice that milk and bread are there? It's not like that; they will put it at the entrance, right? Then you keep that for last. You have to go through every corridor. I don't know what will catch your eye. The item which belongs to children is toffee and chocolate, kind of stuff always on the bottom shelf. You will find Maggi kept on the bottom shelf. That child should not be dependent on the parents. I raised my hand inside the you know basket. If you can keep like this, then you can't keep it random. There are cornflakes and puris somewhere right now. Category you will find biscuits somewhere. So if you get the biscuit category, then it will be very good. All things are learned in some space. How should it be organized in this? This is the data structure of a computer. So a data structure is a particular way of organizing data in computer memory. Now it can be anyone; it can be secondary or main memory; be it cache, whatever it is, it is so that memory can be used efficiently both in terms of time and space. So how do we arrange? And there will be a trade-off of time and space. Means sometimes it happens, maybe we need both. Sometimes do we mostly care about both? You will have to keep it in mind lest you get too much space occupied, but it should not be such that it slows down to save space. Suppose your books are one above the other. By placing one on top of the other, it's okay if you pack it, but there is very less space taken. But if I say that the one below take out the book and give you all the books above, something like this will have to be removed. We have to keep in mind that data like this, if it is stored, then it will be too much space occupied. Like the store owner yesterday, when our user they said that we should extract this data and bring it back. This is how you can quickly retrieve complete data. The complete arrangement is called a data structure. So to be more specific, it is a logical relationship; yes, all those definitions are there too, which you have to write in your exam. Can go by them and notes, so you get the link. You will find it in the description; it is a logical relationship existing between individual elements of data. It considers elements stored and also the relationship to each other is very important. So what can I say? Only this thing is important here. It does not mean that the specific data is that we how are you storing this importance? What is the relationship between data and each other? Where is it stored like a tree case? I will talk further about who is the parent? Do you have any parents with children? What is the relationship about linklist? We will talk about the address of the next node with this node. You will get like this, or like I talk here. This category does not mean that any data anywhere around where you're storing it. What is your relationship with something like? So we consider both these things. How are you storing the data? What about the neighbors? Organization is a relationship, so whenever we specify that any data structure is four things we define are organizations, accessing methods, degree, look at the association and processing methods. First of all, we have to understand one thing about us. Let's talk about linklist, stack, queue. No matter what the tree is, it's all like this. What we found in the chemist lab and this is this what happened in Harappa? Excavation was done and an array was found after that. Linklist is not available; you have to understand all this. That they are popular arrangements which are of the time together. We have learned what is called necessity, is the mother of invention. So four people had to arrange data in computer memory. I thought it was like this man. The organization is doing good work again and again. We were using it and then named it Array. Is there any other mechanism developed? There is a problem in the Kantus location. Do not Kantus. So I named it Linklist and it looked like this. It's not like someone came and gave us time. We learned by making mistakes and with time we understood that these four or five are popular organizations; it is much better. That's why you should teach when you're in the industry. Really go into product development. If we do, then is this data necessary? Use the structure, not yours. Hybrid tax can be modified accordingly. Can define a new data structure. But now when you have new data, if we define the structure, then we will define it. What four questions do you have to answer? Data in the memory of the first organization, how will it be arranged like we will say here? One after another in the cantes floor will arrange here; we will say a node which will have two parts, data and the inside the link data you will place the data of the link. There will be a pointer inside to guide you to the next node. You will send a note inside the tree which will have a pointer to the left file will reach a pointer to the right child and how will you organize if there is data in the middle? That's something you have to tell me. Next Accessing Method. Different data structures, in example linklist, that you can access direct d node can't because D's AIDS C's C is near B. B is near A. is accessed only in a proper pattern. Will be able to go while inside the array if you have the base address you can access directly. Or if you want direct bottom access in the stack, want to do it, technically this is not possible. There will always be top of the stack access, so every there are different rules of data structure which next we will read these specifications in detail. How much will the degree of association do for one note? It is related to the note like here in front of you. There is one behind you, there is one behind you; now it is a matter of a graph. If we do, then for example, one here someone is a neighbor while two are one and if there are three neighbors, then how many people do they have? You are associating with and then the processing method. For example, Link List, how to insert and delete data? How to do modification in array? How will it be done when all this? If you define a thing, then you will accept it. Are you sure that you have created a new data structure? If defined, then this is basic understanding is some of the popular types of you can see the data structure but there is no need to panic again, everyone we are going to read now effect in detail of data structure already I will talk about it I have done it but still I am reminding you I am solving your problem again. No matter how good your attitude is, how good is the understanding of the algorithm? Why not? But if the problem is right and correct algorithm from you know what should I say with the right data structure, you know, if you don't merge, you won't mix. Good result will never come, for example. Now gradually we will understand that it is not so. Is this data structure good or bad? It depends on the idea. Depends on the scenario. Environment historical data is inserted. Delete is not more less read operation. What is the problem if it goes for array? If you don't have any tension about insert and delete, then it's okay. I think time will work very well. One can't beat an array in terms of, but if heretical relationship is sorted data, maybe binary search and evil tree makes sense. Yes, so depending on the idea, we have to choose suitable data structure. There is no formula for this value. Fill it, and the answer will come, use it. Different nature as we read. We will gradually solve the problem. Our understanding will develop that should this be used in the scenario or this should be used in the scenario. Yes, so slowly we will understand, for example. Look at this when we talk about DBMS and we have to store the index file. So we understand B trees and B plus trees are the top known data structure. No one can compete with this; it becomes optimal if we use the compiler's talk to us about storing symbol tables. If yes, then we understand that the tables have been performed. Best sleep again, impact will be huge if you choose the right data structure. Won't then there will be a problem. Now proceeding further, one more small one classification is there, but they manage to have clarity. We will divide data structures into two parts: primitive and non-primitive. Now let's see what it means. What image should you put in the data structure? Sir, what does this have to do with it? Let me know. Give in context. Suppose you are at home. Everyone has to make it, right? The requirement is that it is very different. Obviously, you know, hardly anyone in the world a house which is exactly the same, i.e., a flat, etc., but in that also people like him customize it a bit as per your convenience. Now this is probably the reason why the market you don't get a ready-made house, right? Went to the shop, brought it home, and kept it on the ground. Took and kept the house inside the factory. Took it and started working; otherwise, people have to build houses because their requirements are different, so not making and selling directly. But when we let's talk about whether we want to build a house or not. This means that first, we need to first we will have to make cement. First, we will have to make some iron rods. House will not be built if you have to make bars. No, these are some of the best things made in the market. If it is made and sold, then you don't think much about it. More about what the design of the brick should be. Brick is basic; brick is its use. You can create different structures by doing although customization is possible. You don't have to work from scratch. Me give you one more example. Imagine when you want to assemble a desktop. If you make a desktop, you will make a computer. Does this mean that you motherboard you will make the processor, you will make the graphic cards will not be made? All these are made in the market will be made based on your requirement. Do you want to play gaming or like us? Do editing or maybe day-to-day? What are your requirements for performing operations? According to that, you can choose similar data. We categorize the structure in this way. Let's do it if I first show you this tree. You can see we speak primitive and non-primitive. Who is primitive? Who is ready-made? Whose definition is programming language is already known to the computer by the compiler? So if you consider this issue now, you there is no need to tell the machine what to do. He knows, for example, in a particular compiler that if you say integer, then which two bytes to reserve in memory? Everything can store type data is predefined. Yes, but now link list these are files, these are graphs. Cannot be pre-made because there is a lot of customization in this, so these basic use of primitive data structures the complexion we create by doing to use yours. These are known as per requirement non-primitive. Yes, then primitive basic which are already defined, no need to make, no need to tell the compiler is not a computer program is already known, and non-primitive which we let's define now what I have written. See primitive data structures are those which have pre-defined ways of storing data by the system, and the set of operations that can be performed on these data are they also pre-defined? What is the definition and what operations can be performed? All of them are already pre-defined here. They are diet operated by the machine instruction machine instruction computer already knows how to work on them. It's again, it's character, it's plot, it's that. Everything is now integrated and then added. Subtraction can do all that. Understand now what is this non-primitive? So again, but there are certain situations that obviously will not be sufficient. So derived data structures that we that is non-primitive and using the definition to use definition primitive. Let's do whatever by using it complexion. We do weather Linklist. These are known as non-primitive now. Excuse me, I'm going three this basic. Why am I going through terminology? It is important to have a to clear basic understanding, go get it later. Please do any discussion in complicated. If someone's level is different, then it takes some time. I feel like I should be covering all these cases. If I am there, then all the examples are given here. Kind of non-primitive another difference I see you somewhere in books will get linear and non-linear. Now what? That's the linear order you understand. Will go one by one. I already have a difference arranged in points and kept in a linear data structure. Data elements are arranged in a linear order where every element is attached to the previous and the last one, next one. I say this in the simplest way possible. Linear meaning in a straight line, ahead of you one behind you, one behind you linear. What is non-linear variable data are attached in a radical fashion? For example, look at the last point is array, is list, is queue, is stack. One in front of you, one behind you, one in front of you. There is a tree behind you if you are linear. Graphs have multiple children of a node. No one knows how much can be seen in the graph. How much can be the out-degree in-degree? Both of them became non-linear and became single. Level will be the height measure of any linklist. Does it work, or will you get it at the same level, sir? But this obviously there are multiple levels evolved. Their implementation will be easy to understand. Explain and implement here, obviously a little complication is coming and traverse traversal. Now, for example, when we let's talk about LinkList or Array? If you do, then nobody is going to ask you that. Everyone knows how to traverse a linklist. First note then next note then next note then next note. Yes. But if we talk about Tree that if we read further, then we will also see the code. We have three traversal orders inside the tree. You can pre-order these. Can post-order because non- if it is linear then there will be multiple options or graph b aa d aa a star and you know very all the variations can be there, so this a basic understanding. I hope you understand it may have come linear and non-linear; anyone may ask? You can answer. And yes, homogeneous heterogeneous. By the way, if you care, it's terms fundamentally us in chemistry read homogeneous Trojas idea butt still what is homogeneous, what is heterogeneous means same type and data structure like array is for example. The simplest case is that of an array where any number of data arrays, for example, int because can you have that I have four inti jars, five floats, four characters is like this. Not all the details you will get then it is none as homogeneous so where same type of data ho saare all hetero genius ware. You can have mixes, for example, structure. Now if a node of the linked list is if you look carefully, here you will find example ek integer jar mil sakta and you can have a pointer neither are structures r the very simple example of hetero genius. So hetero genius different variety very simple understanding. Homogeneous same type. The definitions of both are written word by word. You will write very well in the exam. OK. Now finally, I think the basic introduction is done, and now we're ready for our first data structure, which is array, so let's go now. Let's talk about array in its most basic form. Is the most fundamental data structure and is called you will understand best because if you understand. Now let's say one of the stack and q if a good healthy framework is ours, then let's start with a joke now. I know no, this has been done by.
Someone you know. Janan is internal. Second computer. Programming is a paper and subject is whatever it is. Question is defined array. Child writes an array is used to call a boy and a person who is at a distance far away from us who are visible to our naked eye. For example, Hey Rupesh, as they call me. No, hey listen brother, hey write like this, then this. Write the definition, I don't know that. Doesn't this make any sense at all? Very smart, but the answer is well written. I also want to write it very well defined, and this is the quality that you and we, I have learned, you are learning right now, whether most people get the answer or not, it is different. It's a matter but 40 numbers have 100 numbers and 40. A complete copy of the page has to come, the rest is up to you. If you have come this far, then whatever your oh worthless friend, tag me in this comment. Please write, I want to see how many people I am calling someone else to come and take a look. You will not learn anything, now continue this idea.
The simplest argument we have talked about earlier. If there is one by one, one by one in memory back to back in a single sequence, we keep arranging in a continuous manner. Type of data: One integer, all integers. If one float then all float, then this data structure will be called array, we are saying. Wasn't it the data structure of the computer? How things are arranged in memory. So think about the most common sense idea. This must have been the case, not one after the other. Keep trying and see what is written here. An array is a data structure that stores a collection of elements of the same type, very important, stored at constant memory locations, very very important, and can access using an index. Now this index, what is to come is very important. So here you can see who are the elements: 2, 8, 7, 6, and 0. When we talk about counting, I will do it, I will tell you first. Who is the element sir? This is element number one. This is element number two, element number 2, 3, 4. It is written like this: Index means numbering. Na numbering is not natural numbering. You can do any numbering in CSIT. We always turn on default numbering from zero, so its index is that index row. If you want, now I'll talk further. We can change it if we want, but the default in case any data structure is usually we start from row, so index zero, index one, index two, index three, end index four. And whenever accessed, we will not say which is the fourth element. We will say which element is at the third index. This index is ours. Big important role in the long run.
Let's play how to declare if. Let me talk about something simple. First of all, tell what is the data type. Whatever name you want to give the array and whatever size is inside the square brackets. For example, here is an integer type array we are declaring the name of the array. For example, we put my array and then you can. I want the five elements? So imagine computer in default case. What will do is declare an array and indexing starts from row in default case. There will be 0, 1, 2, 3, and 4, total five elements. Yes, it will go from row to four, let me go to two. Bytes of space for every location will reserve one or two things that are important can be written in C language whenever we. If you declare then default there. If value is garbage then it is not so. He goes and clears it, isn't it undefined? And we already keep the gauge value inside it. Although you can change it later if you want. Can do if we start this. Obviously there will be change, but if we use Java, if we talk about it, then there is someone in Java. Default values are usually for integer suppose it is row boolean value. If yes, then usually they give false likes. This is yes and obvious, you can change it later. Only now I can declare if I want to start. Doing is like telling the computer that this kind of thing we have to create structure, it is called. Tell me the schema, now what value should be kept in it? When you keep value, it is called inish. Do it like you see here. Data Type Array Name Array Size. All these something basically declared initialism colon 1 2 3 4 5. Key five elements are going to be here if you. If I am doing this then declare. Even if you don't tell me the size, let me talk about c. It will work because after seeing it he understands that it is ok. You are declaring five elements initially. So from Roe to Lake Four Index by itself. He will go and write the same thing below here. I am there sir, once I have started then. Can the value be changed at all? You can change if there is no problem. Where you can see is saying array of two now. Please note that this is a count and not an index. This index is 0, 1, 2, 3, and 4, so two but no. Must have been an element already like ours. There was probably three in the case and he is asking for change. What to do -1 then value here. It will be -1, neither assignment nor equal. If there is two, then the moment is always from where to where? If it is right to left then assign it like this. Now can zero in fourth index four. If you want to do then again index four means last. If the element is raised there and reduced to zero. Declaring in case of array is initial do and even after initialization if we. I want to change, I want to change all this. Things are very simple, so many basics.
After understanding now if two or four advantages. Understand what are the advantages of array. Because of what I had already explained? Is a data structure good or bad? If you think it will be wrong, it depends on the hour. The requirement that we have is it suiting him or not? First pay attention to where you will shoot. Efficient Storage and Retrievable Array Store. Storage is not space, it is waste. Not storing any pointer back. Storing to back and also retrieve value. If it is very fast then you can say like this. Wherever there is historical data, right? There is not much modification in it. Use array there, what is random access? What we are saying is that if within if. If you want to access 100 locations then. First everyone has to access 1, 2, 3, 4. No, we will derive the formula further. If you want to know the base address of any array and if you know the size of each element, you can directly access any element. Can do very fast, can do very fast. Fast will be easy to sort and search. Obviously sorting if you want to move ahead. All the sorting algorithms we will see. You will read what you know not in this video. Where will you study with single shot algorithm? I am always using array there. Are flexible. Now flexible is such a disadvantage. Here in that point of view in flexible not writing that inside the array is flexible but by modifying the array itself. We are defining you know stack or queue. If there are, then in that case we are saying a kind of. Has a base case which is flexible and has some. Modify the rules then it starts behaving like a stack and a queue like this. And then easy to use, easy to use, easy to understand, that too is kind of an advantage. Yes, that's our first idea. What is the problem? The problem is the biggest. Is it a fixed size or is it not flexible? Understand the meaning of fixed size whenever an array like. If I use C language for example. Let me talk whenever you declare an error. At the same time I have to tell you how much space is needed for historical data now? It's okay, I already know someone. I am talking about history, so much data. It seems if I face a new problem. If I am defining then how do I know? Imagine, we will start a new batch. Are doing for gate 2025 imagine yes. Now I have to declare an array where I want to store the name of each student. Do I know how many students are coming in advance? Now this is a problem, I guess I have declared it here from my heart. Off size 1000 for example now if later. If 900 students come then the remaining 100 space is that kind of waste because. The operating system gave you an error. Sir, I declared it and gave it with Rs 1000 in it. If there are locations then the last space is wasted. And in the language of operating systems we have yes. Talk about this in detail in this video. What do we call it in we call it internal fragmentation. That is internal to you because that's what the operating system is saying, my brother. I just give it to you I am done, what is the problem, we thought. 1000 but later found out 5000 students came here now am I in run time I can increase its space, I can't increase it. Because sometimes what happens is our demand. If continuous space is available then it is but. There may be some data loaded after this. This is not your house, you have to increase the space in your house. You also have money available in the world. But there is a house in the neighborhood, so if you four. Any other plot except you know plot. Neighbors will take it, there is no benefit to him. Space is already occupied so that is known. Edge is external fragmentation space but. Still unable to allocate because constraints. If not then it is because of the flexibility of the array. We always have such issues. Is insert delete any build in support? No, you will have to manage by yourself. Imagine so much data and in between. If I delete something then I. I have to give each other element one step at a time. Do I have to swap or should I insert it somewhere? If so, each of the following elements is required, one each. I have to take a step forward so that I can. I can make space for such a major. There are problems when we talk about homogenous. I can't be versatile enough. Store me data about all the books. Now I have to become a character in the name of the book. Cost may be a floating point. You know B in integer jar on different number of pages. I can't hold on like that. Then I have to declare multiple arrays. If it falls then there is a problem. Performance again I have already told. There are certain cases where good work. If he doesn't do it then tell me the conclusion, I am fine. It's not a matter of what's bad, what's good, what's bad. It's a matter of application, there are certain cases. Where there is nothing better than this and there is no end. Certain cases where this work is very bad. Will it do some memory management work? Data representation data management implementation and caching. U can go one by one all this in additional slide. That's why I keep watching it many times am in semesters word by word questions. Asking write down the application of n. Hey, so this is the context read a little. If we go and make an addition then we will get one out of five. You will definitely get number 42. Understanding I think already. We have start a conversation on discuss now. Index and the index is great fun because we. They always think that things are not counted. It starts from forest but we cry in CSID. If we start with then very good Pisces. Let's go if I can see something. Thought I'd share the look at the with you too. The first one she says we need to talk to and when. If someone tells you that this is how you know. Especially the pale friend that we need to talk to. This doesn't mean anything very happy. Must be serious about it. Now you seems too have more time for your computer than me. I want to know how important I am to you. It seems that you spend more time with yourself than me. You are spending time with computer and today. In case you can call me tell me what I want in your life. I am important, now the boy thinks for a minute. But what are you saying if he is from CSID? Is you are number one in my life. Your priority is number one, that's all. Had to say that the person in front melted and. The matter is sorted and look at this worthless me. Just that I start thinking counting from zero because we are from zero let's start counting so if you are the number one. It means basically you're at number two. I understand, like this, there are three ideas. In default case we say zero base indexing which is our priority choice which is our default choice if something. If you don't speak then we will always start from zero. If you want, you can do indexing from one. You can start and if you absolutely know. Whether I am Ariel or someone of mine. I have a specific requirement from 72. I don't want to start counting. No why happens in some programs. Na context hota hai let me say 72 is the date of birth something like this to me. By looking you will know from any base. Indexing can be started in all cases. It's loud, see what Age A is saying. Father my job is to respect my sons. Opinion is very progressive advance father. It seems that even the child's advice is important and the child says something. I want to say, father is asking, yes. My dear son, tell me what did the child say? Starts at One Array Starts at One. And look at this bang that everything is tolerated. B can't bear this much, see this. Here the teacher asked questions on the board. Hai 5 my ff mine, how big a worthless person would be? Think 5-5, can't turn back. Looking at your friend that 5 - 5. What is yes and he is not writing zero? He is saying where it starts, what does it mean? This is CSIT class 5 - 5 0 ho yeh. Zero is there whether you know it or not. Not necessary but indexing the array. This brother starts from zero. Knew yes brother, you are solid and now. Look at the last one, it's the funniest one, don't you? Shoot I am a programmer yes and that check how are doing it is saying start at Forest and so many things, these people also know this. So non CSIT people are army people. But we also know this much, Hey Starts At zero, these two, three, four are just for fun. After all, I don't think there is any confusion in this anymore. Remember it should not happen in the default case. The indexing of the array starts from zero. Now is sometimes big in counting. If problem arises then I will discuss this matter separately. Although I write how many inside the array. The element is simple but how to calculate. Will indexing 0 1 2 3 4 5 6 7 a end. If we have to default like nine then which. The first index is terminology also sometimes. The first index is important. This is where the game starts. What do you say about the lower bound of the array? Are the lower bound and which is the last index. As far as we go we call it upper bound. Lower Bound Upper Bound. So what I'm saying total number of elements kitne kaisa. Find upper bound minus lower bound + 1 +. And is very important you will feel better. If you do bound minus lower bound then difference. Come so here sir upper bound is not lower bound is 0 and pw so 9 - 0 is 9 and pw total. There are 10 elements, yes and no, from one to naan. Till and this the formula will always work irrespective of. The fact that you started indexing from zero did it start with one or started with n. Just to give this context if. What would have happened if I had started from one, it is. Like 1 2 3 4 5 6 7 8 9 and 10 yes and me. Was talking about 72, start from random 72 let's do it. 72 73 74 75 76 77 78 79 & 80 & 81. Now you see if I'm this one. If I start from, the upper bound will be 10. 10 - 1 because first lower bound is our one + 1. So that's 9 + 1 again you see total element. How much did 10 come from 72? No confusion. Where did you go from 81 to. So late U C 81 - 72 + 1. Again it turns out to be 9 + 1 which is nothing but 10. So this formula is for age. Number of elements are always a concern. Will give perfect answer and as soon as it happens you will. Looks like there is some formula for this too sir. You will make your own mistakes in a hurry. If it happens then remember this especially. Multi Dimension Arrays which we will talk about later. So remember upper bound minus lower bound + 1. Simple talk. Now when you call number off. If elements are detected then size cannot be told. If I tell you here then suppose it element is of 4 bytes say what about array. If size is then number of elements is 10. And each element is of 4 bytes long so. Obviously the size of the array is going to be 4040 bytes yes so what is the size of. Array number of elements multiply by size off itch f am talking very simple. There is nothing strange, let's talk now. I am the most important and I am the most important. Like we will go for 2d 3d and even multi dimensions are but it is very important. Because simple and asked if my. Suppose we have an array for example. I will write down his name k right sorry a. And any element of it is which is at. Which index? Which index? Which index? We need his address identification. Which axis is very fast and random access. But how do you check it out here? Some things we should know beforehand. Formula is already written kind of. If you rival my base address then you will give me. Will tell from where the array starts. Basically from where it started in the memory. What is the number for example let me say that. This is our first sale. Starting from Rs 1200 we can make a case. Isn't it so suppose this is 1200 then weight off. If you have to tell each element size then value. Let's take for this case let me weigh in. Each element is 3 bytes normally will be 3 bytes. No, we are assuming that in the example k is. The index of element whose address we need. Want and lower bound and upper bound then that. So you know indexing as per your choice. This time we have done something else. I take random can I start from -3. Let's take a strange index so -3 -2 -1 0. And then 1 2 3 4 5. And 6. Then questions. What happened to an array whose indexing we did -3. Started from and where are we going -3 from. Did you do anything wrong? Yes -3 to 6. How much are you going and the base address? I have kept 1200, what is the size of each element? Three bytes tell you that index. What is the base address or address of number zero? Look at this, how will you use it? What is the formula sir what is the base address. Base address is 1200 plus what is the weight off each element now according to our part. That's three and now look at this this k - lower bound what is k sir k is 2 and. What is lower bound lower bound is -3. And - -3 is like + 3 so 2 + 3 is like 5. 5 * 3 E 15 and 15 + 1200 the answer is 1215 check. Do it, it is a very small case if it is 1200. It was on 1203, it was on 12006, it was on. This was at 1209, this was at 1200 and 12 and that. Is nothing but 1215 then calculation exactly. That's right, this is the component, look at this. If you disintegrate this a little, you can understand it. k my lower bound actually tells you that. How many elements are there before you? In our case 2 + 3 = 5 look count 1 2 3 4 5 yes. k my lower bun tells us. The first w tells how many elements are there. What is the size and weight of the element capital B? That is, the base tus tells from where the counting is done. I think it's very simple to start. The arrangement is one, so get it tattooed. It's simple, isn't it? It's a temporary thing to do. Don't make life so one dimensional. How to access the array using this formula. Will always help you if I ask you. You can try practice questions now. Ho you can pause the value let the base address. Of the first element of the array base address. Told me this is like 250. Each Element of the Array Occupied. So Weight I also came to know that it is the 3rd and the. Address of the fifth element in one dimension array is 10 now. The first thing that matters is the index. Didn't tell but that's in default case please. I can also accept the address of the fifth. What is Element of a One Dimension Array? He is saying that the fifth element is needed. Index five this is what the count is saying. The index is not telling, it is saying the address. Of the fifth element so if you fifth. If you are asking for the address of the element then basically. You are saying index four, you are imagining. Yes because the counting has started from row 0 1 2 3 4. So that was a trick question. What should be the value of k here? Then we will assume that the default row is so k is 4 - 0 so that is 250 and that will be 12 so answer is 262 is the address then this type of question is a. And you can try this is I think a Pascal kind of declaration where now. See from where to where the index was told -6. You know the base address is 4 bytes from +6 to. I think there should be no problem so base address sir is 3500 weight of each element is 4 bytes what. Is k is a specific location which we should be 0 so k is 0 and lower bound is -6. If you count from 6, tell me what is the answer? Hoga sir it is 3500 and this is four now this is six this will become 2 42 4 this is 3500 so the answer is 3524. So this kind of an idea isn't it. You will find such questions in university exams. Can expect in the semester. On a One Dimension Array. Now let's understand the idea of two dimension array. Like vdi can be 2d like a matrix. Everyone has studied in Maths so what is. A 2d where is our understanding. Is that is divided into two things rows end columns. Now some things I say that. Some things in studies, question of respect. Shouldn't be made, it's okay if he comes, he didn't come. It's okay, what difference does it make, but this. Making it a question of respect is a matter of some people. They get complete B.Tech in this matter. There is confusion as to what is column and what is row. Don't act like you have to remember me, not me. Know. But look at these vertical orientations are known as columns and this horizontal orientations are known as everyday isn't it. Another thing be so sure that if you know somewhere. Went shopping and what the salesman was asking. If you like what you like then not like this anymore. Brother, this one, you tell me, brother from the fourth row. Second column like this and his eyes. You will be shocked to hear that your son is from CSIT. Is yes and when removed from fourth row. The speaking index has started from zero. Index is four i.e. fifth row. I am doing so this is row and this is column. It is a two dimensional array, isn't it? When we do this. If you arrange data then this is known as a. There are many areas where. When there is bulk of data, organize it. There can't be a better way to do it than this. Now I thought what else should I look for? Now this day you see the number of soldiers coming. Think about the Republic Day parade we would have had. It's a very good example of that, isn't it? Is a 2d array not a single line. The parade is like a two dimension here we are. Are parading how do you declare and. Inish is it so look at this again here you. First we will tell you what is the
Data type. Used to do, now will you tell me what is the name of the array? And now instead of telling the size only, you will tell me the size of both and keep the money. Who is always talked about first by default? Who are we talking about after that? First row of column and column so may be late is an array name, judge, display and disp data type integer. 2, 4 means two rows here. There are going to be four more columns here. In this way, you can also inish are bud brackets separated by comma and then further curly brackets, and even if you want, you write this row major in sequence. It works in order only; what is row? Top will be filled in case of major default to down, left to right, top left. I am sorry, should be said in reverse, left to right, top to down, left to right, top to down. First, the entire first row will be filled, and whatever is left will be filled. Will come in the next row, and this is a big there is a problem which we have to understand. What is the problem? 2D, 3D, we data structures in your understanding. You can think whatever you want, but the hares reality is in a computer memory, and computer memory is one dimension there. Data is arranged in 1D, so if you are you even imagining it this way? You have to understand that you have to define a formula, an idea using which data if you convert it into Vadi then this store. Now there will be two major ideas to do this here. But how you implemented the storage in you know one dimension memory? One idea, row major implementation. Now look at this; I think you understand the same approach. We also intend to declare we were talking about the 2D array you have. You know top left to right, top to down, left to right, top to down like this. When we arrange that is known as row major implementation and more here statically you can see first row first will be filled when first row is completed only. We're going for the second row, and when the second row will be complete because only we are going to the third row again like saying am left to right, top to down, left to right, top to down. Now that's how a row means what do you call order implementation in short? There are two major orders; this is an idea of I will also derive the formula, but let me tell you the other idea now. What is the other idea? Could think column major inst of left to right, top to down, can we go top to down and then left to right? Then look first notice, first store the entire first column. After that came the number of second column, and after that came the number of third column, and this is known as CMO, not Chief Medical Officer, column major order. Obviously, this is understandable for human psychology because we also read from left to right. Isn't this one always more suitable for us? It seems and we mostly use this also programming as if speaking. This is also the default idea in language, but there may be certain cases where this is a more logical thing to do, and here's one. Will derive formula like for Vadi did it, and this formula works for this. When it comes to direct numericals, both understand the formula of row major, column major. Then we'll understand what's the difference between them, how we can convert row measures to column major. A relationship is a trick, isn't it? Even if you don't understand, at least learn this by remembering it. But numerical comes and then one or two questions. If you try also then see what story will happen here. He is saying, tell me the address please. What does that mean? I am the row number, and j is a column number, let me take any random number. Suppose this is a random number suppose in column number i and j this one element is we have to find out if this cry stored by major. What will be its address in memory now? How to find out? Now you know the basics terminology already, base address, size, lower bound, upper bound. You know two or three things. I I can't tell because right now there are multiple if dimension is then now lower bound i I will say l1 which is the lower bound of the row. I would say u1 which is like upper bound off the row. Similarly, we can have l2 ch e is like lower bound of the columns, and then we will have u2 which is like upper bound of the this column is a good understanding one. You must have me and everything. I am already writing the definition now. Look carefully; the basic idea is the same. First of all, you must have a base address. Is there anything new in what we brought from ODI? We must also have the weight of the each element; we should know that too. Look now, if you want to see me, cry. So what will be my number in major first? What should you think that I cry? I am so many who have cried before me, please understand the cry I am in. I am not just cramming; I am trying to explain. I am doing this before I cry. How much is it, and I am in sir i and count. Where does it start from? If it starts from l1, how many people are there before me? Before me i - if l1 is row then this is i - l1. I have separately also defined is the number of roses before. So what does this factor tell about the whole equation? How many are there before us? Now before us! How many tears are there inside everyone? There are as many elements as there are columns. How can we remove the element and column? First learned upper bound minus lower bound -1 look at this u2 - l2 + 1 look at this u2 - l2 + 1. This will tell how many columns there are, so for example: In this case there are two rows above us. And each row has four columns so 2 * 4 gives us I understand that the eight elements are before us. So this is the first part of the equation. u2 - l2 + 1 * i - l1 look at this what is this telling this this this this this this good. I did not write by multiplying so you know this component tells us that before us total how many elements are there in a day, but let's talk now. The cry we are in is not over, is it? He is sitting first, not even before us. So there will be some elements so if I add column i i how many elements are there before me then j. Where does the counting start from? l2 so look at this j - l2 tells that before me how many elements are there and it will be obvious 3 so 4 * 2 = 8 and 8 + 3 = 11 this means 11 elements are before us and then again story simple. You can calculate the formula. You should think in exactly the same logic as column major. It will work if I put this in column major also. If I agree then we will have to see first. How many columns came first and then which column we how many elements are there before that? How many columns came first? Look at this sir if I I am in the jth column and you are counting from l2. If we start with j - l2 j - l2 tells us how many columns are there before and then again row? From where has the counting started? l1 from u to u1 then this factor tells that every how many elements are there in the column so now this time this is four and I'm sorry this is four and this is three hai na teen aa gaye na yes. So how much will it be? 12 and then we we are in the column, we are in the eighth row, before us how many elements are there so this is i - l1 because the counting has started from l1 and it your simple formula has been derived. Any time you can appear in the exam for column major. Explain can have or a number five simple numerical row measure or column of calculate the formula from major and tell me. Well, we will solve each question one by one. Let's see, but before you do this a little look at the analogy; it's exactly the same, what to do? How can you convert row measures into columns? Wherever two is written, write one wherever where 'two' is written, 'one' is written where 'w' is written. You can write 'two', 'two', 'one', 'two' ko one ko to two where i is written there is j write I where J is written and convert your row major to column major. I just have to make this little change. So I want to analyze like we did. Once you analyze, you will understand. Let me be very honest to you. You don't need to; you can write it at run time. Think for a minute and ask two or four questions wisely. If you solve it you will also remember it. Now solve the question on this see what I know, I do. Second you can try now see this one told me from to 15 and from one to 10 its meaning what is this this is l1 this is u1 this is a2 is y2 so you can imagine like this. I almost cry before you tell me the pass is for 15 days, numbered from one to it has gone till 15. It started from one. To make the thing simple and we have 10 columns which goes from one to 10, so the total is 10. We have very good columns, and we should proceed further. The weight of each element is then here my got the value of w sir no problem if the size if the base address of the array is 1500 so i think i get the value of capital b. I got determine the location of the well 12 9 so I think I also get i and j i got that too. So we can put the value what is base address sir base address is 1500 weight of each element is 4 bytes now what is u2 - l2 + 1 look at this u2 - l2 so 10 - 1 + 1 again 10 what is i - l1 i is 12 and l1 is 1 so 12 - 1 is going to be 11 and what is j - l2 now j is 9 and l2 this also if it starts with one then 9 - 1 is going to two b 8 so this is going to be 110 and this is + 8 so this is 100 18 yes this is 118 yes and that is multiplied by 4 so 118 multiply by 4 so this is going to b 32 and this is 7 and this is 4 472. If I sum here then the answer is 1972. So this is the address using the row major order. You can repeat the same calculation the formula we have is using the column measure. One more thing brother, don't solve this in advance. If I am keeping any calculation even if something goes wrong, it's okay, please forgive me. Dena baaki toh u get the major idea ok. Now a three dimension they don't know much. People get very scared if 2d understanding is clear and the point is clear. So you can try your hand at 3D also. How to observe so I think this everyone must have seen the Rubik's Cube. It's a very good example of a 3D array. Do-Teen Baat notice here that while we are in the 2d array there used to be conversation in row columns, row columns. And that's a standard terminology g 3d here's the standard terminology for arrays. There is no height and length breath, how to observe? Do something like a corner of a room? This is how you can see to be honest nobody know who I make a row and whom I make a column. There is no standard terminology. What is better than u dimension one dimension? One dimension second dimension third dimension and each dimension has its own upper bound lower how do you define an array if you have bounds? UC is an array which has three dimensions so I'll say this is dimension number one this is dimension number two dimension number three. Dimension number one is like go from l1 to u1 here is the dimension number so you can see it is going from l2 to u2 and dimension number this is going from l3 to u3 now how to solve. Let me try and memorize it; you can do it. The formula is written in front of you. Imagine. Let's see what happens if I assume here. I am somewhere; now you have to think first what is the idea of storage? So the idea is this. Can I call it a plane? Do I call it a plane? First this entire plane will fill the first level say level, say plain, then second level. After filling, you will reach the third level. If you believe this then we will get the formula. If we want to remove it then what will we have to do? This is my plane; I call it i I am calling, I am calling now this is i and I should say this is like eh suppose this plane is plane number zero number one is plane number two is if I I am on plane number two so see me first will have to plane number one and total in one and one how many elements have come, now this factor the base address represents that. Do you know why I wrote it here? I missed a thing and multiplied here. Bye w obviously I have to write now i - l1 tell me which plane I'm on and look at the remaining two dimensions puri puri u2 - l2 + 1 total suppose this would be telling how many rows are there inside a plane and u3 - l3 + 1 this must be telling inside a plane how many columns are there for example in this particular case yeh bhi three hai yeh bhi three so nine and my number came on a plane. Because it is two and if you go from bottom to top then it is 9 * 2 is 18 i.e. 18 elements have arrived. That's why we came here on the plane below. One understanding now that you have come here you will have to see it in 2D so now I cry and I can think like a column, imagine this is how it is stored to define you. Yes, if it is stored this way then we know this old formula where we are j - l2 for example if a j - l2 and then for example if I let's start from here j = 0 j = 1 end j = 2 so j - l2 basically we have a if complete row has come then this value will be 1 and then the second dimension starts from zero. If it goes to 2 then 2 + 1 will become 3 then this there will be three basically three elements which we came before us at level and here k - l1 so you can imagine this is like k0 and k1 and k2 and if i is on k1 then k1 - 0 is like and an element came before me 18 three elements had already arrived in my level. If you come before my cry and I have one 18 + 3 + 1 so that is 22 elements multiply by the weight of each element before me do base address you can have and if you understand this idea dimension by dimension na because no longer by row column calling to look at this idea of and if you are worried about dimension then look at this I have one dimension till n dimension I am going to each dimension my own index is how to write formula the first dimension i which is the index of the object via works on the first dimension and rest full dimension full full so l2 - u2 + 1 u2 - sorry u2 - l2 + 1 u3 - l3 + 1 blah blah blah blah blah last till the end go AD's image cannot be clear because you definitely can't visualize it. Can solve one dimension, next will be solved pe come here now 2 j and l2 come to us so the whole next end will go on one by one it will happen like it was happening there and last let the index of working on dimension so x - ln8 is before us and the size of the element is plus the base address like this you can derive an this is a question that I have completed. Let's see if this is for the semester itself. Question is an example; I raised a hypothesis. Multi dimension array q declared as this so it is understood sir clear cut that it's a 3d array and if we talk in terms of l1 u1 do so this is l1 this is u1 this is l2 this is u2 look, he himself did not cry and did the column definition not used stored in a column major order now the difference with that it doesn't matter because I would have explained otherwise. Find the length of each dimension in q length if you can tell, you can see from one to 8. So how long is it sen 8 minus sorry how much is the total length 8 8 - 1 + 1 means total is late. 5 - 5 + 1 means total is late. Think this will be 11 and look at this minus if you do then there will never be confusion and then 5 - 10 + 1 so 5 - 10 will be 15 +. So we understood the length of these three 8 11 16 and then he is saying that you are effective calculate address so base address somewhere have you told me what base address you have given me? Base address is 400 of all three sir IJ's if there is value then can I say what is it? Is 3 - a1 is the same as l1 counting from one has he started - a1 ev and then u2 and u3 we have calculated so this is 11 and this is 16 plus j - l2 j is also 3 and a2 is like -5 so 3 - 5 is like minus minus plus is like 8 and multiply by the leftovers dimension 16 and the last one mine started from -10 and our number is 3 so 3 - -10 like 3 + 10 that becomes 13 this will solve completely and here also I am sorry I did that again here missed multiply by this copy and there is a problem of paste so if you multiply this is what is like what is like four then you get the idea so here a basic solid understanding of your clear from start to end I have tried but it is still not clear. One small point left, one small point ideas that spurs importantly in the semester have you asked many times what is matrix? Spurs matrix and understand it like this matrix whose content is mostly zero it happens that is a sparse matrix then what is the need to read this separately brother? The content has nothing to do with you. The point is if most of the content is zero especially in ideas like image processing etc. This happens and I explain it in a general way only. If I store it, it will take up too much space. Because I have to remember everything let me know that most places me there was no need to remember anything because it was zero. Could there be a smart approach? If I remember separately that some data at some places and whatever is left zero, I don't want to remember everything. For this kind of observation it will be necessary reading separately so a matrix is considered spurs if the large number of it elements are zero conversely in a matrix with most of the elements being non zero is termed as dense where most elements are zero that are sparse. Well, it's not an exact threshold. No one can say such percentage thoughts the process may be generic. If there are mostly zeros then spurs and most will be dense if not zero. Ok, now we understand these metrics. What advantage do you get from storing separately? You will get speed efficiency in computation will store in simple way because of speed then all n cross n suppose this is then only total space will be stored in a special way. If you do this then it will take less space and time too. It will cost less if you do the entire process quickly. If possible, here are two popular presentations but as far as your syllabus is concerned representation and linklist because two is the fundamental idea so how does look at this puri work? Just write the definition and explain the idea. At this matrix obviously it's a kind of a sparse matrix of mostly zeros so what do we do first row and column and then the value is declared three times. Will do and now you know the story. No need to tell these are the numbers and 0 1 2 3 4 these are column numbers so that's it we keep seeing that the address is given what is data? What is the first data? What is the row number? Row column number two row number row column number two the data is three, note this down separately. Now row number row column number four data is four row number row column number four data is four rewind very carefully if there is any problem then see this row number here one column number two row number one column number two data is five so like this if i separately store only the element and in addition if anyone then you ask me now sir second row what is in the fourth element of the second row? There is no entry in the fourth element. Meaning if there is zero like this then all the data we very little space can be held quickly. It would seem that we cannot imagine even in small cases. Imagine being able to do 1 cross 1024 crosses 1024 1000 * 1000 contains 10 lakh elements there are more spurs than that can hold directly in very less space. What could be another approach to this? It is the same; you hold it like a linklist. Here sir 01 2 3 01 2 3 4 then look at this and then that row number zero is speaking in a link ilish three parts of data, one part of pointer next note row number row column number to data is three row number row column number two data is three now look at this row number row column number four row number row column number four data is four so this way if you hold he if you have written the complete column value then that is a link less representation. I think now we are done with the array part so awesome I hope you understand the whole chapter. You must have understood and I hope whatever number it is 15 20 marks come in your semesters you will do this well, won't you? Are preparing for get net any competitive exam the basics are clear rest is different based on the exam set of problems you have to solve age far semesters are concerned that is more than sufficient okay so far friends we have talked about a lot of things very well. Understood from him took understanding from him got the idea but there are certain problems and as I said before, again I I am telling you just give the data structure. Here you have an array and you have a link. The rest of the list is just ideas, like a stack. Or why is it that we will observe further? Both ways to implement both can you implement a stack data structure with the help of an array and a link list you can implement queue with the help of array and a linked list are necessary first. That is, after the array, work on the linked list. If taken so that both are prospective it should be very clear in your mind, right? And then you will understand that you know why is that a you know like stack or those trees kind of modify is either array is either link list is ok now two three majors problems, although we have yet to overcome the disadvantages discussed but still reminding I have a big size problem again friend, please tell in advance if the size allocation is fixed. It remains to be seen what the size will be and once if you declared it then you cannot change it. Can and both problems are internal fragmentation external fragmentation igen it if I declared an error off size eight and I filled five six slots later if found then the remaining space is waste internal. Fragmentation I want to extend this maybe there is space in the system but it is continuous even if it is not in fashion, I can extend it too. I will not be able to give that is also a you understand that the problem is fixed. The problem of size is insufficient insert. Delete inefficient again you are somewhere in the middle if you want to insert then enter the number next to it. The element is to swap them all one step ahead. If you
want to delete? You will have to do take a step forward by swapping, which will take a lot of time to run. There is some trouble, isn't it? If this kind of data... Where are you working? If insert errors are occurring consistently, this creates a lot of problems for us. Gonna end flexible again. Very less. Like we will talk about linklist further. Will do it and at run time however you want. Modify and you will understand header link list, circular link list, circular header link list, double link list, double header circular link list. I don't know what even... whether it is trees or graphs, they are also one kind. If you look at the modified link list further, there's a lot of versatility that kind of... If I can't find it here, what will I do now? Understand linklist very carefully. Look at the link list, then accept it if you understand. Now I understand the data structure at age 50 to 60. I put a train because very good example I think of linklist. Now what is this? Look at this; this is a node. Consider this as a structure; two things here. Whatever its data is, it is, and there is a link; there is a pointer to the next node. Is it so? If you want to reach the next compartment? If it is, then it will have to reach the engine first. Only you can access; imagine that here. Pay attention. It's a good thing that no gate has been imposed on anyone. If yes, then you are going via engine only. Then again you see link is available from here. So the link has to be passed from one node to the next. Have to go through, and what is the advantage? Because non-contiguous case allocation would have been fun. So look at this example; its first... Understand the approach, then let's look forward to us. One node is the first node, and one is currently I. I accept that some people say this first. Some people will give head, and some will say something to someone else. You can call from pointer basically one. We need a pointer from which we can access this data. If you can access the structure, sir, please give me a link list. If you provide me, then I will give you something like a stomach. If you take a dog with you, there should be a chain and something in hand. So you have to hold on to it, or it will be lost. Similarly, its head is this pointer. You should have this pointer of head. If you touch it, it's as if the link list is gone now. You look continuous. The idea was to separate parts of the memory. I have some space available; use it. Want to do? How to remember? How to remember? Let me tell you which space is available. I am saying that brother, I will give you a space; I will deliver it; use it there; store some data and there... Holding the pointer that you want in memory, send it to some next space, and then there hold a pointer that leads somewhere else, pointing somewhere there, which is somewhere else. When you have nowhere to go, tap. It is his idea to keep the link list then. Same thing; it is not that excavation has been done and link... It is not that the list has come out; the idea is this: Using different different spaces, that non-continuous space allocation had to use and remember everyone's address. If it becomes difficult the first time, then one place... Memorized the address, and in every location, the next location where we hold the address. You can go ahead by following the points. And this is its simplified structure. Generally, we will call this as node where parts will be data parts which fold data. Want to do? And there will be a pointer to the next node, and using this idea, we can move forward by flowing one by one. The whole story is written in this first part; contain the information part; it could be int, jar, character, object; can be anything. And the second part is the link part and the next pointer part, which contains basically the address of the next node. Yes, so which major... There are disadvantages if I tell you. We resolve all major disadvantages here. Let's do it now. It's not like that; its... It's not your problem; it's yours. If there is a problem, let's discuss it. When will the link expire? The last node will contain a null value, isn't it? As I speak, the first pointer is called first. Start, speak, head, speak; that depends upon the implementation of how you beginning and how the story progresses. The implementation again is very simple. We can create a structure, so there is a structure node where we have data and one we have a pointer named... What type of pointer have we kept? Next. This is a self-reference data structure. Struct is a node and is a pointer of the same type. That means this pointer also points to another structure. That means it will be pointing to another node. Again, let that be very clear that here I will talk about the code bit by bit without... He will not enjoy it, but this video is not about you. I know you C programming; I am not teaching. So here is a reference link, Sarah, in the notes in the link to the video in... The code is another link where you will get the complete information. You will get the complete executable copy at no cost. If you are going to get it, then you can use it for practice. You can use it for practical exams or whatever it is, and the rest is ours, which is the second channel KG coding by Prashant sir; you go there and learn about technologies and programming language specifically. Can concentrate my major... Understanding is beyond the academic point of view. View OK. What are the advantages one by one? Dynamic size and memory efficient. Memory efficient memory usage; dynamic size means at run time whether any node many can be inserted or deleted easily. You need to think before sleeping. No wonder how much he will stand because I say I am standing somewhere; believe me later. What if we find a space somewhere here? Now change this pointer; will start point to this node, and this pointer will start point to this node. Done. Insert, delete a node; it's no big deal; just change this pointer and do a bypass surgery like heart trans bypass; look like this bypass here; done. It is very easy to delete, insert, acquire as much as you need. Whenever data is required at run time, type off. There will be no overflow, but it will definitely be symbolic. Maybe because think in linklist insert... When will overflow occur? When the system's memory itself... Kind off, the system should be empty now. What will you do if your memory is empty? I will do otherwise because like non-contiguous location is space anywhere in the system. If it happens, then we can use that space from there. You will find only one pointer; you will need a pointer. If you reach through, then all these are versatile; we got good... Like I just met you. Example was speaking; using this, you can use header linklist, circular, and different. You can use it in applications a little. Say you know strict form is linklist. Absolutely liberal form; there is space anywhere. Disadvantages can also be allocated. There is always a delay in computer science; trade off between time and space time. If you save space, it will go. If you save space, it will go. Now time will pass here; we kind of space saved and internal external tried to avoid fragmentation here. Now look, what is the problem? If you look at me, I have to go to the last node; tell me how to go? There is no way, sir; the address of the last node is second last near second last. The address is near the third last and so on and so for you must have the address of the first of the list and then you Trevor one traversing by one one by one till the last. Imagine you will be able to access only if you go. This is a link list which contains 100 crores notes which is the database of Aadhar card. Hold through the linklist; you have done it. Tell me, find this element and tell me. I will start traversing from the beginning; I'll keep doing it, I'll keep doing it, I'll keep doing it. Linklists are too slow, too slow, and time is such an important priority. It should happen, but again then where is the same thing? Use if data set is very large. If not, then the insert is getting deleted again and again. May we think linklist is a better choice because array won't work. Memory overhead is not a thing I can imagine that I am currently using a system and a phone with... Let me say 512gb. Talking about laptop, let me take 512 giga bat off. Hard disk and even 1 terabyte nowadays common is 500A with 12GB of secondary memory. Means 2 to the power 9 is 512 giga means 2 to the power of 30, so basically 2 to the power power 39. So every address will be of 39 bits long, thick, about 8 pounds, about 5. Byte is of 8 bits and byte na is of 5 bytes. Address is always there when we are made make butt address symbolically shorter. Sir, a considerable amount even in holding data may be wasted off space. Just integer and two byte address, we kept it on hold for five bytes, and this too... Do you know the disadvantages of a linklist? It should be that yes, this problem is created. If yes, then these are two-three ideas; the rest... When we work on these like a little on array, if you work on the linklist now, and you will have good clarity with time. Let's take a look at the university here. From exam point of view, I got a five Marx difference is also ready by making kind of... Have you done how memory allocation will work? Array needs constant size. Fixed, dynamic, growing at run time can also string can also... Insert delete is easy; why order of one? Just done our formula base address? Near is the weight of each element; tell the lower bound. K minus lower bound, how many elements from me first is the formula; direct has come out. There is no way; order of n one by one traversing one by one. We will have to go further then insert delete a lot. Shifting is difficult in case of array because will have to do sir to make full space. Here a new node can be easily inserted. Is again not an issue. Last one is memory efficiency is again the point of both. Good in terms of memory efficiency, yes, but there is no memory efficiency here. Aren't both the points in point location? If we look at it logically, then it is not efficient, but a pointer that is being wasted is a... There are different considerations, so this is a trade off. Now what we're going to do? Pseudo codes are more concentrated pay or c code pay basically late a c code ech. The code is executable and runs as... Will continue to do the same for your link list. Understanding will keep improving on linklist. If Thorat's clarity does not come, then here a little technical discussion is necessary. But again with a clarity that I am not going in depth; I am not teaching you C. I am not teaching python java, but the idea will be clear with a little code. If we keep looking at the components, so the header files you included are of this node. You have defined the structure of my thoughts. It's no big deal; we understand. The data is the pointer to the next node. Now create a node and do dynamic allocation. If everything is fine, then we assume that we have a new structure like this whose pointer and new node will come? Whose address is named new nut will be on the pointer; I am checking once. Nege of new node if new node is null, so it will hit then you write memory error and basically you exit after that. The chances are negligible because you will get space somewhere but still our duty is only Thorats but check should do overflow. Ok, now look here, what are you doing on pe two work says new put data in node whatever, for example: I had to keep the data. I wanted to keep the data. I will keep the name and data only, ok for now declared kiya na inish ii nahi kiya and the null pointer in new node c next. If you have created a new node, then you just have a tap. The pointer is created as a new node and return this new node obvious if any... If you attempt to insert into the linklist, it will quote will call this function create new node and from there a new node will be formed and will reach there. Now let's see the main function here. He has a node head end create new node a link start making a list basically and create. If 10 calls are made to the new node, what will happen? The node will return the data value inside is 10 and whose pointer is null and now head will point to it; it's in the head, isn't it? The value of the pointer to the new node is basically a node appears in the linklist, then what to say? There's a new one in the head's next again create a node and there you are again. A new node will be created with the value 20 and head's next which was tap till now is now on 20th will start pointing, sitting here and playing hey brother, watch the next one of the head's next. How can we observe this is head? This is head's next and head's next. If I have to create a new node again, this is like 30 and this pointer is headed here do not point here in the next next. This is like tap for and now you can... If you traverse then obviously 10 20 30 will print a small analysis and get it done. I am very confused about some people. Head gun becomes next and how do you accept any address of your own? Imagine this is 100, imagine that is 200 and that is say 300 because it is the next door address. So what would be written here? 200 would be written here. Sir, let me clear it up a bit here. 200 will be written; go ahead; this is the next one. Here is the note 300 must be written so like... For example, we did head; what is head? Head is 100; 100's next 100's next... What is written next to 100? It is written 200; now what are you saying? Whatever is new nod came you know here its in 200 wala. If you have to enter address then see this 200 one. The head started pointing here; what is the head? Is 100; what is 100's next? 200; what is 200 next? 300; wherever 300 is written, it has happened there; if you put the address there... If you enter address then basically this note, if you start pointing then this type of Ajman or this with kind understanding we move forward. Now look at these very basic operations; will do more work on linklist. Let's go; what's going on with this C style sudo? Traversing code and code you can linklist in very simple iterative fashion show it together in two or three cases. I am a b CD again with the same address analysis. Let me say 10 20 30 40. So here what would have been written here? 10 oh sorry. It will be written here that 20 is being taken to the next page, isn't it? Here it will be written 30, here it will be written 40, and obviously this will be null and head's value... What is the current value of head? 10. Now a node is pointing to the first note created current, declared current and I started it from the head and then see the current too. Whom will you point to, sir? Whom will you point to? Basically the value of current is 10. Check if there is no current tap. If there is no current tap, then what if there is no current tap? There are two things to do; see what the first one is. It is saying print the current data now. Look what is the current? The current is 10 current. If a is written on the data of data 10 then print a hoga is saying again that current is equal to current. Now look carefully what is next? Current. Current is 10; 10's next pay kya? It is written where 20 is written next to 10. Also current is current; what is the current 10? Where 10 is written there then write 20 then basically the current which till now was pointing to 10 is now... Who will the current point to? The current is on 20. Equal to current next then same thing. Is the current tapped? Is the current tapped? If you print data then B will be printed then it will be updated; it will be printed and then it will be updated. D will be printed and that will be all so basically what we're doing traversing a link list in a simple... If you can't do linear fashion then can't do anything and simply value printing look at this function. See what he is doing; also linklist traversing but look at this the beautiful thing it is doing with a ricker function. Now that makes the thing more interested. In general, someone in the beginning won't talk but must know if... Let me give you a little idea and show you my look at this function; name it traverse. I will obviously traverse; you will call starting pay or current pay and function call. If it is of single variable, then assume so. I called it a pay now obviously null. So if it's not then come out of this; what will you do? A will print the same analysis as the tree. Rikers catch to tree wala to print will do a and call the function nest again on A's next. Suppose on B is it null? It will not go; it will do the same thing again; it will print B&Again will call on the next pay of current. Current will print on the next page of current data call will be made on next pay of current so that will b c here c and call here on tap and as soon as you call on tap you will come will go out if you write a tap then what will print hoga print hoga a b c and null so that is how you can traverse a link list both iteratively and both recursively hai na and I think as we move forward no hurry no rush I am slowly understanding you. It must be getting clear and a little bit you will feel confident reading the written code. Writing code is a different matter. For now this is our point of view at all not that we write code but if the fundamentals if the code is written then it is a bit technical. There is a definition and it can be read. There is nothing very strange in that; see what are you doing? Right sea stalls for searching a key in linklist any value in iterative fashion. How to check ABC and CD in linklist? Here's the head again and let's check it out. I brought C value; see what to do. First of all then it became a current pointer. Well, also understand why the head is in front? Why are you not creating a new pointer? Sir, you cannot take your head with you. Linklist will be lost from our hands will never change this potting to first nf i will never be able to access. Then there will be problem; ok, let's move ahead. Now see what is happening to the IF current data is equal to what is the current data? Hai nahi mera ki toh si hai and a is certainly not equal to see ain't come out. Go to the next if current is equal to current. Current will move forward; similarly pointer update will continue to traverse like we were traversing earlier were printing earlier; now comparison will we do this time with the current data i.e. b e e c is no, not this time also come out go. Finally the current reaches node C and maybe current data is hitting here as if C and Ki is also C; what is C? Yes, yes, the match is done; so the match is done. Return current and then you exit. So basically I will return that pointer the pointer that will be pointing to a node in the node where our key is; see how many you can reverse this entire list in a simple way. And let's say you can do this with this loop. I came out and couldn't find you anywhere. Return null means basically that we searching any node link list I am not the one in whom that is coming. Yes, very basic observations. What are we doing here again? They see we're kind of doing the same thing but in a recurring manner. I did both all the fundamental operations done, right? Iteratively, recursively, iteratively, recursively tried it both ways so a b CD four points we have and again this time suppose we start the game from current. If current is equal to null then come out. If the data matches then return it. For example, let us assume that our that's C and we called the function search. Let us keep the name of the function on the note starting with A. We will come in the last what is he saying and we have to search C saying call again. If you do then call this time on the next page of the current. So suppose node B is called and search is done. Still have to do C that you point to B no, is there B.E.C. there? No, I will call again; this time on Seema C will match the current it is pointing to. What is there, should it match the key? The gate is matching yes and C. Return is late, little by little, simple will practice simple cases but now you also understand how beans work can be done iteratively and recursively then let's move on to what we are doing here for inserting a key at the beginning of the list start of a new node link list. How to insert a good observation in will be yours. For this this this this a head was told whose the address of the obviously linked list will be passed. Let me call it h and a key that lets us insert you will have to look at this old observation which insert a new node that you have learned before. Will make, declare, inila who has the key and its pointer? A pointer to the new node name and its address. Hold Karke Baitha Hai and that is nall. Now step number one: If you keep the data then whatever it is or we have to keep the data here for example according to the rules it should be kept in the new node. Let me write in the data, so here we... What will be the next point of the new node? Look at whomever the head is pointing at. This was the first note till date that was on tap. Now they will start referring to him as a brother and the put the new node inside the last is head. The value was what the head was pointing here. Here we will basically create a new node. Inserted in starting from now head go to this node and then we can traverse the entire list. So that's how very simple understanding we can insert a nut at the beginning of the list what to do remained have write a c stl pseudo code for inserting a node with a key after a location in a list. So again after some location how about if you insert then the location of the previous node we should already have if and null then how can you do nothing after that? Do if it is not null then look for a new node create and treat data. What if I say something like this? Case there's something like this let me say this that there is a previous node after which we have to insert have to see what happens with the new node next is the next node of the previous node. If this new node is the previous node next to the new node? Which is the next node of the previous node? Next tha new ka new node ka next will also point to that and then previous node why new node in next also remove the pointer to the previous node. New nut in next, here it is done. How simple is the bypass surgery done? Hey friend, two pointers have to be changed which is the new node? Will make his next associate here. It is important to do this first otherwise the link will break. And then the old pointer will now be you will change very carefully to do two things. New node is inserted in the order and yours is done. After location now what is doing delete a note from the beginning of the list to well it's that simple this is head head is equal to head next when the matter is over although this is a proper base case check will do let's see MT first there is no sorry link list MT. If there is MT then what will...
You do? I will. If it's not like that, then it's time.
Created a temporary pointer and added some code.
Will he do that work? I held it and kept what I was saying. Tha head ect head g next now head. Will point directly to the next node. And this little prop with no waste anywhere. Throw it and bring it back with care. Now free the person you are pointing at. So that it can be reused and linklist. Normally it starts from next note. Suppose we deleted the first note. If done, then insert from starting. Insert starting after a node. Deleting in and obviously what's next will also have to be deleted after any note. It's very easy, just imagine it yourself. Now you can slowly write some pseudo code. Suppose if this location is, let me say this. This is AOC, after which I will delete it, what will I do? After location location one has to be deleted. I will note down the location next. Put in next to next to location. Where did you write that the matter is over? Look after location, this is the base case. If location is null or next null of location. If yes, then there is no point in the process at all. Correctly written, created a temporary variable. Well, it is next to the previous node. Made it a temp. Yes, it's not like this. He doesn't leave it, he does it properly. Na see this is the next of the previous node. Eq to tam's next to this previous. Place it next to the node i.e., location. Next of this team, both ways are you team. Keep the next note or you can use the previous note. Keep the next next, it's the same thing. And pick up the person the tom is pointing at. I got free, so I used to do all this work. By doing this, an image slowly appears in our mind. Will it develop and will it be happening?
Linklist is so flexible! It's versatile, insert it whenever you want. Delete wherever you want, move back and forth as you want. And just hold us in the pointer a little bit. Children will have to be made to fear a little bit. It seems from the execution that we did not work on the pointer or the idea of programming seems a bit tough. That's why I'm confused, please explain. The game is very easy if you understand it.
Linklist. Oh my god, reversal of a linklist iteratively. I will run it step by step and show you. Because reversal is a very important thing. End recurse not known iteration. Questions can be asked in the exam. So you have a pointer called head now. See three pointers have been initialized here. Keep some data A B C & D carefully. See previous current and tap previous initiative. So this is a pointer named previous. I turned it into ice with current from the tap which is now pointing to the head i.e., first node ko and there is another one named may be next. Pointer with which the game was started again by tap. I start going inside the while loop hoon while current is not equal to no no. The current is not tap yet sir the game will go ahead. So what to do next, put the current in it. Next, look here, the current is now at point a. If he is doing it then who will he point to next? Inish ee he will go ahead. So Next points to the next node. Put previous next to current oh my. Previous in God. Current's Next Currently. What's next for Null Current here right now? If it is pointing then it has to be kept tap. So basically this tap is next to the current. If the value of PreviousPrevious is NULL then this also became null and then the previous one is equal to Current Previous Joe was sitting here watching. Brought him to Current, Current is equal To Next. Now all these things move forward one step at a time. The current has also come one step ahead. Current arrived next one iteration finished. Just checking again to see if the game is on tap. It's not gone, it's not taped, then do the same. If the next one goes one step ahead then the next one will come. Gone here, current, next, previous. Now point to the current nexus previous ones. And from here you will get reverse link list. Something like this current will be seen. Previous Fair Enough and Then Further in Next. If everyone comes forward one step at a time then love will come. Previous e equal to current so previous a. Will go near the current and the current is equal to Next current will go one step further again. You go, is it a current tap? It is not a current tap, sir. Then do the same thing, one step will go next. Next OK Current Next Previous. So Now Look At This. See Will Again Start Point Backward and current previous will go one step Further the previous will come closer to the current and the current will. I think last will go to next. Is we in iteration is null now not yet. If there is no tap then tell me what to do then same again talk current equal to current next equal to Next Eq to Current's Next To. What's next is basically our tap right now Previous so becomes next to current. This will start point backward and then. If both move forward one step at a time. The present past has come near the present and the current has also reached the tap and now you can. Check the final value is the current null. Yes, it's done, it's done, come out, head. If you put it in 'Previous' then it is 'Previous'. Currently late UC is pointing to D. A new head has been created and please check. How will the linklist work? Address of the first note. Who always tells? Head tells? Aaya D came to D's next to C's. Next in D is B's next in A and Late UC and AK next tap that too. Don't forget, the link has been reversed. The initial creation is a great code with three steps. The process is a one step updation and finally you have to change the head. How brilliantly a simple linear you are looking at the list here. What have you done, reverse it, very simple. And very straightforward implementation. Now What I Want That I have written the code, please try it. In homework because complete case little time. It will seem but the idea is the same sir what is it here? We are attempting a reversal of a simple linear linked list but in a you will see Rickers fashion here. Although it is not very strange. The whole game is here when in the neck of the head will call and say sorry in iterative fashion. Reverse linkedlist in recursive fashion. Will going forward ask such questions. Sometimes in GATE in competitive exams. Can be asked in semesters so give you. Have a link list with a code written in front of you. He is asking, please tell me what to do. Let's just try to explain that this. Don't be afraid it is solvable. The structure has been explained and the name of the function has been written. Saying rearrange it will do two pointers. Name of one has not been declared initially. Is named p one is named q and this is probably talking about the list and the next on the list. If so, its address is in the list. Is a temporary variable and here we declared that. Is temp list null or list ka? Next is null, sir, list is null, right? Next in the list is null because in both. If there is none then we have to move ahead i.e., if the link list was empty or the link list. If I had only one node then maybe rearrange there was no point in coming straight out. It's not like that now, go ahead, give it to me. Inila ization is seen taking place in the step. If you point to the list, you will be pointed. To one and q will point to the next in the list. Who Will Be Pointed Tutu Is It Now. Look what to do at this is while temp is equal to previous ka. The value is now a temporary variable in temp. The value of one previous value became one, right? Value of q in value of p in value of q. The value of is kept here to and then of q. There is a difference in the value of q and there is a difference in the value of q. Third variable use like one is back again. Let's swap two variables by doing p. Value kept here, value of q moved to p. Then put the value of p here OK and now. What is saying p = q's next p. Updated directly to next to q then p. Gone where was this and this is a. How do we read the ternary operator? Condition Is p holding Is yes p. Holding sir p is not null if p. If you are holding then first statement will run otherwise the second one runs after the assignment. For now, first will work, so put it in q. Put two p's in the next q. Next so q came here basically both. The pointer jumped forward and if the first. If you understand iteration, what will happen this time? Four here, three here, two again. Will jump now this is p this is q here. Six here, five will come again, both jump. Will do now this is p but q because null ho. If we go, I think we will come out of this loop. Because if q becomes null then how can it be rearranged? So basically pair by pair swap happened. Hai to 2 1 4 3 6 5 but sen apni place pe. As it will remain and that will become a very good. Questions for a competitive exam like Get Net. Something Like This Yes. So Too Fundamental idea and confidence that yes. If someone talks like this to us and. Because link list is a basic. If you have understanding then sir we are in the. Position to solve this is not strange. Go ahead if you want you can. You can have many cases made and kept. Try this case where what is saying let's try. See the following C function takes simply a. Modify linklist and input arguments. The List By Modified element to the front of the list. And not the modified Value is a list we have. A B C D What else the Four Elements We Have is saying. He is saying that if you want to bring the last one to the front then. Basically there are two things either tell in advance. Don't tell me in advance what the function is here. Yes, it is already being said here. What is the function and something or the other fills it in? Will make it blank or will it fill in. Blank case is the same, we also have four options. The last note front is already telling that it is nearby. I will come now how will I move to the front. The name is also correct and the structure is correct. Declared two pointer p and q head. Obviously pointing to the first node. Brother has not started P and Q yet go ahead what is saying p e q is inila to null and p is inila to head to p point. Will head and q is declared but inish. This has been done by tapping ok now look at. This while loop while peak is not next equal to null. While p's next is not equal to null why. Going to P's place and seeing you. P is going next so both values. Whatever it is, step by step. When both values are moving in the same manner. This loop will be completed till you can imagine what has happened will p will go one step forward q will come p ki place and until P's nexus is taken. Fard p will go one step forward q. Aayega p instead of fard p will go one step ahead q will come instead of p, do you want to go ahead of it? No p's next is not equal to null. Currently the next tap of p is stop here. So the code that we have run is this code had only one function because the last node. If you want to bring it forward then you have to hold it. Two pointers p and q are moved forward where pass is the address of the last node and q has. The address of the second last node is now three fields. There is a point in the blank, this also happens, right? Sometimes it's not just about surgery. It is also a matter of which order the operation was done. If you go, please notice, I will also read the option. What's the point of butt, head later. Will move, first of all we have to understand that this is the function of q. Next should be null because if it. This tap will go to node starting. Want and this point which is next to should point the head and head. If you want D then what did you do first? If I look at option y it says tap q. Make q of q which is pointing to q of put tap inside hey not put tap inside q. Hey brother, why do I have to put a tap in the next one? Leave this out. What is B saying about Q? Next we will keep the tap and put it in the head. The value head of p will go forward is wrong. I am in a hurry to get the next update first. Will have to do, let's put p in the head. Value I Think Will Make Sense Here. See the tap placed in q's neck, q's neck. Step by step now last node. Will connect first, look at p. Next P is D now P's next will be. Pointed to the head and. Now update, how will you update sir head? Put the value of p in head. If you give the value of p then who will get the point? Will the head point to D? Now what? Look, the linklist will start from the head. From D via A and then B and then C and. Then tap after C is technically D now. Not the Last D Bun or First Nut of the List and. That's How We Can Work Over It. Yes, this is the type of modification now you can do. Try Some of the Questions by Yourself This. This is also a good question, you can try. Ho and now let me discuss some of the modification. A popular modification is called header list. What is a header list now? Not to be confused, absolutely simple linear. The list is no change at all. What is the change here? But we put a special node called the header header node excuse me just have a special node. Called the header node and this header node is. Used for multiple purposes it may hold some. Meta data it may hold information like. How many notes are there in the total link list? Something like this so if i go a headed link. List is a variation of a standard link. List that includes a special node called the. Headed node at the beginning of the list header. Note does not store any actual data. Take whatever he's holding on to. It's Like an Engine. It doesn't seat real passengers but it. Serve as a fixed reference point and. Simplify the operation like insert delete at. The beginning of the list, that too later. You will understand that for example link list MT. Now I have to tap the tap. Implementation is a bit tricky. If there is a header node then consider starting from minimum. He will definitely point to the lower head. Not going anywhere even if there is no node. So those types of generic operations are. The header list simplifies the. Header node is always present. Even if the link list is empty. You will always find it in the next pointer. We will not have to keep tap actual data. Aayega Simplify operation does initial Lishan. End of the List Tavares Like This. Now Can I explain it to you code wise? Change will happen if header is equal to null then V Se Link List MT. Please Understand Here we are considering the first pointer. Start pointer that will point to the header. If the one next to the end head is a null then. We assume that the list is our tap. Will happen and late you come out if you come. So now see when you have to traverse the head. Will not traverse through the neck of the head. If you do then the temp starts from next to the head. Will do and then print sequence. If you want to traverse then first check temp. Data of this term, data of next term, data of term. Next, the traversal that we will do is. A new variable not starting with a header note. Will make a temp which. As much as we did in Ishizaki complete observation. Modified all the codes written so far. Can go for the header at least just pay attention. Nex Initiative to keep. It's that again here I haven't got the head yet. Suppose we have started only that is the. Address of the first no of the list but. Last node instead of containing null pointer. It Points Back to the First Nut of the List. So instead of tap if you again on first. That's how we understand circular is here! Link list go ahead if you. Will read the circular to understand. How to implement circular queue. Circular list is another good example. The good thing is what's inside it we are talking about हन नल नल नल. See programming language. To programming language null ka. Implementation can be very difficult. Sometimes. How Do We Implement Null. It's a Very Complexion needs a null point null somewhere. Not only how do you identify. If you go, this tap gives total independence. So that we can get advantage in these certain cases. If it goes then it is a variation circular. So single link list of list can be. Same data structure used to implement. What I was saying was why and circular. Because you will see it easily later on. Here we are able to implement. Traversal of the list requires a. Stopping condition true as iterative untouched. Pointer Note Again Using the Count to Limit the Number of Iterations and Avoiding the Infesting. Will not be able to go into the loop again and here. Look carefully at what changes need to be made. Leave aside temp equal to head and. We just have to look at. This is the first thing to keep in mind, there is no failure here. We used a do while loop and tried to come out. What is the condition from where you started? Temporary variable going forward head point. Was saying yes to the first end of the list when. Till now the temperature is not coming back to its head. Meaning we are moving forward and if again. The head has come first on the list so its. Meaning, you have traversed so come out. Here you are looking at me with the tap. Why did the circular not have to be compared? If so, then this is an advantage we get. And Now What You Can Do Logically to Understand It. Is more important if you ask now. Required that you give a short note. Write what in number four, number five. Is Now Circular Header Benefits of Both. So here I have a header. Note will also be yes and the last node will be no. Contain the null value it will point back to the. Header node I missed even the tap. I can also keep meta data. I can also handle such scenarios efficiently. I will be able to handle it well and it's late. Support code you can go through it and. Identification. The advantages of both are clear cut here. Can be used together and one after the other. Modification also and one idea also. Linklist What I Do Linklist As You A Major Problem with. Can See Linklist Sir, does he have only one direction? If I can traverse then this which. The problem is that the link list is relatively. Makes it very slow. Another issue is if you. If you observe carefully you will understand. The link list is quite unreliable, think about it. We are moving forward by doing this. God forbid if there is ever a pointer in between. If something goes wrong, can you proceed further? Sometimes you will be able to access the list, sometimes you won't. And what's sad is that I always. I am not talking about sadness, it is about great sadness. This is a very sad thing, sir, you also know this. It will not seem that data is lost if this. The pointer is invalid. You will find that the pointer is invalid. This means stop here and list till here. The link list was special if we were single. Observe from order it is very slow. Because you have to start from scratch falls will always traverse one way. And the dependence of the entire game is unreliable. A single pointer depends on a single pointer. If there is any confusion in between then complete linklist. Let's face it, there will be a mess again. Can't access now this problem. What is the way to manage you have both the. You see points on every note, it is late. Next pointer which will point to the. Next node and this will contain a null end. There is an end pointer which is also can traverse a linked list like. What is this disadvantage that you obviously have to. Have double points but what is the use when. You will start playing with points, right? You will enjoy it now because you. Linklist back and forth access. You can do anything sitting anywhere. Operation can be done insert delete is. Very easy can you tell me sir 20 node. Insert before I can 20. Insert after node I do I can delete this node, I can. I can delete before this. Any operation can be done as per your wish. Just You Know How to Play with the Pointer for Example. Imagine this is a pointer p p. Put the nexus of P into the nexus of the previous one. This is a Bypass P K Next K Previous. Put the previous of p in this is a bypass this. I sat on the page and deleted the page itself. Like this and drink the next one in the same way. The latter can be managed as desired. But again as far as writing a short note is. Concern I think you get the idea. Reliability is better, traversal is better. Insert Delete Are Much More Flex Possible. And can be done in any direction possible. What was the penalty? A little more points. Become sophisticated if the matter is crude. Then something will go wrong and the second you. Data will have to be stored double because here. To hold not one but two addresses on every note. So this is the idea and I am reading this. Again the supporting code is what I want. That you should go through it again and again. I am reminding you of whatever code is in this video. We are using its exact details. You will find understanding in the notes. Also link to separate executable copy. You will get the structure so you understand. We got the previous and next two. Node how are we declaring so v. Have a data and tap we're holding. If you want to talk about something important, now you tap a previous and. Next we are holding, we are working on that. Are able to do and in the beginning and ending. How can the address be held? All that observation we have traverses you. You can search in only one direction. The idea will be very simple, delete it. Starting delete at the ending see I am discussing everything in understanding. But I'm saying that I'm not very in. Whatever point you want to go to. You can observe simple list. In this we explained each code one by one and. Then what do we have what do we have is a. Delete by pointer. If we delete a pointer. So what I was saying behind that. Next page of previous location. Location's Next Location's Next Previous. Pay Location's Previous. This Thing We can do and these are some of the conclusions which. In an important way we bring. From whom the double link is last and here is. The Final Possible Idea Called The. Excuse I am the one with the circular double link list header. When you have a header and through the header you can. You can access the entire list now. Let us assume that all the advantages. If we read them all and merge them in one place. If you give that is header circular double link. List It Totally Depends on the Requirement and the environment. Which exam point will suit where. This is what I thought from an off view. Understanding we have that at any point. Notes of one or two numbers each on off view or. You can write point number five. Execution Wise If You Want To Go Into. You also have the depth code and you can use it. Can you work late is again a question if. You want you can try that question on. Double link list, isn't there some code? What will happen if you change but I am thinking. It's I Think Reversal of the Link Reversing list doubly linked list. So let's talk Polynote now. Representation using linklist then one very small very small. Understanding what is the logic that
If a polynote is very easy to understand the example which is like 3x to the power of 4 + 8x + 6x + 8. If we want something like this with the help of a link list, a different make a note of the style depending on the how many variables does the function require? How can we represent the function of look at this note now here we have three keep the components so we have a kit. That means 3 is 8 is 6 we have exponent. That is, what is the power of x and then obviously link to the next node so if you can do it one by one and see how. You can understand from the example so first power multiplication of th in case which that's three times the power of x gone into four. And that will be all link to the next nut. Now here you are seeing the power curve of x. There is no one who is directly related to x. Power to confit got 8 moved ahead. Next look 6x so here we have power of x and only ext means power of x and we have x's power and end here. What does it mean that the power of x is 0? Have at and row and null so like this also kafit can be represented. This is a good example for any Paulino. Look at this is the example in front of you where the function is of only one variable.
Function of two variables and three variables if possible then the structure is there too. A mutual discussion in advance understanding can be created for example our understanding here is better than most of us. Will keep no fixed structure later is and then a to the power of wa to the power of z power then imagine if the first term representative. If you want to do this then you will keep the coffee ant last. If x is to the power of two and y and h are not basically what is the power of both written as zero? Coffeefish will be placed last is the power of x the power of one wa is two and if it is not j then basically his power is zero coffee after all. If x is not x then power of x is 0 power of y is not 3 h then power row like this is what I think we can represent. It is a very simple idea and in this way any kind of case, any kind of idea very easily we can represent with the help of a link list. I hope that the idea is clear, a little logic maybe suppose if you want to represent paulino edition using a linked list so you again you can imagine a small case. Suppose I have 3x s + 2x pw dis is one Paulino mean and suppose someone else takes it I take 5x sp 1x + 3 now how to do this will represent again please write first can so 3 end to end then proceed. What is the limit here? 2 one's power and end give. Have a link go ahead and here's what's this is lock coefficient is one x to the power 0 and then v will have a null pointer representing this lo sir comfort is fx ka power to and der is a link coffee ant is one x's power and end there is a link cofish ant is three x's power 0 and then you have a null pointer right.
Adding now means people with same power. If you want to add then see here what we can means you can imagine a detail algorithm. I'm not going into detail but we are doing power match, both have same power. Yes same a pointer moving from here is a let me se its name is p let me se its name is q match the power of both of us. If we are having beans, then their coffee is if there is ant, we can add it, so basically I can modify any one or if we can create a new link then you can have an at and then two then moved forward here. If you see, the forest is coming and you will see here also so one is coming so you can go further both one is going to be you can again check two and three so obviously it will melt here and here. But if row is 0 then this can become four then that is 4 0 and null then what result will come that will be 8x s + 3x + 7 right which also comes. If you wanted directly then like this if that our polynote function is if it's already the form is represented in the link list. So how can we achieve both by applying one algorithm? Can represent, this was an idea and again I'm not going into details but at some places I saw that in the link list if this type of question is asked in the case then you can work over it now because of the link list a basic understanding is clear to us na and do which are actual data structures like I was telling you which era far as sorry array and linked list both of them.
Now we have an understanding of we are very ready for the stack and the q part yes now stack. So basic understanding I think everyone knows those who don't know now look at this this is a kind of idea that simulates the stack. Insert and delete will be done from the same end. So this is a kind of data item orientation insert you are doing from here if you want to delete then do it slowly. You understand it like this, if we in the case of restrictor the ab array then we they are saying, insert it somehow from nowhere. You can delete the array if give restrictor and from one side only if insert or delete is allowed then the one which data structure or the logic that will be developed that's no edge stack. I always say stack is linklist these are not like data structure these are the ideas now you how you implement them is different then you think about it in real life. Have you seen the stack anywhere? Now look at this. It could be tiffin essa or casserole sometime. Have you ever used it? Otherwise you will do it. So late in life if you are the last one reaching the box, isn't this the reason? Not the box directly but to remove it. The one above the one above the one above the one above first of all in this entire world who went in the stack, it was the one at the bottom. Look at this magazine will come up last. Below is the spring a transparent magazine now push up the bullet you see. So this bullet was the first the butt went in and the bullet came out last. It is coming so you are watching here also stack mechanism may be available at home sometime. Do you know what is called dry? If you need clothes then this is also a the kind of stack is where you put a cloth and cloth and cloth and cloth and the most will put the clothes out first and will be the last to take them out. If it comes then all the examples we have here what idea are all of them quoting? If we follow the idea of stack what if we read this a little more technically? I say look at this a stack is a non primitive obviously this is not primitive a non primitive linear data what is the advantage now because we have all this have you seen the basic basic terms? If you know what it means then stack is a nonce primitive linear data structure. It is a orders in which addition of a new data item and delete of already existify assume security or do nothing. Insert can also happen from here only and talking the stack terminology insert if you push while speaking, then push from here too. Hoga delete is called delete instead of delete. To pop, the pop will also happen from here, then when push and if the pup is done from only one side then we call that arrow stack will be calling yes and what is top of the stack?
Top of the stack is a pointer which will always point to the element which is at the top for example let's say this is like a b c d this current scenario is o or top of the stack who will it be pointing to? It is always point to d are some basic principles which you will gradually learn while doing things. Like I ask you, tell me in this stack d which element is below then you will say sir under d is correct i will say wrong speak we don't know where you are actually because there is only one element in the stack that is accessible. What is readable is what is at the top, below that what's underneath that we don't know? Top of the element is d which will come above d. Will come if I tell you pop it don't ask what to pop why it will be the same that I tell you a b cd write a b if you play the cd, don't tell me which one it is. Sir, do you want to tell me the bigger one or the smaller one? Because who will pop who is sitting at the top so you can't even pop c, b or a. I will pop the highest d only with you I would say insert a new element, don't do this ask where to insert, you already know. If yes then this will be inserted in the top of the stack are basic ideas the element which is added in the last will be to be removed from the first and the element which is inserted first will be last to be removed basic idea what two terms become last in why is fifo f like first out? First in and first out last and last out here is lifo or filo last in. First out or first and last out, these two I have already talked about the basic thing which the most accessible element of the stack will be will be the element that you find at the top of the stack. It is visible and who will be the least element? The one at the bottom is very basic understanding just this insert delete mechanism push pop you understand a little try case look at this blah blah blah blah blah blah blah blah from here the game has started, what is the first thing you say? Have to push 10 ok then have to push 20 very ok then he says I have to pop now what to pop sir, whatever is on top will pop. 20 will be out then further i think push two back to back and do it so you have 10 and then you have 20 no problem then three pops back to back, now three pops if there are then I think 20 10 10 then after 20 20 will come then 10 will come then 10 will come stack kind of is empty then push 20 end then pop 20 pushed and same popped like this is asking you the sequence of if value is popped out then sequence is like 20 20 10 10 20 tried a small case this is the question asked in this semester, brother, just two. Get the idea that children are so basic there is understanding that there are no forest companies. This is how I did placements in etc. Let's see the question and ask it in simple case. Just to get the idea, now imagine if someone what does a non-csit person know? Is there clarity now from this question? I have understood the logic and where to use it. So now I quoted some examples express parsing it is very useful and detailed in parsing. Not going into bracket if four open the bracket is there will be four closing brackets or if you have a little understanding of oc wherever storage is used in pdf etc. Have to do views stack only then bracketing function call oh my god it's done very very important function call like this occurs if a function call is let me say as in function main he called f1 and f1 called f2 to give you context is a function cost me cost has to be calculated area is calculated on the basis of area let me direct on the basis of radius will you calculate the call first? Radius will be calculated on the basis of radius area will be calculated only then cost will go somewhere. If it is calculated then this is how you know the function. Call or activation record that is complete the mechanism is stack and it has very good support. If it does then the function call is totally handled. By stack undo feature is not controllable that story of controlling people and then syntax checking already if else I have already talked about matching, so this is something among all these important application stacks this is the most important sir pura execution hinges on this yes now implementation like I told you a little I said a while back that stack is not a data structure it's a philosophy it's an idea if this is the way things work anywhere come first and get what comes first the one that will come last will be processed or which that process came last and first. If it happens, don't get confused about its meaning. You're working like a stack now a idea can be what we call static implementation what is this where there is an array using an array we're behaving like a stack and the logic is the same that we have but when also insert delete we attempt anything if you excuse me, that's the index of the array. We will also extract them using program algorithm we will observe we will call this static implementation and because we have talked about arrays so which restrictions or which advantages the disadvantages that were there in the array were also on the stack. Will come one may look at this diem implementation like we just linked list didn't read in details but got the basic idea is that you implement an array a stack with the help of a link list suppose I say this is a link list and insert and delete will always be done from the beginning the list has to be inserted and that too at the beginning. Will have to be deleted from, that too starting from imagine, first the forest came and then the forest. After two came, then after two, three, now deleted. Who will be the first three because insert delete has to be done from the beginning itself. Understand it like this, no matter how you implement d with the help of an array and with the help of off a link list if insert delete both be it in the same end starting and ending then it's a stack if insert delete is done from different end insert from start delete from after or delete from start to insert since then it is a queue why don't you talk about yourself right now? Keep confined here yes so if we are talking about implementation, its algorithm it is important to ask the code in the exam. Can no doubt in this now code also if ideas become important then push once you will notice how it is done because it again what I told you in the beginning if you understand the idea then you understand the code also. Will come otherwise I will have to memorize the code again so I stack acquired value in default case due to this the index will be zero first then one then two then three and then four and five and let me say -1 -1 is like if if it's empty we'll take -1 push us is s stands for stack n is the size of the stack and went from zero to lake five here so how much is six top of the stack worth? Take a pointer that represents again oh what we call top of the stack for now, let's name it like this: a c to three if there is an element then which one is on top of the stack? Must be pointing to index number two currently its value is to and let us say x is the element we want to push push is it an operation? Step number one, what check? Will do if top of the stake is equal to n -1 see, whenever you want to push, you have to insert. Always have to check overflow, there is no space. It's like inserting an empty oath when you come, tell me if this stack is complete. If it was full then our top of the stack would be now I changed its name to op, which is now indexed. Pointing to number two if this is complete if it was full then guess whom you would have pointed to sir point to index number five in that case if it was completely filled, then at least check it. If top of the stack size is -1 i.e. that 6 -1 55 is equal to two is double equal to two it dozen means in assignment it's a comparison overflow exit come out for now no because right now top of the stack who are you pointing to? It's okay now. What to do is to do two things first the pointer will be taken up, will make space and then insert will c top of the stack is t = t + 1 so now tell whom will op start pointing now? This point will end index number three then insert element into top of stack what to do now, if it happens now then come out. Exit as simple as that's two-three things have to take care had to insert, first checked overflow. The overflow condition size is n but because I started indexing from zero. If I do then obviously I can go up to n-1 if I am already there then it's n overflow its pointer first incremented value insert key came out starting if we are talking about implementation array use the same idea to pop right now I'm crying I'm sorry this is to 3 4 okay, let's remove it completely. Where are we starting indexing? Zero se na yes so look at this 0 1 2 3 4 and 5 and obviously the base case we representing -1 to stack we have size we have which is n top of the stack let me take the same scenario a b c to top of the stack currently pointing to index number two and we have to delete i.e. pop have to do this whenever you pop and delete will pop into any data structure will we check whether the data is there or not? How to pop if empty top is equal to -1. Is it currently -1? For now, point to index number two. Still standing firm enough to delete so if it's like this then points to -1. It means it's an underflow if it's empty. What do you say underflow it's an underflow n exit but obviously underflow is not there so what from you now look here delete can't direct otherwise deleted why would anyone want data? What we are doing is first in a variable y if you are saving your returns then what to do? Save the value of stack top. What is written in stack top is written to c if it happened then it has gone into c kind of y now. Now there is no tension, top equal to top-1 and if top means top-1 then top index will point to number one now you return y who is holding here and then you exit some people may think this sir I didn't delete it, I just copied it. You have come to one page, see the best way to delete it. Ignoring someone is a good way to want to delete this from your life logic can be you know applied in multiple I will kill you by deleting the context do you just ignore it and forget it? If you forget, then you understand that you are a prisoner or a prisoner, yes, so is this. Observe the matter carefully here also I am showing you what can happen in emptiness have you got some garbage value? If you know, then deleting means leaving it out of consideration. Dena I'm treating it as mt tomorrow I need to insert something above this. I will insert it, no problem yes so this idea was pushed for implementation. If you write any pseudo code function of end pop started with you for now you can do the implementation here but I wrote a little code section. And this section will be linked to you later. You can also access it through if you want then the rest are in the notes. So everything is there so first of all if we if you are using it as an array then an array we declared that the structure will remain the same we have one array, whatever size it is. You tell us and we have a pointer a simple integer value you don't need a the pointer is actually a simple integer value. Which will define top of the stack and this a complete structure was formed which we named put the stack so that later whenever one the complete definition of stag has to be made by us. We already have this I obviously we are not going into the programming language but little understanding I am talking about stack structure etc. You have a basic understanding of other wise you know kg code which is our programming the channel is go to this there you will get it detailed understanding of every language you will get access to technology now how to do so I told you default in case we start indexing from zero so where is the initial from? Then do it from -1. Inish I made the value of stack top what did we do right now -1 we took the same pointer here we come, let's move forward, mt underflow. If there should be overflow function then look at whenever you want to delete this so first let's check if mt is there and how to know if mt is not there the value of stack top is -1 it means mt if yes then it will return true similarly both we have read if stack already if stack top is full then what will be the maximum size? -1 will be whatever the size is -1 n -1 basically these two implementations match our now we go to push already observe have done the first base case function I have already written this in full if that call happens. If you hold the value then I will print it I will come out with full stacks otherwise it will be a little while later it's a work of art, it's like a stack top. Also value is let me se to in our case if the ++ 2 pre is incrementing then what will that be like three and stack off or we inserted the item in the array of three so the first pointer does two things. Increment then insert kind of did both the work in one step trying to smart off butt idea it's simple, similar thing, if we pop if you have to write exactly then how will you write? There, there, like, full check here. How to check mt on pay? How to check mt we know he will match -1 and will come out in another way. Now look here. Why post here because we work and save value first. What to do after return post decrement? Then whatever the value in a off top is first she will go for return and then we will reduce the value of top by one because if one pointer comes down then both we have the exact implementation and this is like the main function includes studio attached studio library we took took input output and did nothing? No need to write define max size 100 taken because static implementation you have to tell the size of the array first for now let's assume 100 as the main function one. Stack declared s initial is function call did and I left the rest blank in between gave you zero return in the end using dose as per the number of pushes or pops functions you can do the same idea if we implement stack wala from linked list see this idea in your semesters if you can ask then again I am defining this time I will write node, its name is because. The whole array is not the whole stack in node node there will be two things, one will be data and structure. Will be a pointer of type node which obviously pointing to another node so we made the declaration and then this just a pointer because the top of the stack is a the pointer will be one in the case of linklist. We have structured the top pointer separately. Made inish, how to stack top again? Fill in a pointer if i a I'm imagining the stack as a linked list. If it is empty now then who will be on top of the stack? Will point here 0 1 2 3 indexing so it will not happen in the case of link list. Basically will point to null and if mt is how to find out if inish is done or mt is done? And if the knot is pointing to the top tap then it's mt and here's what I thought I had. You have missed mt full wala full wala what could be better I'm sorry in case of linklist, consider it as full. No need because from
Non-country. There is no location, so there will never be overflow here. So overflow occurs only in case of stack, when the entire system overflows. If you have memory anywhere, then bring it and give it. If you give, then practically there is no need to check overflow if a stack is implemented using a linked list.
Now, how do you push? First, a new node, a new pointer node. We will have to declare using malloc. Declared. If new node is equal to null, which will not happen normally, you will not get any code. Node will be found only if there is space. So what if there is no overflow from this space? Now imagine this is a stack, which type is already implemented. This is a stack that currently contains a, b, c. a, b; let's see where the insert happens. So whatever data of the node, saying that you have created a new node, put item in. Let me write item, then node's. The next data item is placed on the top of the stack. Will point, let's say top, middle, point here. If he is doing it, then it will also start pointing here. And the top of the stack is new up top; it will point. Is it this? This is like insert in a linked list in the beginning of the list. So this is like insert this here. Push is saying delete, i.e., pop is also like this. If it has to happen, then now see how pop here will be selected again, playing with the points. Because you want to delete it, first check. MT. A temporary variable has become the top of the stack. We have it, node pointer top. I have pointed it out like this. Understand that a linked list is a basic tool. You will understand that in the next process. All these implementations should become very easy. Currently, the top is pointing to this, so see what it did was create a temporary pointer, temp; let me call it t only. These stack top will point to given and popped data, whatever the data is of temp, so keep it here. Pop data, in short, let me write pop data, which will take it out, have saved it. Stack top is equal to stack top ka next, now point here at the top. Next to stack top is top, whose points will be directly increased? Will start doing, will point to B. Yes, and then you free the data that temp has. Free the node and this data we have kept it, please return it. Basically, a return will be this kind of understanding and again last our main. I have just written the function so that the previous one is understanding that too. If you understand again, you see this implementation is also a bit difficult to understand. You can always go to the linked list part first, where I went into detail, discussed, then you can come back to it or go to our coding channel. Programming language extract a little more ease. If you understand the implementation, it will take some more time for you to understand this. Popular functions that I feel are important, I wrote down what I saw during the semester. Like reverse of a linked list, reverse of a, you know, string; no string we have. If you want to reverse, then just tell you the basic idea, length. You have defined a stack, declared a pointer. What to do if you keep pushing? Imagine if written inside the string, if A B C D is there, then what will be pushed first? A will come, B will come, C will come, D will come, put a loop, simple, and then pop the same again. Store the interesting thing, pop, what will happen pop? First, there will be D, then C, then B, then A hoga. To sir, stack automatic acts as a string reverser. That pushes, pop, just its reverse is like this. This is the main function that will work as observation. Are you right, hello word, original string? If you print after making reverse call, obviously that would be the reverse string, hello. If it gets printed instead of word, then this is some basic understanding of what is stack, push, pop, and the execution implementation in static way array and in dynamic way using a linked list, right? Sometimes I have seen in the semester, if direct code is asked, then you can go through that part, but the obs code part, optional, if you just want data, you can concentrate on structure, skip dos code part of entire video. Wherever inside I discuss the code part, if you want, you can skip it. Koi. The problem is not because the idea is important in the first place, letter whatever you are working on, programming language are C, C++, Java, using that you implement. If you can, then let's discuss further, sir. Let's increase, and this is a different kind of problem that I have had several semesters. If I have seen then what question observe? Do if the input sequence is 1 2 3 4 5 data identification. Isn't that fixed, what can be changed? When to pop, pop when you are supposed to. Now what is the question? 3 5 4 2 1 this pop, can I get a sequence? Let me try. This is for example now, obviously first what do I want? I want three. Can't reach direct three, one will come, two will come, three will come, and as soon as three comes, I'll pop it. Than what to me? If you want five, then don't give five directly. If I can get it, I will input four, then five will come and see this five's coming, will pop, and now you can see then four aa and then two will come, and then one will come, yes. So this is the idea; this means 110, but this which in option A we have p pass pop sequence, is this possible? Try B first. If you want what you want, then one will come and two will come. Popped again, if you want four, then three will come, four aayega, pop kia, and then pop kia five. If you want five, then pop it and then one. Now again it makes sense. Third, C wala. Let's try this and see how it will work. Four came, I am sorry four direct how come? I can come one, come two, come three, come four. Input sequence is same, 3 4 give me. If you want five, then five should come and pop gya. And then we have two and one, so ye. So this problem seems to be all possible. How will you create the first number five? I need something special, flexible in my hand. There is no such thing, because if you want the first number, I want five, so obviously I have 1 2 3 4 5. All inputs will have to be done by giving only five. Output is possible, five came, popped, four got three, but now you say that first you need one, then you need two, this is possible? No, here first two will come and then one will come. Now this is not possible. Cases can come, sometimes I have seen this sequence is reversed, so instead of saying 1 2 3 4 5, they will say 5 4 3 2 1. That's D, A, B, C possible, but D wala not possible, yes. Let's move ahead now, very important thing, notation. Now we can write any expression, basically moved to stack application. If you understand the basic understanding, how to write expressions and expressions, how to go from one notation to another. What are the stacks and how are they evaluated? There is a very important use of. Before we go to Rickers and all, so just pay attention to this. We have three types of notation to write any expression, obviously in fixed, prefix, and postfix. So if I have a basic idea, like we have an example, we are one talking about mathematical expressions. Now datchi will be in and operant one will be first, one will happen later. Basically, something happened. No, because this is the common sense idea which we always use in real life. This is what brother does, for example, 3 + 5. We never wrote + 35 or 35 p like this. It is written that this is the most popular, common sense, and you know, understandable approach which used in real life, but for now you may feel strange for a minute, but like this why are we doing it? What is its use? They'll see later, can there be an idea? Called prefix notation. Now what's this? The notation is that you write the operator first. Write the operator first, and then you write the operant, so this is like if you want a + b, what is meant to be written is that it means that a and the values of both B and B have to be added. But we are talking operator first, write then plus a and B. What will you write in this example? Plus 3 & F. Some people also call it Polish notation. I will tell you why I am speaking now. Let me tell you this, so this is a man of his, name is Jain Hanna, you read it yourself, so he wrote 1924. The notation was developed in. I was from Poland. So why it names it Polish notation and whether it is polished or prefixed. What could be the exact opposite post? Fix and what do you mean by this where? But we have something like a p, operators are operands and then operator is it is later. So if you want to write 3 + 5, then you it is written like this: Yes, now these three notations, maybe it's common sense between these two. What does computer have to do with it when also someone does calculations and solves? Obviously, we have a lot of expressions. If you write, the computer will also solve it. The computer understands all those expressions first, converts to postfix notation, and then only it solves. So here this topic becomes important for us. So you just go through this idea, ok, Polish notation calling prefix. Semester-wise remember the prefix, say if you are polishing, then what do you call postfix? Reverse Polish. Also called it Reverse Polished, so postfix notation is a type of notation which is most suitable for computer to calculate any expression. Now you will understand why this is after some time. After all, what is the most suitable computer? This is not looking good, sir, the computer is saying I feel good about this, why now? See, it's universally patented notation for designing alloy through the computer, i.e., that you know across the industry it's. If anyone can make alloy of standard arithmetic and logical unit is like this, where the expression is directed, it is not solved first. Reverse Polish in postfix notation, notation then we. Now let's solve any expression entered into the computer is what was written earlier. Let's convert them using the stack. Now let's solve where the stack comes from here. It is useful to explain the use of stack. Only by doing this we can convert these fixes into prefixes or can convert point to postfix. Number one and once when notation prefix or if you go to postfix, then use that track. Can be evaluated only by using. Now let me clear the work here. That work can be done with postfix, can also be done with the prefix, but hum don't do it because of computer most suitable idea is postfix exam point of view se bolu 99 par off the time de must ask and give in general ask questions on postfix, sometimes asked in prefix. If we can then give a good example will do with prefix also. Postfix is the important thing now this one. You have the expression, this is n expression, convert it both into prefix end post, convert in both. The whole idea will become clear to you one more time. Do not specify in most cases. You convert it using stack specification. If you don't do it, then first I will do it in a simple, common way, convert you and show you, then we will also use the method of stack. How to convert using specific hain? Yes. So now first I direct attempt. I have taken the expression a bit longer so that all possible cases are covered. So what to do? I have is I have a + b multiply c divide d and this is like power operator, yes, d power e power f and then multiply is bigger then not done d - c do a thing - till c I take it, I ignore it, yes. Let's assume there is this much expression right now. See what we have to do when we convert this. Let's start our first attempt. Will post obs for fix bado mass will run according to priority. Remember the words we use in maths? If you have an idea, you must start with the most high priority operators will start from that, and I'm not using the stack right now. If you are directing, then tell me about all these, who is the highest priority, sir, highest priority is power operator, but with priority we must also know associativity, like you see here power are neighbors of each other, such cases which is useful in associativeness? Tells whom to do first, then normally every operator is left to right, but this power, how is it associative? It's right or left, so tell me now. For example, if it is written 3 + 4 + 5, then this is left associative, first 3 + 4 solve will do p5 in the result that comes out will do, but if it is written 2 to the power 3 re to power 4, so obviously first 3 to power 4 will be solved which will give the result, ray to power that will go to power that is it is right to left associative, meaning it's not about memorizing, it's something mathematical understanding. Let's first power will be solved and the one with power will be first. If it is solved, then let me know when this part comes, will be solved, will be solved as if it will convert. So what will happen, tell me sir, it will happen e f end power, this is what had to be done right, sos postfix. If I am converting it into, I underline and write so that I lest I forget that this is so much in this part I have solved it and the rest I will go step by step so as not to rush anywhere, trying the first case due to confusion. Otherwise, I will write it underline only so that remember we have solved this. Now look here again this power, it will be solved, this is the first time it has to be solved. This is not solved yet. This is the left operant. This is the right operant. And here comes the operator, when so many parts if you convert then tell me what will happen, first operand is d, second operand is e power it, it's solved so I'll treat it as an operant and then comes this power, so now it will behave like a single unit, yes, and the remaining part a + b and then multiply c and then divide and then multiply and then - c. Here comes the power, it has been solved, who's next? Need division and multiplication, priority of both is same and both are left to right associated then which is left. If I solve it then when I I will start walking from the left, so there you see b star c, this will be solved in this step, I will do it if I have less space. Can I say this is what a star looks like had it come, I would have changed it and written it here. So let's assume that we have solved. Now that I have become a star, I underline assuming that solve it's done, now if you go left to right again the number is a multiple la a division but first let's do the division as to whose turn will come. What is the left operant for this division, sir, will be left operant bc1, what will be the right operant? Notice this will be d power power and then we have division and that's one idea what would happen here this and then multiply d - c. Look, we have solved the division also. Moving forward without any doubt or confusion. Now tell me what to do next. Hey sir, this star will solve if you allow me, should I solve this also or move on to the next step? I thought I would do it, so now when the next if you do it in steps then this will be the first operant and left operant, this is right. What will I do better than the star? Star d power is power then and division by second is d and their operator is multiply and now this will behave as a single unit soon don't do anything wicked in the game. If it is not given then I think it has been perfected. This is one thing, this is the second thing, operator came later and then a p and then - c next tell me the work, only two operators are left now plus and minus hai na and again both of them are left to right associative always first who will solve the left one first? If I solve it, tell me what comes first? Sir, first operant is this, second operant is this, the whole story is so this is like b c star and then f and then power power and then division and then d and then star and then I can have plus and then my say. Now again this thing is the first operant, this is the last operant and then you have operator then solve the last I take it, sir, so this is like this we have just a was solved in the last step. Yes, a. When solved, we found the first operant and the second operant came till d star and this plus it's here, it's going perfect, moving forward. So a s star d a power power and then division d star plus and now the second operant and the minus. Now here comes our sir. Now this is the postfix expression, so one all complexions are different kind of operator should come to us so that someone there should be no confusion and so step by step we converted it into postfix. Like we fixed post in every step, we can also prefix in every step. If it is there, then how will you notice the prefix? Do I write the same expression again? You need a little patience and if you if you understand the point immediately then you can skip a bit. You can move forward by doing lad. I don't advise that's because as I speak in general we don't expect but who knows when look where and what questions should be asked at this, this is the complete expression again. Let's start and as I speak if you do it in prefix this time then tell me out of this you know the power of which presidency is priority highest. But if the right is associative then the first number is aayega iska na sir ok so this is like operator ef good one more thing a wondrous sometimes I heard the thing that came to my mind some children say that sir, this if postfix came then its reverse would be lifted. If I write it, will it become a prefix? Sir, prefix is not reverse postfix or river of postfix. If there is no prefix then you have to solve it again there is no shortcut yes ok. So we have solved this many components and what remains is reman the complete expression as it is so a + b and then multiply division d and this thing and then multiply d - c yes next. This will be solved in steps again its operator who is the power so this time the operator has to come first. First operant is d and second operant is power e this is one idea a + b multiply c division and multiply - c is another idea yes I just think power is all solved. So whose number is next in multiplication? Division's again you bonfire me this I I directly replace this so this it's like a star because it will change. Because we have a little less space so let me change this and okay okay this is going to become star bc itna part aa gone, removed it from below and then moved ahead. Tell me whose number is next. So who is next? I think it belongs to this division and will come first. Operator this will come again first operator so this is star bc and then you will have the second operant so this is like power d power e and our entire part has been solved. Have we have a ps and we have multiply d I understood the complete component then proceed further. Tell me now there is just one multiply, right sir? So the first number will come so have this multiply so first operator gives complete first operant so division star bc power d power e end f this first operant aa multiply aa went and then we have the second operant and this one whole part is ours and now just two more the only thing left is one left plus one more left is minus ag next number of both priority is same and this is left associative should come first so a's so first you write the operator yes then you write the first operand which is an and then you write the second operant which is like star division star b c power d power e f and d and minus c this happened and now in the last place also before and even later because the priority is the same was subtraction will come last. So now the first thing you will see is minus and this thing now so this is a star division star b s and then power d power e f d and then minus so first operant and second operant the end operator came first so there is I have learned a lot about how to step by step fashion. Complexion used you can use the relatively simple in simple one exam just came you can convert any in fixed expression into postfix and prefix and i I am reminding again possibilities talked about question post if there is a fixed point then practice more beyond that. Now you have to do this, there is a way there may be chances of error in this na, I am still not telling you the method of steak. Now I am telling you a different method where I would advise you to go for a tree make and then using the same tree when you you will do its traversal further in the tree. We will go and read it specifically but I will use a little of the tree if preorder in order or post order if we do traversal then we get different different notations are given, what do you want to say? I will make this slide clear also I am now looking at this for this how to make a tree? How to make a tree? I also remove this minus because we if you did not consider before then solve it like this do it according to priority first what we solved we solved e power f na so you have something like this you have e and then you have f and in between what do we have in have power operator this much has been resolved, then the next one is this wale power ka tha so this will become the second operant and this d will become left operant this much part has been solved like it was solved before. We will still solve the tax in the same way, just make a tree. Giving is the next priority according to I think solved b star c what's this? So late you see you star and then you have b and see to maan let's take this also solved then what do we have now we division would have kept division I assume that this whole part is solved now that multiplication is finally done. Number will come so this is like multiply d this is how the whole thing ended. Next whose number is it? I think plus ka na so by now you have also seen the pattern in my opinion. You must have started to understand so this is like a plus this and then the final number will come last. Si ka so this i like this so like this see according to the bottom of fashion expression we have created the complete tree, now this what is the biggest advantage of the tree and see how it works if this tree only if we go for different traversals. Again we will get the notation a which is called t tree traversal does not come by will you go a little further to the tree component. Learn traversal in and come back here if someone else comes in advance then if there is no problem then now I can use all three of them. Which one does the traversal first? Am prefix I am not telling that I how am I doing I assume we if you understand then let's do it first pre three is preorder traversal in order traversal and post order traversal is done first so this is minus a star division star b c and then then then then power and then d and then power and then e and a and then you go you have a you have d e after a you have d and then you have c now this is the preorder traversal in let's order please do it in these orders have a and then plus and then you go and go you have be star see and then
You Have Division. And then you have d power e power f. Multiply d - c. Now to do this pattern. What is the best advantage of tree method? Will you fix these notations and you will see your Same expression should return and exactly the same expression is returned if Same expression returning means Our tree turned out to be absolutely perfect. If there is nothing wrong then cross check with this. Goes And Now We Can Have The Post Fixed Notation in which post order of corresponding tree Traversal will do so you have a and then b Star End Then D Power Power Division End Then d star and plus and c and minus. I Hope which we calculated earlier. Prefix and postfix matching this. If it happens then this is a must faster approach quickly for anyone's expression. Create a tree and postfix if you say post Do order traversal, prefix is called. So make pre order traversal this perfect. How will this approach work? There are more advantages especially look at this Kind of expression where unary Operators Have You Always Get Confused That How to convert to butt tree method. There will be no problem as l x is obvious. Factorial will be solved first in brackets. So let me have factorial and look at this x is what is written before the factorial. So x will become the left child and log The input operand of is x factorial. So this entire bracket will be made of log. Right child yes now of this tree when you Will do preorder traversal so this is Like l Fato x and post order traversal we will do so l x l something like this is going to come Which is nothing but the prefix notation And Which Is Nothing But The Post Fix Notation for this you can direct it anytime. You will read this but you will not understand the tree method. Say Always and Always You Can Answer Yes. So I Hope any expression now if Convert prefix to postfix So weather you want to do it directly and You Want to Do With the Help of a Tree You Can do now what is an idea you can Also do it with the help of stack right? So this is also an idea this is the What I Think Is Quiet Confusing confuses children. Still I put the full screenshot here I am you can take a screenshot and I left a screenshot of the solution. I have also brought this just to give an idea. How it works step by step. The step is not completely solving this Because this is not that important yet. I don't want to leave anything empty. Basically the idea is we scan left to right. And now look at this as soon as Some operator comes we put him inside the stack. Let's push and these defaults are saying Some race rules will change in between and As soon as an operand comes, we post it. If taken in fixed notation then most First came the open bracket, it went on the stack. Postfix notation inside is empty then u Have a then a we scanned into the stack. Our open bracket remained butt because it operant is operant goes into post fix. So a is visible here, the next number is plus. Tha Plus is also an operator so the operator would go here. Are there posts inside the operator's stack? Fix No Change Then You Have It Again n open bracket open bracket so open bracket plus open bracket no issue. Again here will go a remains as it is then we Have B B Aa To B Because You Know If it is an operand, it will go inside the stack. Both are holding their positions. Then you have multiply and then you have multiply multiply someone come here Not an issue what to keep in mind High priority sits on top of priority may but take on higher priority. If you can't sit on priority then go on top of plus. If you are keeping multiply then no issue ahead We grow because you have seen, now we will come to you I know this post will go to fix. Have plus plus we scanned and now here We will see when we write plus above the star That'll be a problem if we try What is higher priority in that case? Low priority if you can't come here What you have to do is pop this and Put it in this notation so this plus here But this star will remain, you will see the post fix Started appearing in Yes Proceeding Forward Next value is d and as soon as d comes d Again you know it's operant, go ahead Gone Than You Have Closing Bracket Watch Now As soon as the closing bracket has arrived, right? Can understand that it is completely solved So the bracket bracket has nothing to do with it. But yes this plus jo solve hua woh kind Off shifted here then moved forward. Closing Bracket Is Done After You Have Division Okay, when division comes again, understand. High can sit above low no issue Have given you have come again gone ahead Not an issue and then you have a closing Watch the bracket now as soon as closing When the bracket comes, now both will be solved. If the division pops first then it will go ahead. If plus pops then it will be followed by and now. This Is the Postfix Notation. Basic understanding is the expression left To right scan will happen whenever the operator comes Will go into the stack whenever the upper end comes Will go inside post fix notation. High priority above can remain high Low priority is no more than priority. And secondly, you have seen this pattern Open bracket closing bracket where Whatever is inside it should be solved. Using this idea you can do if Specified in exam by the use Off stack only other wise direct solve do it no need to do it yes one more There is an example for you so you can take one Screenshots And If You Want You Can Try It by yourself yes ok this is also Same thing now let's talk about the next thing that is Evaluation of Arithmetic Expression. So What's the idea? Right now we just converted did in prefix and ijn in postfix. Now that you have converted the expression So how is it solved sir? It should also be solved. Let's go with the help of a stack now. Understand if expression already written in postfix or prefix So how do we solve it? Isn't it easy to solve computers? How will the computer be comfortable? I know, okay sir, let's talk now. How to evaluate an expression Are With The Help Of A Stack. If expression already prefix or In Postfix With the Help of Stack Hum Converted So Stack Stack Stack Multiple Times. So I'll Take This Example: This is a fixed expression. It will happen which you can already tell by looking at it. Because the operator is visible last and If it is the first operand then convert it to 110. The post has been fixed now. Pay attention how to solve this. Let me explain the complete pattern to you one by one. Always keep in mind whenever post fix If there is expression then we always do scanning. Sir is left to right and left hand side Will scan from and what rule will you get? Whenever I explain it to you on the way, The operand will be found and will go inside the stack when You will also get notice of how the operator will be resolved. If you do, we will create a stack here. We found it inside the operant gas stack. Found inside the operant gas tank we found Inside Operant Guess Tactic Now As Soon As Operator will be found, operator will be solved at that time. And how to solve which first value pops She will become the second argument and which First sorry which will be the first value popped Second argument that will be the second value to pop. That will become the first argument and 2 * 3 is 6. Now Result Will Again Push Back Into The Stack means operator to solve We will pop two values and the result will be Will push it again to the next value. Tell me what is one in the stack next What is value division first value pop second argument second value pop hogi first argument 6 / 1 result is Once again into the stack now what do We have this edition again same story first Value will pop second argument ting ting ting ting ting ting ting ting der you see At a second value will pop and become first. Argument 8 + 6 is 14 4 14 again push back Into the Stack Next What We Have Is Four Next What We Have Is One Next what we have is multiply First value will pop second argument Second value will pop first argument 1 * 4 is like four only and then we have two So two came inside the stack Next we have Division to this came two here this came four here 4 Diva Batu We Have To And The Last One Is Addition yes to this and somewhere else pay value and This 14 so 14 + 2 is going to be 16 16 so Result is out 16 see the whole process understood See the idea, are you able to observe it? And even after doing this, why is there no need to memorize? See if any of these fixed expressions are Will be a + b and I posted it in the fix. If converted, it would have become something like this Now imagine when A is coming inside the stack. going b is coming going inside the stack So notice when I pop this To solve plus b then sec It was an argument, that's why you said it again and again. Don't memorize it, understand this also. The first value that pops is the second The argument is created and the second value pops up. It happens that it becomes the first argument and That's how we solve it and repeat until Keep doing this until the entire pattern is finished It can be done if you solve it correctly. If you do then you don't know what you will get in the end. Have only single value like in this case We got 1616 now this expression was As I told you already in the post fix. I am in general prefix will not be found But even if one can ask, one can You could also solve the example prefix. Hain So Dar U C An Example And This Is Obviously an expression written in prefix Now what is the rule of prefix scanning? If you do right to left then it will be reverse here. The scan will be done because the operator will scan first. What should I do? First of all I need to be operated. All that is needed is the rest of the rules, I keep going on. I am a bad idea, how will it change now? Will you understand that 2, 1 and 4 will come first and then Will come one then will come four next what do we Have is multiply now look at this this time The first value that pops up will be the first. Only the argument will be created which will pop second. Second will be formed and 1 * 4 is 4 yes next thing What came the division so first value pop Four Second Value Pop Hai To And 4 Diva Ba 2 It's Sir Next We Have There's One Next We Have is three next we have is two and now What do we have multiple na multiply The first value is here, pop the second value. pop the value 3 and 2 * 3 becomes 6 then Came division first value pop six Pop another value 1 6 div ba 1 u Have Six Again Goes Into the Steak Next You have it now, if you want to add it first then Will pop the value and the second value will come. Will pop six that will become 1414 will go up again and then final edition So the first value will pop 14 ting Ting ting ting ting ting ting there you Have one value left to end 14 + 2 e 16 So the final value you will get is only 16 cms. How come it was the same fixed expression? I used the same in prefix and postfix Convert and create two separate cases so that If there is no confusion then I hope this is complete. I just explained the pattern to you and this is its description. There is a complete manual, sometimes this can happen What procedure should I write in the exam? University people can't digest you know food. If you had asked this, you would have been completely right. You can download the rest I told you Scanning given postfix left to If right is prefix then scanning is right. Two Left End Patterns You Know How to Solve it Now let's talk about Rikers my God Rikers is one of the most important Topic in University Semester Exam. Look its idea is limited there will be Certain Questions to Solve You can come and I will talk to you once and Theoretical aspect can also come but in General As you get into programming increased Work by going to And You Know Placements etc. If you do then recurse will be very important when You have scored NET for competitive exam. If you prepare for this type of exam then Recurse will be very important so a little Looking at it from the exam point of view Rikers tries to understand in detail So I'll go one by one Let's observe the first point by doing And if there is any confusion, please let me know. Yes So Recurse Is as Defining Anything in Terms of It Self. Recurrs A Pro Programming Concept Where Function Call it yourself in order to solve a Problem by breaking it down into Smaller More Manageable Sub Problems yourself in your own terms Defining is called recurse but the The idea is that in small case there is a function f of A right now if I'm saying f off a I need this value and this something Like this key for example f of a is f a -1 Pw So if you want the value of f n So I am telling you that first you f n Calculate the value of -1 similarly f n If you go to h of -1 then you will get f n -2. Will send your same idea to call but Because the size is decreasing, the size is decreasing So the base case that goes somewhere They say f1 or f0 in recurse. You will know the value and from there then You will come back after solving, right now? Watch a lot of examples and you will get better at it. You will be able to understand from this it is a fundamental idea In Computer Science and Mathematics and Use Mathematics to Design Algorithms and Solve Problems That Have Repetitively There are structures, there is a lot of space It is used and you know we in General We Understand It is a Very You Know Programmer friendly idea if once If you know how to think in cursive fashion you can work on things very well. Rikers' Big Important Idea Base Case Because you know the size of the same problem Change and call for small problems You will go but be very careful about the base case. It is necessary to write because if the base case we Not written yet, we will learn from the exam later. There is a danger that we go into on 110 These two info loops will get stuck in the loop. will overflow and go somewhere Execution will not stop and recurse will not be saved. The case I wrote this is recurring What is Case and Stack used for here? Because when reading inside the stack While we keep calling, remember that chain. Who called whom and then whom? Called with the help of that stack when If we see further practical examples then we will see that You will understand the matter well now look at this Example Factorial I Think It's Simpler Than This If we can't have an example then let's accept it. Let me run the function and show it along. If you enjoy then let us know the factorial value. Take let me call factorial edge f let me From we called him on four pay now see say If you are crying then return it, not one. There is no zero, what to do in else? saying return n*factorial Call the function n - 1 p What about this It means there is no base case, now this is the What to do if base case is not base case Return n multiply by factorial of 3 n - It is 1, so 4 - How much will 1 be, it will be 3 Now I have written it, sir, is this a base case or not? If it repeats again, tell me what to do times will come 3 multiply by f2 is this This is not the base case, otherwise what will happen? 2 multiply by f1 is this base case No, this is not there, so what? 1 Multiply Ba f0 and see here Clear Cut It is said that if you call on pay then return Now look here, when you find a forest, 1 * 1 is 1 and then 1 * 2 is 2 and 2 * 3 e 6 and 6 * 4 is 2424 So That's a Good Example of Rickers And you also learned this from the tree method Like there is no need to maintain run time Na activation record and all like this If you manage directly, it will be better if you solve it. You will be able to handle things well Now Rikers' aunt's son will be able to do it. Hai iteration na what is that recurse mein to We call the function iteration i.e. loop How many loops do you read while for loop? loop de while loop do while loop yes one thing Let me clear further iterations of recurs first. The power of is exactly the same, all the work which They can be done through repetitions and iterations. can also be done and all the work that it What can be done can also be done with Rikers. If possible then where should it be used? Again it depends on the experience Depends on the environment in some cases You will feel that you know recurs is more suitable And some will involve iteration. How will that happen? With practice you will start working slowly If you go then you will understand where where to stick the needle and where to stick the sword So I'll go one by one iteration refer to a Process of repeatedly executing same set off instruction age long age If the specified condition remains true here We don't talk about base case, we talk about condition. Let's talk like in factorial case Can speak as long as the resulting value It should not happen so much or it should not happen at all. Can go for it in programming iteration is Commonly Implemented Using Loops As I was telling you, these three You may be familiar with Do While Normally We Use I don't do it but for and while I am very Two specials that are popular are used outside Cases break and end here Continue break where a specific There is a condition, any case can happen that as soon as the break statement comes you Currents come out of the loop and continue There is a term if such a condition arises If we don't have to work then we can Skip that iteration only and we move to the next iteration These go into programming Practical context is done for the loop Loop inside may also be listed as unknown Loops and Look At Have the Same Problem Factorial solved this time by iteration So let me quadruple the factorial again. call call four pay result ko inish The value of i is from one and the value of i is from one to n. If it lasts till then how many times will it last? Once or twice. How long should we work three times four times more? Go till it i our fur or less than four Okay, see step number one every time. What to do now, value of result What is one and what is the current result? Initia is done one se yes 1 * i so 1 * i If it is i only then it is our result. Shortcut operant is seeing good results What does it mean that is Result allocation is not result equal t result multiplied by i this means this thing Is it short hand operator then next What will happen in case the value of i is to be If it goes, we will multiply one by two. So our result will be two then next case If the value of i becomes three then it becomes two. We will multiply our result by three. Six will become and then four will become six. We will multiply and our result will be 24. In the next case the value of i will be five. Obviously f is not less than equal to 4 If the condition falls you will come out of the loop and Again u see answer is 20 f so either reverse Walk or walk straight, the idea is the same, Rickers and As I say iteration both work We can just have ideas about what approach we can take. Relatively more friendly feeling with Let's do so in recurrence versus iteration. See this is a proper difference I felt Given so that if there is any five marks in the exam Even if I ask for difference, you must be in. The Position to Answer function calls itself All Problems Use Loose Too Loop To Repeatedly executes a code and understands it Typically uses more memory due to call stack Memory requirement is more here Will be yes because he will keep calling again and again ok here's the thing about memory Requirements will be less because activation Records we don't need to manage There should be a base case and here the condition There should be a condition that never fails. will happen again Infineon Of Simpler and More Straight Forward for repeated task now again I am saying this is subjectivity. See In Where There Are Certain Persons Who Feel More Comfortable with Loops by Sir Rickers Can't think from idea to recurse Recurse save approach can't think of anything People Will Do Anything By Rickers Only They Don't Like Loops So It's A Subjective Thing Performance Might Be Lower due to overhead of function calls Typically faster due to direct this thing So it is relative because again and again Activation Call Happens and You Know You Have to call a function function up to a sum Extent it may be a little slow Relative to our iteration now recurs We can do some division here From Thorates is an indirect recurse if Let me explain to you in simple words function if it comes from its own body Suppose the person calling you is So This Is An Example of Direct Recurs Yes Ek Ho can indirect what do we mean by This is a function f1, suppose it is f2 is doing another function on its own You didn't but when you go to f2 you C If F1 is written somewhere there then a Now if we look at everyone's example then first function calling another If he is calling the first one again then this is An example of indirect recursion and this It may not be that there should be only two f1 calls f2 f2 calls f3 f2 f4 Call me like this and then you come back to so this is direct this is Indirect which is direct recurrence that can Be further divided into two types known As tail and head now what is tail if a Recurse call is the last operation in the function Before it returns a value then it is Called Tell If a Recurse is Mentioned Before Any Otherwise consider it like this, if I do all the work first After doing this, you are talking directly here, right? I am the last one after doing all the work first. I call that is known as tell Rikers So You Do All The Work Now Example If you see this also then you will understand this is called Tell A What's Another Idea Even if you are a beginner, what does head mean? No, there should be end or in the beginning. Then there may be a case that you do some work then you do a function call and then you do some work last i.e. think like this If even one task returns after recurse call You came and told that is known as recurse So if nothing is written after the function call This is tell and anything after the function call If it is written then it is called head recurse. Whether the function call is made at the beginning Have you done any work after that or somewhere? Be it in the middle, a little earlier, a little later. There is some question as to which of these two cases If you go to head recurs, this is nothing Like middle rickers ire you have tell and the rest All cases you call them head yes then again Category Ization is but when we try to solve If we go then nothing will happen sir now We have some practical questions one each By doing this we will practice some additional and Obviously there is nothing like that in this Butt will ask directly in your semester. Your understanding will become very solid For all ages the idea of Rickers is a concern So let's start problem solving now.
Will look at the cases one by one on Rikers. You will learn, see the first case, what to say? Here we have a function u. Can see main and asking find the output Of the following studied code is a function Fun whom I am calling from main. And We called the function a you can see on the What about calling value four? What would happen and how the story progressed? If you observe then now look at this I Called the function sir four pe see now What to do if you want to work foursome? If value is greater than row then here The reverse is not the base case, everything is a Base case if entry not found in function. So here it is working whenever in the function Going in, see how Rikers You have to understand that you will always solve it by making a tree and Always solve numbers step by step. One is saying print say step number two Call the function again but call How to do it at the same price or at a lower price. If you want to call at low cost then look at this here What will I do? I will do a function call on Four. Sorry I'll Print Four. And Again Did a function call but did three on kiss. Now look again, this is what he is saying Rikers. And Now You Can See This Is An Example of tail recursion because after all I am doing it now, tell me what to do now. Sir, if you want to repeat the same process then I will call again at the same value. I will print and then call to pay again. i will print and i call. I think it's still possible Because one is greater than 0 then no issue. So again I will print and this time I will call you and now you can see when If I call at zero then zero is no greater. If the zero condition fails then it will fail and What if Fard Call will not happen here? It seems to be printing, let me know. So there you c 4 3 2 1 so decreasing We need the complete sequence in the order. It is visible here, see further idea. It's exactly the same, I'm using the same code. I am but you will see what is the change, just the look. At Just to Give You an Idea the Difference Between tail recurs head ratio so now this is An example of recursion where first call I am doing the rest now, I will do it later. Guess what will happen this time again same thing. Yes but right now I will call first and who will call I will pay three times and then come later. I will print ok notice one thing We added x to this activation record. The value has not been changed, we have called. Only at x-1 so when I come back the value Will it be three or two or four sir? This activation record will remain value four only. I will print it on four when I come back. I will come here, what will this do? This will also work the same, it will call on two pay. Will print three, what will this call do? Will you pay for one and print two? Will do this call will pay and print. Will get it done if you call on one and a row then go ahead. Call will be made next, if call is not made then change. What changed? Sir, in the last case you If you look carefully then decreasing order The sequence was printed in Look at This 4 3 2 1 but if you look here then this Seem printed in increasing order. So first it became one, then it became two, then again It became three then it became four and it became one. Final by just swapping instructions How much can be changed in the code? Yes here Now see if there will be such a print command is base calling the function once. It is understandable, anyone can solve it. Look this is a smart case here I am I am calling with a little limit on three. Diya but look at this karna kya hai kitne Notice how much fundamental work has to be done. Do this by printing the numbers one, two, three and five. Then I have to call and then I have to print. Then you have to call and then you have to print. How will this story progress one by one? Do Have let me first call this on f3 and like You see, there are five things to do, so let's go. Let's start working and then print it. Will call to print again. Will call again to pay and then Will print the complete idea of Rikers. I understand that it won't be too late. Clear each value again and again If there is no need to solve then like f2. Sir, we can solve it here. Result will come, he will come here, I will solve here. Now I will do this, what will F2 do? If you want to do the same five things then start. Once you solve the recursion from the tree You have learned, mind you, there are some resources you know. If you won't be afraid of any recusor Let's start now this again print will print will print and here But as I understand it, call on f f1. Yes come here now this f1 again sir If you do five things then you will print it. will print and then u c f off 0 on and f off 0 will call and further i think Nothing is going to happen with this call because where u c f of 0 is the base case 0 is not Greater Than 0 Condition Falls We Come. Please tell me what sequence was printed outside? Three printed and moved forward to print It happened here three times one consecutively. You will get it, you will get it, now look here also If it is f1 then we already know what happens with f1. What happens three times consecutively? One print is happening and then again You have two and then you have three and that's what The complete pattern is from here sorry Till now I think this is complete. Here also f2 is representative of f2. It is written as if this sequence will repeat. So this is like 2 1 1 and then 2 and then 1 1 1 and then 2 and at last ॰ will be found. So this is the eight sequence which will be printed is going to be if you make a tree and use this recurs You won't solve it, it's so complicated. It will be possible to catch it in a sequence Observe is very difficult to solve. Yes, look at two or three cases, we tried them. What was the idea of different pattern butts? Print will not wait for 5 seconds once look at what this code is saying we have a Function Whom are we calling? Have to call on pay and base less than three there is a case Otherwise calling the same function twice value pe n-1 n-1 pe and then pv so how The story will move forward and what about this case? There will be observation, see one by one, it will be fun To you I will start the Idea by calling this on f now say f f What to do sir, there is no base case. It's not less day 3 has come, three things have to be done. Look at it this way, you have to call me four. pay plus call again four pay end Then tell me, do you understand this much? So twice we will call four which will result will come, we will even it out amongst ourselves and there Won't stop because once there's another forest in it. Now we have to add again like we did last In the question, did these two learn separately? There is no need to solve which one's Sir, if the result is of someone else then it will be his. let's catch what this will do also He will do three things, he will call for three Now this will also call three pay and then one See what happens if again f3 is not the base Repeat the same process in any case. hold on to one thing and keep moving forward. See like this so f2 is nothing but one because If two is less than 3 condition holds then From here you got forest, from here you got bana 1 + 1 + 1 value of f3 becomes 3 if you want It is written separately step by step. If f3 is 3 can you tell me what is f4 so Now this three and this three and one so 3 more 3 6 and one seven means the value of f4 What happened sen now can you tell me what Is f5 now think this way yes this way now This four is seven This four is also seven And this is one so 7 + 7 14 + 1 this is our Turns 15 and asked at I think five If you asked at five then it means if this We will call the function, see five pe to Here we can see a clear cut 1515 So this is the understanding I and I will solve the problem also on Rikers bus. I just want to observe whatever idea Sir, let's digest this together. If we take approach then what is approach? One has to follow the basic understanding By one you know traversing and solving Then let's move ahead and try another case. Look at this case again I'll give you Observe once for one minute and 30 seconds Look at what function you are calling. and this time I am also getting Plus Minus printed. Am I asking or am I asking about something else? I obviously tried in such a way that every case I have something different for you to learn. If found here what is consider the following Receive function c if get function is Being Called the Man Than How Many Times The Function Gets Invoked Before Returning To the Means is such a good case than you. Got the edition done or got something printed from you? Although there is print statement but ignore it Because and to confuse you this question How many times will the get function be called if we Let's try calling the gate off Let's see sir so late you see let me I represent the gate wholeheartedly. Called on fi go here what base case What is it? Is it less than one? No, not less than 51. If it was a base case then we would have returned it. How many tasks have to be done? Three tasks, first task. This has to be called -1 pe mano four pe dusra Have to call on -3 and if it goes 3 out of 5 Two left very good and third work to be done print print i write but us It has nothing to do with it again. recive function is grab any one I said there is no need to solve everything You see some people make a complete tree You won't need that later, you'll see. Hold any one chain and guess the rest. Can be done directly I start from here when I do four So tell me what will happen, this will also do the same thing. Bar will call one less i.e. three on one will call three times less i.e. one pay more print will make the call one less i.e. two pay call Will do three less i.e. zero pay nows interesting case this gp call will be printed Will make you come here and call one less i.e. That one pay call will be three less i.e. -1 pay Will print t and now ts the most Interesting Thing Will Call Ro Pe Call Will you pay 2 and print one? It is a zero base case. Yes sir, it is a zero base case. Because returning as soon as it's less than one So now understand the idea, did we get this? Got a call to solve off 0 Had to do it brother, will know only after calling. I think yes there is 0 lesson 1 and that is a We can return the base case from here. Will Get Nothing Similarly Over It If I I am leaving, there is no need to write what is g. Off-2 Single Call It's Not Value It's Call g off -1 single call g off 0 single call so this bhi single call bhi single call and a call Its yours so tell me how much call for offv Had to make one call, one call and one of its own Sir, three calls will have to be made then the value of g1 Will you get it? Now see one or three calls here. its g1 already one call is three and one is four and one of its own five is like g of 2 Now you can solve this in fives. You can go up while observing the pattern. No need to solve the rest Now Similarly Can You Tell Me What Is G3 Now g3 then you see g of 2 is 5 g of 0 is 1 1 and 5 6 and one its own so that's 7 g4 tell g4 now look at this it's already ready Now 7 g1 is 3 7 + 3 is 10 and + 1 so Ye sir kya ho gaya this is now 11 end Last case now that's g5 that's what we were asked for g 5 I asked, are you not nervous, each one? I am moving forward step by step. No you are able to follow so now this is 11 g of 2 2 2 2 2 2 is 5 so 11 + 5 is 16 End + 1 So You Get 171 Na So There You Different Types of Sea Rickers Different Different Ideas But Fundamental The logic is the same, we have to make a tree one by one. one by one value by value Keep observing and then you will Yes now you will be able to solve identification There are two special cases, one is Fina's number. Very Important and Next Tower of Knowledge So let's discuss them now. Let's talk about Finney's series Let us first understand its definition, what Rikers? save function is so in mathematics Number Commonly Denoted Age fn2 proceeding one starting from zero And one so these are the two base cases for you to understand So what is he saying that you are crying on f0? You will get more on F1 and others If the value is greater than that then what is f? n as written here f n will be f n - 1 + f n - 2 So for example I ask you I say what is f2, what will happen so f2 Will be f1 + f0 now such that the value of both I already have Which Is Like and And zero then f2 is also 1 f2 is also Then what will be f 3 so f3 will be f2 + f1 and both are one so now f3 is and so The value will increase gradually if What if we talk on common sense basis? Value is same function in first two cases Look what is written above and what will happen now? If we have to add then what is 0 + 1 This is what is 1 + 1 is 2 1 + 2 is 3 2 + 3 is 5 5 + 3 is 8 8 + 3 is 13 that Is 21 and so on and so for this pattern I will do one or two more cases in the same fashion. Let's take I think that'll be four and that Is 34 Yes And Then Now That Will Be 55 Something like this then this sequence would have continued This is Finney's function, now the function will go It's that simple, the sequence is that simple What does this have to do with Rikers? Questions can be asked about how things are Can be rotated slightly and to be very Honestly, I have participated in various competitive exams from here. Look for good level questions in the exam If you have two-three ideas then let me explain them to you. The first thing is that it looks easy. is because humans are smart yes if you If you want to calculate f of 10 then it is too late Need to Calculate f8 and f of 9 Again and Again you will solve its value once. Fill in the table and then you can Conclusion Questions like for example if I ask You take it back if I ask you Can you tell me to calculate f au se dhyan Listen to talk to calculate f of 7 how many Additions R Perform How many times will addition have to be done or at the same Time to Calculate 7 f7 How Many Functions Are Calls Done Now These Are the Questions You Ask You can answer only when you complete it You have covered the full point mathematically in depth. Have you observed how this works? And how will the whole story play out? Let's try and like Rikers we solve How sir, we do the same approach by making a tree. If you follow here also then tell me what is f7 so f7 is obvious f6 f5 is perfect Notice the pattern yes then what is f6 so f6 is again f5 + f4 one less and two less and again We understood that the entire tree should not be solved. To catch a pattern is to move forward. Now what is f5 sir f5 is f4 and f3 f4 is f3 + f2 f3 is like like like like like What is f2 + f1 and what is f2 f2 is f1+ f0 so now if I concentrate additions Pay attention to f1 and f of 0 so base There is a case, there is no addition for them. Yes, you have to do f2 if you want to calculate. So once I had to do an edition, how many? Times one time so I keep filling here Age for age edition is concerned there is no Addition for f0 there is no addition for f f 1 but In order to calculate f2 single edition is Required Now Then Let's Go Up What About f3 now i have solved this this is One f1 is again will do for both of them So one is Three's own and one is I think two. Additions are more than sufficient here How many editions did you have to do to again you go further? For f3 one has to do two additions to f2. We just saw the One Edition for F2. Had to do one for a and two for this so 2 + How much did the three and one edition F4 cost? How much has it become four to four editions r Required and further see Four for f4 For addition f of 3 to addition then 2 + 4 e How much does 6 and one f5 cost? Seven Additions Are Required and Like So No And so for you can calculate and they also Shortcut trick, see the sequence. Look carefully look at this and understand something If there is three, then there is two, then there is five. Four hai hai et hai to sen hai oh my god its Meaning the one higher number in the sequence One less sequence of the forest, so you can Understand it's going to be 12, it's going to be 20 It's gonna be 33 It's gonna be 54 Which I have written separately here. Where is it written look at this number Of additions, this shortcut trigger someone from you Ask leg for example f of 8 pe kitne Additions will be required to solve f8. what is the value of f9 sir value of f9 34 There's So That'll Be 34 - 1 Total 33 Additions You will look similar if someone asks you function Call already, we have solved the question. The one with function call is taken, so you can do this also. You can like how many times function calls For f1 had to be done once also for f of 0 If you have to do it once, you have to do it three times for f2. Gaya Ek Ek Ek So I Can Write For This Is One This Is One Here It's Three Times Paid three times for f4 and three times for f2 Had to do it once for f1 2 3 + 1 is 4 and then + 1 kitna ho gaya 5 ho So here's how many function calls are Required Five This is how you call functions You can also see a shortcut to this The sequence is like 2 * f n + 1 -1 so for See the example here, I will explain the pattern 3 * 2 6 6 - 1 5 5 * 2 10 10 - 1 Here comes 9 8 * 2 16 16 - 1 Here comes 15 13 * 2 26 26 - 1 here 25 will come so on and so for this You can solve this sequence using the pattern. Yes, these are some of the cases. How to make finiki function work How to create a recursion tree? Got it but separately Sambesh and you know how many multiple evocations How many function calls were made and how many editions were made? Now we can solve this a little bit Let me explain to you the history is very interesting So this is Joe Finney's number, isn't this it? Given by Italian mathematician Leonardo Of Pisa not Leonardo of Vinci Letter known as Fa Bane Ki in his book in 1202 The name of the book was Liber Abaki Hai Na and then this Westerners to Westerners this to all Find out about it when we check the Indian context is even older than this, around 1400 years ago yes late was a professor and Acharya called ping on my phone this is possible Pattern of Sanskrit Poetry Formed by syllable of lane two so he just Didn't understand the number and Sanskrit on it Poetry had also been created 1400 years earlier than that. First but again what is the problem that our The type of name is not written. And I want to make a little additional point on this because I am able to do it, the sequence is very simple But even when we see in nature not in a flower How many leaves will be like this is like How many leaf petals will there be in pineapple? All on the sequence of this finite number. Let's go now, why do we go to nature so much? What is close connection finiki save in Finnicky Numbers Are Very Very in Biology Important that is to be investigated This is Acharya Pingla who made you know how You Know the Sequence Haddock Mathematician Pingla Who else did he work on? Look at this binary numerical system Binary System Row and One I read a little raha tha so hi used to describe zero and One like Chand and Suraj Sun and Moon like This is because the logic is the same, Bano Miyal. Theorem Pascal's triangle is even zero, right? As most of us know that Acharya Bhatt was a Acharya who worked on it butt Can speak Acharya Bhatt Ne Arya Bhatt He tabulated it well and put it in the butt. Pinga is the first one who Things were described ok moving on now Our Next Idea Is Tower of Knowledge Now That's also a very special case of recurrence Let's talk about this. Let's talk now sir. About Tower of Noi Tower of Noi This is a very serious problem and CSIT A very important aspect is that Problem solving is not puzzle solving problem solving puzzle solving and this also It is a kind of puzzle, however read this puzzle As you read You Know, you will gradually understand that Indirectly we are reading the stack and some After time when you TTO and other subjects Will you read it or understand it? How much of stack in computer science If there is conceptual importance then puzzle first What do they understand? What do they understand about its rules? And Then We Will Try to Solve It with a Recessive solution now look at this tower of If I speak in a new and Indian context So it is also called Tower of Brahma. Why We Call It Traver of Brahma That Too You You will understand that it is a mathematical game and a puzzle. I will tell you directly there Are there three towers? We could have named them. Hain so this is like a beginning tower this is Like an ending tower and this is like a What is Oxal Tower Begin End End Oxal Rule? As you can see it is of different sizes There are discs of different sizes one above the other. One we have stacked up and now the The idea is to take a disc from one side and That means I can have only one at a time. Discs So I picked up one disc at a time If I can, it's not like I can move four discs. I can complete this pattern I want to reach the last place anytime Here you see always big disk Can put a smaller disc on top of the butt smaller We can't put bigger disks on top of disks So the rules are you know in general very clear oxal tower what oxal means again Secondary Supportive, its work is only you To help you temporarily recover some data If you want to hold it, you can do it otherwise. Wise is the conclusion that gives us the ending tower Need to count how many discs there are? No need, basically this is a puzzle Is flexible about the number of disks Minimum three discs are there to pay so it's Kind of
A Trivia Problem: To Pay More
One can pay 3, 4, 5, 6 up to n number of disks. Can be kept, but the rule will remain the same: smaller disc on top of bigger disk. You can move only one disc at a time, and the problem statement also states that this is complete. We have to deliver the pattern at the very end. So I think we have solved the problem completely.
Took some scrolling of the internet; now I know. No, these are some of the people you can see teaching the game. And look at this: Can you imagine if the tower is so big? How many moves should we make if we have a new one? We will have to solve this entire pattern. Now we will have to see what the philosophy is. How should I solve this? Look at this. Let me try this for you here again, to explain or try to show how to think about recursion, because recursion saves time. Writing the solution is not a big deal if once our thought process develops. Think how to look at this. As many ideas as you have, please let me know.
Pass total n number of disks if you have so what do we do first? n minor disks, and those n minor disks can help us by doing anything. Why? Stack key should be delivered to Auxilium property. You know, if the last one, if we have to move the disc, then sir, do it only then when there is nothing written on it. Neither will we have to send all that data. Now, good in oxal and that too step by step. It won't happen when we do all this work. This last disc we take from the beginning to the end, and finally the one which will reach n - 1 disk is kept in the axle tower. Then, using the if the tower comes at the end, then this is a basic idea. If I can give you a recursive solution, good. Before that, why I was also calling it the Tower of Brahma. A little PVT reading this will make you know this problem solving more interesting.
This story about an Indian temple, Kashi Vishwanath—you knew about this just a little while ago—which is the complete renovation etc., completed, consists of a large room with three times one post surrounding by 64 golden disks. To what’s the funny thing? The first thing was the voice reading through the internet. Nobody knows Kashi Visna Temple. Who originally built it? So much Bunder is old, no matter how old it is. You will know only when you go into history. Let's read and know who started it. It started. Nobody knows. Yes, and here, but we have the same problem with three towers, is and instead of 2, 3, 4, 5, 64 disks here. Now, what's the story next?
Read: Brahmin Priest Acting on the Command of an Ascetic Prophecy Have Been Moving These Disks in Accordance with the Imitable Rule of Brahma Since the Time and the Puzzle There is Four Known as the Tower of Brahma. If I tell you in puzzle the idea is detail like they are solving this puzzle continuously, and he believes that when this puzzle is solved, that will be the end of time. Jo jo our you know which is a complete bicycle. No Satyayug and Tretayug, Dwapar Kalyug, that your entire cycle will be completed then. Basically, this means from here you can guess it is in the order of 2 ray to power 64, because going ahead we prove will in order to move 64 disks in real-time fashion, we need 2 ray to power 64 moves. So ye, there is a story in its background, and then I understand that no matter how much you go and read, the point is, we Indians have done a lot of work. Did it and did a great level of work, but that work not preserved somewhere, lost. It’s done, and all the equations are still the same. We are reading ideas in someone else's name. And we would have felt wow, what an amazing thing. If it is a matter of then again the solution which I want from you. He was trying to understand the same solution.
Let's try to write a recursive solution. If so, we have a disk begin oxal end and three towers we have. If n = 1, now that is a base case if there is only one disk. Then there is no need to do anything. You can go directly from start to end. So this case is representing if n = 1. From Begin to end, we can go. If it is not so directly, then you will see. The three fundamental moves are to move the first n - 1 disks using can reach oxal pay from beginning. When we finish this work, start the tower. Obviously, if all the data comes on oxal, then now you can move from beginning to end very easily. And then the oxal tower, there are only nine days left before they can go to the end. Now let me do something and show you, right? We will watch the moves together and talk about the moves.
The point is, let’s see if I you allow me to write Tower of Noi by T. Only if I call the Tower of Noir. Let's watch it again on Kia Three Disc. The solution works or not. Three towers we have which ones we have: Begin Oxal End End. Tell me what work it would have done. There is no base case, sir; there are no three tasks. Will Tower of Noi move? Tower of Noi, so look at this: this call is going to do three things. Will do Tower of Noi again this time on n my wife will call and look at this arrangement be in your position, but the last two parameters got swapped. So I’ll do the same thing be my position and it swaps both. Am in between you have a single move from b to e. This b to e we moved and then again the same function, but this time you see it. The first two parameters we have at position have swapped, so this time tower of knowledge too. I am at my position b my sorry e my is it in position and is it between the two? If you swap both first then a will come first. And then you will have b. Yes, now let's repeat the same idea calls again. Now look at this tower of knowledge this time one pay and now the process is the same as when first bar function call first parameter will remain in their place, now both of them will swap again. If we happen again they will become a e when between if you shift then from first to last. Now we will shift from first to last, so there will be a move from b to a and now this time when the third function is called, so the last one remains fixed in its position. If both move first then yours moves last. The position is fixed and then we can have and b yes repeat again now look at will this idea still be called on One Pay? Well, one person will not call now this is a kind of a base case in which first to lastly here we have a single move from b to e and here we’ll have a single move from e to a from first to last now. Just like you solved it there, you should solve it here. There is a basic idea, your middle will be clear. Very easy to write mala move and now slowly the pattern will start to be remembered the first time we. So the first parameter is your position holds and keeps so this is like on one. So first will hold its ground a and e and swap B with each other and here.