 Welcome back, in the previous segment we discussed the following, we said that questions about pictures, whether documents can be converted to questions about properties of certain number sequences and we also said that finding answers requires solving interesting math problems. Now I am going to begin with an historical remark in this segment. So computers are used to solve problems, we know that, we see computer solving problems but it is useful to remember that problem solving is really not new. Human beings have been solving problems, numerical problems for thousands of years. For example, astronomical calculations were done really thousands of years ago and astronomical calculations are quite sophisticated, they were done for navigation and of course they were done for purposes of astrology as well. Land records were maintained and for that interesting geometric calculations had to be done. Turns out that in ancient India poetry raised some interesting computational problems and these were solved rather elegantly. In the last 500 years we have seen the development of differential equations which are being used to analyze structures, weather and lots of things. So these things really are problem solving and they deal with numerical problem solving and they are used on computers. But all of this has happened well before modern computers were anywhere in the picture. So what does the phrase solving problems mean? Well, it means deciding what operations to perform to calculate the required answer and as I said human beings have been solving problems or deciding what operations to perform to calculate the required answer for quite some time and an algorithm is simply a precise description of the operations needed. Now this might be a new term and you might think that it is a term associated with computers and you may think of it as an alien term but actually it is not. I want to assure you that you already know many algorithms. So you are already half way there into learning this subject of computer programming. So the procedures you have learned in primary school for arithmetic on numbers, say addition of two numbers with many digits are really algorithms. Primary school algorithms say on arithmetic contain all the ingredients and that is really all that is important when you talk about solving these other more fancy problems. So what does an algorithm contain? Well, it requires you to perform arithmetic operation. Your primary school algorithm for doing addition required you to do something like this add the least significant digit of the first number to the least significant digit of the second number. This was what you needed to do in order to do addition. There was also a conditional operation. So there is going to be a carry. So carry is one if the previous sum was greater than 9. So these conditional operations also appear in computer algorithms and there is also repetition. So if you are adding one digit number to another digit number, you will repeat this basic step 10 times and on a computer also you need to repeat steps or you need to repeat a sequence of steps and really you do not need to do much more than this. You may do lots of calculations, you may have to multiply numbers or do something maybe something slightly different but really these are the three kinds of steps that you are going to be doing when you execute a computer program and an algorithm is simply a description of such steps. In addition to arithmetic you know actually many other rather sophisticated algorithms. So you know how to determine whether a number is prime. You know how to find the greatest common divisor of two numbers. This is a really pretty algorithm invented say 2000 years ago and it is still useful. In fact we will write a program to implement this algorithm on a computer. You can draw a polygon and drawing a polygon is also an algorithm, it is a procedure, it is a very very clearly stated procedure. So I should really point out that you do not need to worry only about numbers when we talk about algorithms. Drawing is also a systematic procedure drawing for drawing is also an algorithm. Well you might say that look a systematic procedure for anything else say making T could also be an algorithm but let us not worry about that. We are going to be concerned with numbers and it is vital that you understand what algorithms and numbers are and my contention is that you already understand that. Drawing like what you did in order to add two multi-digit numbers is an algorithm and an algorithm is nothing really much more it is really contains operations of that kind arithmetic operations, conditional operations, repetitions. So what is a program? A program is simply an algorithm written in a precise syntax or a precise language. C++ is only one such language. There are other languages like FORTRAN, BASIC, LISP. All these languages can be used to specify arithmetic operation, conditional execution and repetition. You have already seen how to specify repetition, use the repeat statement. So this is actually a fairly important crucial statement. So some thought exercises for you. So try to write down the algorithm you learned whatever in standard 3 for multiplying an n-digit number by another n-digit number. Well the teacher probably did not tell you algorithm for multiplying n-digit numbers but just showed you how to do that multiplication and by now you know how to do it for an arbitrary number of digits. How are you going to write that? Well you should break up the description into parts. So maybe you will say that in the first part we are going to do some multiplications and in the second part we do some additions. Then in order to describe what operations to perform you may want to give some names. So you may say that let Q i and R i, do you know the i th least significant digits of the multiplicand and the multiplier and then you may say that look let us multiply Q i by R j or something like that. Then you may also want to ask are there phases in the algorithm in which you do similar operations. If so can you say what happens in the i th phase? So what might happen in the i th phase might depend on i but if you can find a pattern then you have really captured the essence. Then you will be in a much better position to write it down nicely and indeed convert this into a program. So what have we discussed in this segment? We have discussed that the notion of problem solving and algorithms is old, literally thousands of years old and sophisticated algorithms were present thousands of years ago. Euclid's DCT algorithm is one example, one really fantastic example is the square root finding algorithm that ancient Babylonians knew. What is an algorithm? It is a specification, a precise specification of a sequence of operations. It may contain arithmetic operations, it may contain operations to be executed conditionally, it may ask for a sequence of operations to be repeated and you should remember, you should always remember in this course that you really know algorithms. So you do not have to be worried, of course you do not have to be scared of computers, you do not have to be scared of algorithms. The algorithms that you know are arithmetic on numbers, primary school, matrices, this is what you learnt in standard 11th and 12th, root finding that is also something that you might have learnt in high school or 11th and 12th. This knowledge that you have acquired in your schooling is going to be very useful for programming and as I said, you are already halfway there as far as being ready to program because you know algorithms already. Then we said that programs are very formal, very precise descriptions of algorithms in specific languages having specific syntax. So we will stop this segment over here and continue later.