Giter Site home page Giter Site logo

yuessiah / 116 Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 9.16 MB

My school homeworks

C 1.08% C++ 96.51% Makefile 0.10% Assembly 0.03% Python 0.05% HTML 0.02% JavaScript 0.07% MATLAB 0.08% CMake 0.78% Common Lisp 0.04% Lex 0.38% Go 0.15% Prolog 0.05% Yacc 0.58% Jasmin 0.08%
operating-system parallelize data-structures homework mips-assembly

116's People

Contributors

yuessiah avatar

Watchers

 avatar  avatar

116's Issues

clean merge sort code

usage: (merge-sort '(2 1 8 3 2 5 7 9 4 6 9))
merge 和 split-list 是尾端遞迴,
可能爆 stack 是 merge-sort 本身會是 2^n 。

(defun merge (merge-list sort1 sort2)
  (cond
   ((null sort1) (append (reverse merge-list) sort2))
   ((null sort2) (append (reverse merge-list) sort1))
   (t (let ((a1 (car sort1))
            (a2 (car sort2)))
        (if (< a1 a2)
            (merge (cons a1 merge-list)
                   (cdr sort1)
                   sort2)
          (merge (cons a2 merge-list)
                 sort1
                 (cdr sort2)))))))


(defun split-list (list1 list2)
  (if (>= (length list1)
         (length list2))
      (cons list1 list2)
    (split-list (cons (car list2) list1)
                (cdr list2))))
      
(defun merge-sort (list)
  (let ((list-length (length list)))
    (if (= list-length 1)
        list
      (let* ((pair (split-list '() list))
             (list1 (car pair))
             (list2 (cdr pair)))
        (merge (merge-sort list1)
               (merge-sort list2))))))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.