Assignments for CSL100

Assignment-1 |Assignment-2 |Assignment-3 |Assignment-4


Assignment-1

(non-credit)

1. Learn the following basics of Unix:

  • What is a Unix terminal and how to open one? Reference: Unix Introduction
  • What are files and processes? What is a directory and how are files grouped together in a directory structure? Reference: Unix Tutorial 1
  • How to list files and directories? How to create files and directories? How to copy and move files? Reference: Unix Tutorial 2
  • What are file access permissions and how to change them? Reference: Unix Tutorial 5

It is expected that by the end of this task, you are familiar with the usage of unix commands such as: ls, cp, rm, mv, touch, chmod, groups, passwd, cd, pwd, mkdir, rmdir

2. Open up a browser (firefox/Chrome) and access the COL100 homepage.

3. Open an email client (webmail IIT Delhi) and login to your account. Send an email to the instructor of COL100 and then logout.

4. Learn how to use and navigate a text editor:

  • Type the following command on your terminal prompt: gedit &
  • Open the gedit tutorial and experiment with at least the following sections (you can experiment with all the subsections on the gedit tutorial page, if you like):
    • File basics: Open, close, and save files
    • Replace text and Search for text
    • Undo a recent action
    • Turn on syntax highlighting

5. Learn how to work with SML programs:

  • Open a terminal and execute the command: sml

  • Follow section 3.1-3.3 of the lecture notes and code up the examples. If you wish to experiment more, then you can refer to the slide deck here from slide 5 onwards.

  • Type the following programs in separate files and learn how to load and execute them in the interactive SML environment:

    fun factorial(n) = 
        if (n = 0) then 1 
        else n*factorial(n-1);
    
    fun gcd(m,n) =
        if (n=0) then m
        else gcd(n,m mod n);    

Assignment-2

Develop ML functions (from natural numbers to natural numbers) for the following problems.

  • Computing factorial of a given integer using both recursive and iterative procedures.
  • Computing x^n. Write both recursive and iterative versions.
  • Computing the n^{th} fibonacci number. First use the algorithm given by the following functional description: fib(1) = 1; fib(2) = 1; fib(n) = fib(n-1)+fib(n-2) for n > 2. Also develop iterative algorithms for the same problem.
  • The integer square root of n is the integer k such that k^2 <= n < (k+1)^2. The integer square root can be computed using the following inductive process:
    • Compute the integer square root i of m = n div 4 recursively. We then have that i^2 <= m < (i+1)^2.
    • Since m and i are integers we have that (m+1) <= (i+1)^2. We thus have (2i)^2 <= 4m <= n < 4m + 4 <= (2i + 2)^2. Hence we have that the integer square root of n is either 2i or 2i+1.
    • Write a recursive ML program corresponding to the above algorithm. Indicate the type of the function and derive the number of steps required.
  • Study the problem of computing perfect numbers from the the Lecture notes Example 3.13 and implement the ML program. Also study the following discussion on scope rules. You will be questioned on this problem during the demonstration.

Subhashis Banerjee / Dept. Computer Science and Engineering / IIT Delhi / Hauz Khas/ New Delhi 110016 / suban@cse.iitd.ac.in