Coder Social home page Coder Social logo

deathking / hit-datastructure-on-scheme Goto Github PK

View Code? Open in Web Editor NEW
83.0 83.0 19.0 751 KB

哈尔滨工业大学《数据结构与算法》、《软件开发实践》作业及实验的Scheme解法。

License: MIT License

Scheme 98.10% Graphviz (DOT) 1.90%

hit-datastructure-on-scheme's Introduction

Hi there 👋

(_2b || !_2b).is_a? Question

hit-datastructure-on-scheme's People

Contributors

deathking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hit-datastructure-on-scheme's Issues

Bug in dijkstra2

Using your code as listed I get:

1 ]=> (dijkstra2 c)

;The procedure #[compiled-procedure 16 ("vector" #xa) #x1a #xbd14fa] has been called with 4 arguments; it requires exactly 3 arguments.
;To continue, call RESTART with an option number:
; (RESTART 1) => Return to read-eval-print level 1.

I fixed parenthesis so that dijkstra2 is now:

(define (dijkstra2 C)

; computes a pair of vectors which contain
; (1) the costs of the shortest paths from vertex 0
; to every vertex in the cost matrix C and
; (2) the immediate predecessor vertexes of every
; vertex in the shortest path

(define n (matrix-col-length C))

(define D (matrix-row-copy C 0))
; shortest distance from vertex 0 to each vertex

(define P (make-vector n 0))
; P[v] contains the vertex immediately before
; vertex v in the shortest path

(define (min-vertex D V)
; chooses a vertex w in V such that D[w] is minimum
(let loop ((w (car V)) (V (cdr V)))
(if (null? V)
w
(if (< (vector-ref D (car V)) (vector-ref D w))
(loop (car V) (cdr V))
(loop w (cdr V))))))

; dijkstra
(let loop ((V (enum 1 (- n 1))))
; V contains the set of vertexes whose shortest
; distance from the vertex 0 is still unknown
(if (null? V)
(cons D P)
(let* ((w (min-vertex D V)) (V-w (remv V w)))
(for-each
(lambda (v)
(if (< (+ (vector-ref D w) (matrix-ref C w v))
(vector-ref D v))
(begin
(vector-set! D v
(+ (vector-ref D w) (matrix-ref C w v))) ;;; added )
(vector-set! P v w)))) ;;; removed )
V-w)
(loop V-w)))))

Now I get:

1 ]=> (dijkstra2 c)

;Value: (#(0 10 50 30 60) . #(0 0 3 0 2))

See comments in code above for the tiny edit (moved a close paren).

Looks like Juha Heinanen 1988 was the original author. Maybe you never ran dijkstra2.

Thank you so much for posting this code. Incredibly helpful to a lisp newbie like me.

关于hit-oslab实验环境问题请教

首先,感谢楼主提供的环境资源分享。但是现在我的64位环境采用make编译linux-0.11出现了as86:Command not found的问题,所以在此处想请教一下楼主该如何解决,谢谢啦!

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.