Semester 5 & Semester 6 Syllabus - Kannur University - BTech - Computer Science & Engineering

Curricula, Scheme of Examinations & Syllabus for Semesters V & VI of B.Tech. Degree Programme in Computer Science & Engineering
with effect from 2007 Admissions.

 KANNUR UNIVERSITY

FACULTY OF ENGINEERING




Download Syllabus from Kannur university site


Bubblesort - LISP

;;BUBBLESORT
(defun bsortn (n)
    (format t "    <<<BUBBLESORT FOR ~D NUMBERS>>>~&" n)
    (breadn n)
    (do (( i 0 (+ i 1))) ((= i (- n 1)))
        (do ((j 0 (+ j 1))) ((= j (- (- n i) 1)))
            (if (> (aref arr j) (aref arr (+ j 1)))
                (swap j (+ j 1))
            )
        )
    )
    (bprintn n)
)
(defun breadn(n)
    (setf arr (make-array n))
    (format t "Enter the numbers:~&")
    (dotimes (x n t)
        (setf (aref arr x) (read) )
    )
)
(defun bprintn(n)
    (dotimes(x n t)
        (print (aref arr x) )
    )
)
(defun swap(x y)
    ( setf temp (aref arr x) )
    ( setf (aref arr x) (aref arr y) )
    ( setf (aref arr y) temp )
)

Output:
Break 1 [2]> (load 'b.lsp)
;; Loading file b.lsp ...
;; Loaded file b.lsp
T
Break 1 [2]> (bsortn 5)
<<<BUBBLESORT FOR 5 NUMBERS>>>
Enter the numbers:
5
4
3
2
1
1
2
3
4
5
T
Break 1 [2]>            http://www.2k8618.blogspot.com/


Related Posts Plugin for WordPress, Blogger...