Monday, July 24, 2006

Recursion and Memory Management

Today's morning lecture was about Recursion. Recursion bascially means repetition of certain task. In other programing languages it is knows as Loop, but in prolog it is known as Recursion. Recursion is carried out until the answer is met. It does not have huge code, just a single line but it will keep on repeating itself till the answer is found. Recursion can help in saving time because you do not need to type in full code, just type a recuriosn rule and that's it.

Lab lecture was related to memory management in prolog. Recursion as it involves rules calling themselves, uses the stack heavily in this way, and it is possible in large programs for it to become overloaded, causing a program to crash or stop the computer. That's why memory management becomes an imporatnt issue in prolog. In Prolog there is a built in predicate called CUT. Since Prolog is sequentional, means it searches records in the database sequentially, thus causing loads of memory to be used if the program is huge. So it is very important for the programmer to use CUT predicate inorder to make efficient use of memory. CUT is a mechanism to enable the programmer to control the execution of programs. In prolog CUT is represented by an exclamation mark (!).

0 Comments:

Post a Comment

<< Home