 A couple of things, I understand that your LDAP login IDs might have been activated but the software lab hasn't incorporated those IDs yet. So I note that you have been using a single login ID today. So the fun of sending an email to someone and getting it back would not happen because you would be sending a mail to yourself essentially or that is working, your emails are working wonderful. Anyway, the problem is there is no moodle and if I have to push this assignment into a location from which all of you can copy, there is no such common directory, common location. The other alternative I thought is I could email it to a tar file to each one of you. So basically a tar file combining these two. Unfortunately the CSR said that they can't compile all the email IDs of your people with comma separated things so that I can send an email quickly. They might possibly do it at 3 o'clock. If they do I will still send the mail to all of you but if not I will just got this printed. So you can have this, anyway you are not like first year BTEC students so I guess you can type pretty fast. So typing out some program in every case you have to modify that program significantly so that should be all right. So today we are essentially going to consider programming examples but first we will begin with a quiz. So here is a quiz on the technology of past. We all know memory, right? So which technology was used in the earliest digital computer? Was it magnetic core? Was it electronic walls? Was it semiconductor memory? Was it cathodic tube or it was none of these? You should be able to answer it in about 30 seconds. I will give you 30 seconds and then we will correct responses by raising your hands. Thought about it? So choice A raise your hands. 1, 2, 3, 4, 5, 6. Not half raised. You might be confused but you have to raise your hand fully. So 6, okay. Choice B which is electronic walls 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, okay. Choice C semiconductor memory 1, 2, 3, 4, 5, 6, 7 where we seem to have a divided opinion. Choice D cathodic tube 1, 2, 3, 4, 5, 6, 7, 8. Choice E none of these fairly large number 4, 5, 6, 7, 8, 7, 18. Okay. If I have these up they will not add up to the total number present in the case. For the actual CS 101 course we are going to use special handheld devices. You would have seen them in serious like Konbanega Karodpati where audience response is collected. So people press in some 30 seconds, 1 minute or whatever and then the collated response is displayed. That is the fastest way of getting your response for quiz. Also if you have to conduct the paper quiz of this kind, a more serious one, it will take at least 20 minutes to conduct a 2 minute quiz and then evaluation is about it. So those devices, just to tell you some happening over the last year, I thought of this last January and a colleague of mine who retired from the Institute Prasarov in Kutchatkar told me that he had used those devices in Gujarat, in the petrochemical university for a class of 60 students and he could buy them for $30 a piece from US. And then I followed it up. I asked that gentleman to come here, the representative but when he came here he said the cost is 2,500 rupees per piece. I asked him $30 don't amount to that because the dollar was maximum 50 rupees. He says no sir, if you import the cost is more and then he said this is only for the clickers. The software, the receiver, everything, everything will be another $10,000. I gave him a cup of tea and asked him to get out. And then I asked our affordable solutions lab which I had set up some five years ago. The objective of that lab is to take any technology solution and recreate an acceptable solution at one-tenth of the cost. That is the motto. They have never succeeded in doing that but they have been able to provide one-third to one-fourth cost to half the cost, which is not bad. So they came up with the study of the bill of materials and so on and they said I told them to make it in 250 rupees, which they said can't do it but they estimated they can do it in about 700 rupees. So then we spent time, got an embedded system design group established, they designed the clicker and the prototype was created by students like you by the way, meaning people are not passed out but people who come for summer internship during their second year, third year. So there are people from I think Jaipur and Nagpur in some place. I had lots of students last year summer and they actually built a working prototype using the Texas Instrumentation. Do you remember what I said about the size of the executable? Now you can see why that is important in some cases. Anyway, then of course the design and all took a long time. We used a cover coca of the remote, TV remote which was available cheaply and I actually used it as a sort of on a sampling basis in my last CS101 class but I had only about 50 of them ready. Then I could get about 850 of them which I used in the teacher's workshop that I conducted which I mentioned the remote places, some 30 remote centers, 850 people attended that workshop. So I would display a quiz here, they would respond from those clickers there and I would collect the data here. That is what we are going to do for CS101 this. I have about the right answer for this quiz. The correct answer is cathode tube. This was used in the world's first program and it was executed on the digital computer. It was not an American computer by the way that development was happening in Europe and America at that time almost simultaneously but the first recorded program to execute on a digital computer happened in June 1946 and that computer had no storage. What they did is they used a cathode tube. They used dot and dash to replace 0 and 1. Now cathode tube because of the refresh, a dot can remain as a dot for a long time, a dash can remain as a dash for a long time. They put some capacitive plates on top which could sense whether something was dot or something was dash. They had a phenomenal amount of memory of I think 32 words, so 32 lines each line so many bits. That was a very old kind of technology. It never sold in the market although they produced something and it soon gave way to magnetic core technology which gave persistence. Cathode tubes have never been used to build memory. Cathode tubes have been used extensively in the early days to build electronic circuits for all you for CPU and everything but they were never used for this thing. And semiconductor memory is a much recent phenomenon. Of course for you it is a very rare phenomenon. For an ancient person like me it is a recent phenomenon. So now we do not talk of magnetic core memory. We do not talk of any other technology. We talk only of semiconductor memory. Anyway this I thought was just matter of some interest. So we will have in the courses most probably not only in this course but other course also because once we issue the crickers to first year students other teachers can also use them and we will be using these. So consequently as one of the TA duties you have to evaluate quiz papers. That job is taken care of. It is automatic evaluation. Okay you remember the goof up I made in the morning and two of you kindly corrected me that the first dash is for something else. So I noted that the first character is for if there is a dash it is ordinary files it is these files is a directory. I was just curious so I went back to the LS command. The man LS unfortunately does not tell you complete details. So I found out that there are info docs actually as part of the units. These were introduced by GNU people essentially the great promoter of open source Richard Stallman he originally developed this idea. And there are info docs which give many more details. So the command to get more information about any command is to save info followed by LS and this is what I could call out. So this is the list of all five types that you see. We saw regular file all right. B means block special file typically this files will be block files. C is character special file so all devices like keyboard and all which interact with the Unix machine as character devices. Remember Unix treats everything as file but it is a character file. The capital C denotes high performance file. What I told you that the file system will allocate, de-allocate blocks and so on. So as a result you would have fitted blocks for a given file. Now if you are doing high volume data processing you will like the data to be and continues this blocks so that you can read them faster write them faster. So capital C will ensure that kind of file. D is for directory. Capital D is a very funny thing which came up with Solaris. Essentially this capital D though all the named pipes small p are very similar in concept. I have not explained to you the notion of pipe so let me very briefly tell you that. So when you have a process p running let's say p1 it will throw its output on STD out. Suppose you simultaneously want another process p2 to run but it should not collect its input independently from you or from any other file but it should collect its input on STD in from this STD out itself. So consequently what you want to do is you want to construct a pipe between these two processes and the way to indicate this to Unix is on the command line if you say p1 the first process will be executed if you say vertical bar which is the pipe symbol and p2 and basically Unix loads both the programs p1 and p2 in memory both are executed but if p2 requires some input it will wait till some output is created by p1. If p1 has created a lot of output which fills up this pipe because physically pipe will be some segment of memory and that memory allocated fills up then p1 execution will wait till p2 consumes something and you can actually create as many pipes as you want. This is one of the important flexibility that Unix operating system introduced early in 70s. Now these pipes are ordinary pipes that you create just by this symbol but imagine if you have a large shell script some 200 commands are being executed and wherein you have multiple processes to handle and now you want some processes to have a pipe some other processes also to have a pipe but these two pipes should be separate. So if you want to name those pipes you can actually create pipe and name those pipe and then give a command not like this you can say p1 greater than my pipe less than p2 something like that. So you can actually create pipes like this anyway. So there are multitude of things and you can examine all of these you are all familiar with socket programming. So if you want to refer to sockets or ports s and p are the things and if Unix gets completely confused over what the file is then it will put a question mark. So now we will go over to some programming examples quickly. The objective of the examples that I am showing you here is to share with you how these problems will be explained to first year BTEC students. So there are some necessarily some simplifications some additional explanations etc which you won't find at your level of program. But I want you to get into the mindset that like if I am a first year BTEC student and I am asking you some question then how you have to explain. Just giving correct technical information is not enough for me to understand and therefore not only in the classes but even in the labs or in discussion session or consultation session you will keep that in mind that those people know much less than what you do and therefore you are assuming the context is not correct. You will have to sort of go down to that level. So here is a what happened. Suppose an array is given which has well numbers and marks instantly the well numbers are given in ascending order but they need not be. You basically want to teach people how you can read these many roll numbers and marks into arrays and then given a roll number how you can search that roll number and get the marks for that student. So there is of course a lot of explanation of what an array is and how the array elements can be indexed by an index expression and by having the index value you can set up an iteration etc etc. So this is a sample program which is given that there is an array of 100 elements for roll and marks. We presume that some code is here which will read all the data in the two arrays and now here we are trying to explain how you search for a given roll number. So a given roll is written by the seen statement and then I have this iteration for i equal to 0 to less than n students. I just compare roll i equal equal given roll. If it is I will say found marks is equal to marks i and at the end of this I will just say c out marks for given roll i found marks return 0. So I found a fellow I get out. If I do not find a fellow I go back again. After showing this program we ask the students what do you think of the problem with this. So I suppose you can all guess that if I give a roll number which does not exist what will this program do? Sorry yes. So this program can have a possible problem with a given roll does not exist in the array may be due to a mistake in input the program will still print some garbage value. Now here is a point that I want you also to remember we have such logical errors in our programs large programs. If we get a value which is clearly impossible like 57000 marks. Nobody gets 57000 marks in any exam in India. So that is there is a mistake. But suppose the trash value at that location is 65 or 65 or 100 decent marks possible right. So you might assume that the program is logically correct. That is where we introduce to the students the need for debugging and while our hand execution of the code and when the programs become large you require debugging tools which I will briefly describe. DDD is the debugger that is favorite here. I do not know what debuggers you have used but it is very similar to anything else that you would have used. But the need for that. The second point the notion of algorithmic complexities introduced even at the first year we take a level in a very rudimentary sense. So there is a previous example of estimation of pi which is what I use by estimating the area or the number of points lying within a circle if you digitize a square superimposed on a circle etc. I am not discussing that point. The issue is that they have been told about order n order n square kind of complexity. So here we are trying to say is that obviously if I have to search through all the elements the order of complexity order n. Then I use this approach to introduce the notion of binary search. Now before that we have already explained to them through some other examples some simple numerical issues problems like finding out the value of logarithm of x. So you take the log x and you do a tangential thing so you keep bettering the estimate and then reach the logarithm value. Similarly a root by bisection method has been talked to them earlier. So what I do typically is that I take this bisection method and relate it to binary search in a slightly different or slightly more elaborate fashion. So I say that finding a root by the bisection method is simple you go to a midpoint and if the value of the function is on the value of the function of high side then you search your search space is this otherwise your search space is this. So basically we say start with a low and high value such that the product of the function values is less than 0. Whereas one of the values must be positive another value must be negative for the function to cross over x axis where the root is. Then we say compute midpoint and function value at midpoint and depending upon whether the midpoint is whether it is function is greater than 0 or some small threshold value you want to go as close to 0 as possible you will never get in floating point arithmetic f of some value as exact 0. So you say some threshold 0.001 or whatever whatever and if you reach that you finish otherwise locate the next interval to be either low to mid or mid to high. So this is the example that you are essentially taking a search space which is this big and you are reducing it by half in one shot and next time you are reducing it by half in one shot. So if I can do this with real light can I not do this with real light? That's the point that we try to motivate people. So what I do is to show that I actually consider x axis as a set of discrete points. So notice that these points are essentially ordered this is a smaller value and the next higher value and the next higher value etc. So how about an ordered array sort of and then at each point I am examining the function value which is like marks obtained by a student. So if the whole numbers are sorted what is the analogy or simile of this approach of bisection method with binary search. So what I do is I simply put that diagram like this and so that look if the x axis is discretized then the points on x axis can be considered to be points in my array which are values in my the key value which is sorted and just like I go for a mid point which on real line could be any arbitrary point but for integer index I will go to either this point or this point or whatever. So in just as in one shot I was reducing the low to high search space to either low to mid or mid to high similarly I will be reducing the search space to half. I have found that this kind of simple graphical explanation goes a long way to explain the concept. After this we of course say that look if you have to do this then you can write a binary search algorithm and then this role made etcetera etcetera is is is indicated incidentally I often ok so this this will actually find out if the role is equal to given role it will set up a flag it will it will show then I ask the students that in the assignment you run this program and you run it finding out in each iteration what is the low value, what is the high value and what is the mid point that is why deliberately a few elements are given initially like 7, 8, 10, 12, etc less than 60 so they can even hand execute it they can certainly execute it and that is roughly the time they would have learned debugger ddd so they could execute it using ddd and actually monitor the points now I do not know which way you will learn these things but you will agree that a little explanation of this kind would be useful for the first year BTEC students so that is the approach that we do and incidentally the assignment that has been given is merely to but there is the same thing so what we have given is a ordinary C program C++ program which reads the text file and then there is a iteration which says give me a roll number and I will search that value what we are asking you to do is replace the reading of the array by a function which actually will read the text file the data into the array and sort the array the given data happens incidentally to be sorted out of roll numbers but which need not be so so you sort that array and the actual search routine should be binary search but this program is not a big deal for you but when you actually write execute you will go through GCC compilation on a Unix environment etc because that is where the students will be asking you problems and in any case it is useful for you to get familiar with the environment so that is the purpose there are a few more examples which I would like to quickly describe remember I told you that you will have to set question paper in the exams as TAs in any course that you are associated with let me first show you the problem that was given to me as a programming problem by one of the TAs last year so it says given to arrays A and B if X is an element of A and Y is an element of B such that if these two are swapped so one element of A array is pushed into array B array B is pushed into array A then if you take the sum of all the elements those sums should be equal that is the problem initially whether they are equal or not then another but after the swap they should be equal and the problem was find out such X and Y I thought this problem was too hypothetical so what I did is I constructed a sort of a realistic looking problem which was this problem the problem is there are two trucks in which packages are there weighing different weights we assume for simplicity that weights are integer and now we need to balance the load we say that initially we are imbalanced but we want to find out exact one pair of packages one here one there so that one Hummel takes out that package puts it here takes up this package puts it there can you find such thing given all the weights of different packages in truck A and truck B notice that this problem is exactly the same as that but you will agree that if the problem is posed in this fashion students can weigh it because they can imagine trucks they can imagine packages they can imagine weights and they can see that this is what is happening why I will also be giving this example in the 20th in the Convocation Hall the objective is to say that even otherwise programming is not done to solve hypothetical problems programming is always done to solve real life problems except of course by mathematicians who are doing theorem proving another thing so it is always useful why there could be very interesting programming problems which you would like to put together such as this it is always useful if you could somehow restate that problem programming problem in terms of some real life problem because then everybody whether they are students of first year level or as old as me 62 years old we will all find it easier to relate to that problem and we will learn another important thing given a real life problem how do we translate and model that problem in a programming paradigm so these are two very important things which I believe are useful so the next slide actually indicates thinking which says initially I would think how will I reprint the problem data so since we will be required to compare rates of packages from each truck with those in the other the best way would be to read the respective load values into arrays that means all package values are available now assuming maximum number of packages in each truck to be 100 now that's an assumption I am making we will use integer arrays a and b or size 100 he is having some m and n elements respectively reprinting the bits it is important to convey to students to state those assumptions here otherwise in the program you directly a 500, a 5000, a 200 with no reason of life there is still no reason of life but it states that I have made a conscious assumption and if this assumption is stated even in the documentation of a program either in line documentation or outside we will tell the students that it will enhance the value of their program then what should I program find so you are saying there may exist pairs of elements of the type x and y such that x is an element of array a y is an element of array b and if I swap x and y then the resultant array will have the property that sum of elements of new array a is equal to sum of elements of new array b observe that this is the original problem which you wrote is a good problem but you will agree that stated in this fashion it perhaps makes more sense now one possible algorithm say is to iterate on one array b and for every element of array b which depends on weight y find the permissible value of x so how do you find permissible value of x that is given a y what should be x so that it can be swapped well that can be done because you want the total balance so you have to obviously find the sum of all weights originally and then find out for any y what should be possible x knowing possible x now you iterate around the array a to find out whether such x exists and if it does the problem is solved so this is an example program so it declares the two arrays a and b it declares m and n as number of elements and then of course index values etc sorry there is a syntax error here have you spotted it wonderful in spite of all possible care read numbers into arrays read m, read m elements then read n and read m elements in b then find some of all elements of each array okay this could have been easily done combining with the reading but there is this matter of style generally we would like to have input operation completely independently as separate function and then any manipulation separate then I find out the difference then I do a curious thing if difference modulo 2 is not equal to 0 I say the difference of some is not even therefore desired element elements do not exist can you reach this conclusion yes but you have to formulate that and it is not necessary that everyone will automatically think of this so it is useful to point this out through a series of commands justification for the difference to be even so after stopping x from a and y from b if the loads are balanced we will have sum 1 minus x plus y equal to sum 2 minus y plus x because you have stopped these and this equation modifies to this where you essentially get sum 1 minus sum 2 which is the difference equal to 2 times x minus y x and y are two integers so the difference is an integer then 2n is an even num so that way we say that unless the difference is even you cannot have a solution so we have found that out this also people should be encouraged to think like that because what they are doing effectively is they may not be changing the order of complexity of the algorithm but they are drastically reducing the execution time you remember you have two order n square algorithms one is say 5n square plus 72n plus something and the other is 25n square plus 2n plus something now the 25n square is going to cause very heavy weight so those coefficients do matter and therefore if you reduce last slides so you can explain that if you go by the law of averages then half of the time actually it is not half because the probability will work out slightly differently but effectively you are reducing that much in computation time so now look at the elements meeting the criteria if x is element of a and y is element of b we need to find x and y such that this is this in general for some j we are looking at bj then for some i we must have y equal to someone minus some 2 plus bj is a mistake this equation is wrong it is not someone plus it should be someone plus y minus x equal to some 2 plus y etc etc I have obviously taken some slides from an older version which had a mistake then this so that is ok you can correct it I suppose anyway so this is what you do you find out what is the probable x this is again a wrong value it should be someone minus some 2 by 2 plus bj and when you get that you search this out and get out now here effectively you are saying that you are doing a scan on ra b taking one element and then you are doing a complete scan on ra a taking another element so some discussion on algorithmic complexity if m is equal to n the problem is size is l and since we already explained to the students that algorithmic complexity has a meaning only when n is tending to infinity and when m and n tend to infinity they are roughly same so the order of size or the size of the problem can be considered to be l and then we say that since we have an outer iteration which executes n time and every time for each outer iteration we have an inner iteration which again executes n time so the algorithmic complexity is order n square and this is where we relate this problem to the binary search term that if the second array was sorted or in this case the first array if array a was sorted the inner array then I could use binary search to find out so one of the two arrays is sorted then the search will be done in log n to the base two times and therefore the algorithmic complexity will reduce to n log n to the base two and we will say that in similar real life situations where we are not talking about balancing role on trucks we are doing some kind of finding out matches against millions of records or millions of things these things would matter so this is generally the tenor of programming courses here the introductory programming courses here here is another example where we we have earlier discussed in the class the limitations and floating point numbers all of you are familiar because of the limited precision if you add let's say how we will do a number which is 10 to the power 37 you add some 0.357 nothing will happen because the precision is way beyond the capacity of representation and then we say in real life we do need to handle larger precision so how can we do that can we have a 50 digit precision can we have a 70 digit precision which ordinary programming languages do not provide so as an example I usually give this example numbers which much higher precision could be represented inside if I decide to represent one digit of the high precision number by one element in an array now if I have a large array then I can use that to represent a very large high precision number so the example of course given here is on integer high precision numbers but in real life we usually give a reference to a beautiful book on numerical recipes have you read that book anybody? numerical recipes in photon numerical recipes in c numerical recipes in c++ numerical recipes in java the same numerical recipes which the authors have been rewriting in different programming languages they are one of the best books in computational algorithm real life implementation so whether it is finding out simultaneous equation solution differential equation n number of things beautiful book and it has actual code which solves the problem so you people being computer science students you are more interested in computer science not the mathematical and numerical problem solution but if you take mechanical engineers civil engineers, aerospace engineers people who deal with structures finite element techniques etc invariably they will require this kind of mathematical and since the first year course is taught to students of all branches you remember in your colleges also students of mechanical, electrical would also have done that program course they would be expected to handle such things so it is useful to give a small example even in a first course so we saw that since arrays can be used to repaint high precision numbers however the natural plus, minus, multiply, divide operations of c will not work so we will have to write programs to do all of these and as an example we will say we will consider the problem of adding 2 high precision numbers so how do we represent such high precision numbers so this is an arbitrary representation that we repaint the number in an array such that the 0 element in c has the number of digits in that high precision number and num1, num2, num3 etc actual individual digits so this is a reasonable representation we can now repaint 2 such numbers in arrays m and n assuming a number as a maximum 99 digits we use m100 and n100 because one position is lost in keeping the number of numbers please note that this representation does not permit negative numbers to be stored so that we introduce later by saying that we will additionally need a site so and that can be easily done by putting the number of digits as positive or negative so this sign can be accommodated because after each memory location itself is a fulfilled integer value and then we say we may now write a program to add these two numbers and store the result in R or RSA R and we explain how R100 and 1 is there because when you add the result might have an extra digit so why is the size of R1 more than Mn and we let people think that we have to multiply 2 high precision integer numbers the size will have to be like almost double now we discuss how difficult it is to add numbers given this representation for example the numbers will be given in this form say 4 digits 9521 6 digits 996357 so when I read this input into my arrays I will have M0 4 which is 4 digits and then M1 M2 M3 M4 containing 9521 which are the individual digits of this number exactly the same thing for the array 1 M0 will be 6 which is the number of digits in that large number is not exactly large but a representation and now we point out that even if we have these digits, individual, digits in individual elements of the array it does not appear state false for me to add because this is not the way I add numbers so we explain that the way I will add numbers is I will first align the numbers on the right and then perform the addition digit by digit so when I shift the numbers to the right I will like to have 00 here I need to shift only the number with smaller number of digits to write because then it will get aligned anyway now in general I do not know how many digits are there in any number so then as one strategy what I see is that I use so to temporary I was called m dash and n dash and I will take the m and n are the numbers and push them all the way to the right so they are always right justify so m dash will contain the same number to the rightmost column rightmost element and n dash will contain the same we also observe that the addition is not simple add this and this and put the result here so any digit position suppose I am adding here I add not only 5 and 3 but also possible carry which could have come up from previous operation and we explain here itself how an iteration can be set around these positions if every time we add the 2 corresponding digits and a carry the carry may be 0 carry may be 1 and if after the last digit all the most significant digit is added if there is still a carry that is where an extra position is required for the line so then the algorithm to be used is you read the you have read the numbers in m and n now you shift all these m and n all the way right and then all them like this so this is what we do incidentally last year I had used this opportunity for the first time to explain the question mark operator all of you are familiar with this it's a form of if now invariably in the textbooks and in most of the teaching we find this is thought or this is discussed along with the if statement when there is no natural need to discuss this in fact we generally do not like discussing elements of programming language piecemeal by piecemeal there is no concept which is introduced without an example there is always a programming example in which a concept comes and then that concept we believe sticks better in the minds of people we are trying to propagate that method of teaching everywhere in the country but this is what we do here I verbally explain what this does and then of course I start with carry equal to 0 I is 99 I greater than equal to my another syntax here this is of course Microsoft stupidity any isolated I will be capitalized automatically so at many places I have taken care but this will remain anyway and then you will notice that I have shifted the numbers to I dash to m dash and m dash so I am using that from the last position backwards and whatever is there if this is greater than 9 then they should take the digit to be modulated because it is 12 so the result will be 2 it is 17 the result will be 7 and carry 1 like that and then we modify the carry and go and just to make sure that the verbal explanation of this particular construct is understood I usually repeat the slide and say that this means if m0 is greater than m0 then max digit is m0 else max digit is m0 and once again but first the fact that this kind of construct is to be used only when the left hand side of the possible assignment is same max digits or something and either this value or that value is the construct when you use this so this is these are the kind of examples by the way a question paper in the mid-same contained having explained this before the mid-same they had to subtract numbers so they had to work out the negative number representation and they had to do now a borrow instead of a carry and in spite of the hassle of an exam I tell you I mean this is where it is extremely satisfying for a teacher there are several students who wrote a composite program which could do either addition or subtraction so their representation were meticulous and their computations was good and they could write I mean fairly good program in a two hour test so that is where practice counts if people have written lots of programs then these constructs and segments will automatically sort of flow from your head that is what should happen given all this we still need to debug programs so I don't know if you used in your programming or you did not use any formal debugging tool gdb that is more popular is it everybody is familiar with some debugging tool or the other or if some people have never used a debugger please raise your hands because this is important one two three okay never use debugger okay fine so how did you find your errors in the program or if somebody goes back and examines your final project report the programs will actually not run that is likely for other reasons but particularly when your programs becomes large become large and there is some error in some segment I don't know but I find it extremely difficult to locate it easily some debugging tool is very very essential anyway what we use for the first year course is gdb but gdb is also called popular here and I would strongly suggest that you spend some time getting acquainted with gdb unfortunately this is not an ubuntu machine so I can't show the ddd here but I have some slides here these slides I will put up in the final common directory when you get it on the model or something so you can look at that but you can execute ddd on your own for every one of these programs and you can see how you can step through how you can find out values and so on or any debugging tool is not very difficult conceptually it is easier to imagine that you have an animator or an animator execution of your program lines are being executed somebody is trapping each execution value of some variable changes and you are able to observe the change value if you wish after every statement execution so instead of hand executing you can actually give the data and the machine will execute step by step if you do not want that but you want to stop if a particular value changes by this much or something you can set what is known as break points so in your program you say that if the index becomes larger than 10 I want to stop and I want you to show me the value of this variable or this element of the array etcetera so graphical tool an extremely versatile it will not take you more than 10 minutes to figure out how to handle that but believe me it is worth it to do it even for you for me for everybody it is still worth it to understand a good debugging tool and use that so this is some explanation of the debugging tool essentially it monitors program execution as a front and command line debugger so it can debug executable binaries it can debug java bytecode programs python, pole, bash program anything that is the reason why ddd is perhaps more popular among some people invoking ddd you just say either ddd and then you will get a blank window of course there will be no program there in which case you go to a file option inside the ddd and load a particular otherwise you can simply say ddd executable if you know the process ID number you can also give that quitting is very simple in the file option you say exit or quit or control queue what is important is navigating through code so before you use ddd just let the compiler know that you are going to use a debugger later see debugger is not black magic so while you compile the code there must have been certain hooks maintained which the debugger will use so you have to inform the compiler that I intend to execute this program with a debugging option and consequently you can say gcc minus g or c++ minus g okay when you invoke the compiler then you are wanting to use a debugger later and then of course you can open the file or open the source inside the ddd you can look up definitions of various values and various variables and so on you can create break points as I mentioned so stop the program execution at some point so line number 40 now of course you will not stop it if it is a plain sequential instruction but obviously iterations, iterations you give a line number then when you run the program every time the execution comes to that instruction you will stop and at that point if you have highlighted certain variables or other elements etc for display then those values at that instance will be displayed it is almost like hand execution except it is done far more rapidly far more conveniently and you do not have to go through every iteration for say 10,000 iterations some values and variety of it watch points are stopping the program not at a particular line number but whenever a value of the expression goes beyond a certain value beyond the threshold value and you can interrupt any time by pressing escape if you just want to run the program you can run there is an execution window which comes which is exactly like your terminal if you are executing a program there is some input value in that execution window and the program execution can also be seen so as I said this is a very beautiful graphical way of executing your program but under your control step by step those of you who have never used a debugger will really enjoy doing this so in the lab today rather than writing that C program although that is what I expect that you should submit a file so whatever file it is it will be a CPP file you can submit it ordinarily there are multiple files to be submitted as you would have seen in the morning you would convert them into a tar file and you upload a single tar file that will be the normal because but I would definitely like you to grab this opportunity to become familiar with the debugger once you use one debugger thoroughly you can convert to any other debugger without any problem but in particularly those of you who are inclined towards implementation oriented activities rather than theoretical research you will find this extremely useful and just to tell you that some of the best theoreticians, computer scientists in the world are here with us and many of them are better programmers than many implementation oriented guys so theory and practice are not contraindicated good theory does not mean that you must not practice what you preach now good practice means you should be devoid of theoretical understanding and devoid of a coin anyway so this is all that I wanted to say today yeah okay there is so there are one number of other details you will actually look at the ddd documentation to note more but I tell you by reading documentation not much is understood you have to dirty your hands so play with it for fun and say today and on Monday to the extent that you can and in there also later on it is worthwhile playing and mastering that because in any course project that you do later during the semester all your final project if you have to do implementation then believe me the two things that will help you tremendously in saving time and achieving faster results one is the version control system and the other is a good debuger these would be required so this is not for the sake of first year students first year BTEC students this is for our own sake that we should do this is that okay fine so any queries since we still have about 3, 4, 5 minutes any general questions anything anything under the sun we will still have to continue with a single login idea Raju is it by the way Raju Chintalla and Swapnil are the senior TAs for 101 and there are supposed to be two other people who are coordinating this TA orientation program but they are missing wonderful they presume that you will take the responsibility Nagesh can you just show your face to them Nagesh is my research associate he joined me about 5 years ago from Goanjiing college and he is deeply involved in both the national mission projects that we are doing as well as the programming courses in fact he has written he had written a book sort of what 5, 6 years ago on detail 8 years ago I went through that book it is an extremely good collection of very many important things I have requested him to open source it that means release it openly and he has agreed to do that but he would like to edit it but I have convinced him that you should not be worried about mistakes and you should certainly not be worried about some people pointing out mistakes you saw me making mistakes here right all of us can make mistakes so I have convinced him to release that book we will put it on the either it should be key or CS101 home page or something and along with the BTEC source you can also read it, it is useful in general you should depend more on internet resources rather than physical book resources or that is the moral of the current era so you will find for example wiki to contain beautiful technical explanations on points which are not so well covered even in textbooks all of you have read wikipedia how many of you have never seriously searched wikipedia for any problem everybody has so tell me what is the best tip on programming that you got from wikipedia see that is the point you search wikipedia but you search wikipedia for general problem you will believe that specific technical points will probably not be as well covered in wikipedia as you would want to that is not so you take image file formats anybody who has done any image processing so you take image file formats all of them are better covered in wikipedia than many textbooks that one sees the BMP format for example the complete core for BMP format the standard for BMP format is best described in wikipedia rather than any other text so such is the power of the internet resources and other endeavour through this CS1 on program and through the national mission is actually to launch a classified portal on computer program where all open source resources classified categorized properly would be available so those of you who ultimately become TAs for CS1 will actually be contributing towards that effort as well by not necessarily by contributing questions yourself but by editing correcting the programs that should submit and by ensuring that those are in presentable form that will be one of the activities so that is all I have unfortunately can be any communication between us because there is no moodle so in the assignment all of you can access email right so I have given two email IDs one is mine and one is Raju Chintala who is the coordinating TA so at the end of the day you just mail you have to mail only one file the final program that you write and just mail it to him that is all and use this opportunity to you know sort of figure out as much as you can tomorrow of course is Sunday so you should all relax as Professor Sundar said you should also have some fun in life so you should have real fun tomorrow go out in the nice rainy season to we are lake or some such place a picnic, rainy season picnic but don't follow and come back on Monday morning I think you have got a schedule copy also so we will continue with that schedule but you have a programming test and this is like a regular programming test like C programming test you would have given what four years ago something like that so it did not be C it could be C or C++ but it is essentially a C C++ I am presuming that all of you are familiar with C C++ at least either of them fair enough because one thing that we will be doing is I will be setting up the question paper for that test before that you will be setting up questions for a hypothetical test so you will see the wilding of your questions and the wilding that comes out in the final test and finally evaluating papers you will have to evaluate papers of the students for whom you are TAs in whichever course so what we will do is your test papers will be evaluated by yourselves but in a pipeline fashion so we will simulate how question papers are evaluated for large course it will be fun any other suggestions ideas nothing 20th as you know from the studio is the institute day they have said that they will cover the module extensively so that is why I am removing emphasis on Moodle you should be able to see Moodle is also an excellent learning management system and now that you have held up ideas go to the institute Moodle actually you should be able to see the courses that you have registered for but you can also see a number of other things and just examine what are the features what is the discussion forum what are the links for various things schedules etc etc it makes life far simpler and very organized so that is the objective alright yeah please who top coder.com just speak on that because they are recording everything so the top coder.com has very good tutorials on C and C++ programming I mean it even has java csharpandal but yeah cc++ is top coder.com are they open source I am not sure if they are open source but yeah they do share content about programming there is a ticklish issue you know that if something is not open source then we hesitate in putting it in public domain ourselves we can give a link saying go there but our notion is that if my people require access then it is best obtained if the information is on a local server see India is very special as compared to many other nations because internet bandwidths are still highly limited so you take your institutions for example I have seen many cities in which colleges have less internet bandwidth than a cyber cafe and many students actually go to cyber cafe to interact with internet now given this situation if you have heavy usage by let us say 300 400 students on some particular resource on internet it will be impossible so what is the best way you create a mirror you create a mirror site and inside your organization our notion of open source is that our open source servers which are there in the reclamation project or national mission project things are downloadable anybody makes a request for any portion we actually put it in DVDs and ship it saying you install it on your own servers so open source should be to the extent that nobody should question saying that IIT Bombay or FATA or anybody has violated an intellectual property regime so if not can you just check the stop coder thing we will see if they have a license and these western societies are very peculiar about it on one hand they are very possessive about the intellectual property similarly they are extremely clear about the legal provisions on the other hand they will be very dicey in the world so they will never say whether this is open source or not 4 or 5 years ago we had a situation where somebody had kept a tutorial on the website and persuasion my colleague from the database group who is the author of that book on databases decided that people wanted access so he put that on a site here and then he got a very sharp thing from the author of that tutorial that how can you copy my tutorial and put it on the site there is already anybody in the world sees and co-op downloads his tutorial but you can't put it on the server so professor Shaman Chakravarti another flamboyant researcher who actually is far better acknowledged as was expert in data mining and text mining then that gentleman he wrote a letter to him saying that we have kept it just because few people wanted it we never believed that it was one of the better tutorials we have deleted it since that happens you know we would not like that to happen so but it's a good point that he is making all of you should be in the lookout of resources in programming they could be mutually beneficial and additionally they could be beneficial to these learners and wherever you find a true open source thing which means I can copy and distribute that is open source then you would be very glad to have them because on our model we keep all the resources which are accessible so top coder you said top coder we will examine that thanks any other question fine so go ahead enjoy the lab and then enjoy the evening and night and tomorrow thank you