[ slady | who is slady | work ] [ ] B-tree animation This page introduces an interactive Java applet animation that demonstrates the principle of a B-Tree data structure. Main functionality is here in showing smoothly the inserting, searching, and deleting process on the btree of chosen order. Main stage This demo displays the view screen in different sizes. You can select your preffered size depe
人生を書き換える者すらいた。: 人材獲得作戦・4 試験問題ほか 次に同じ質問がきたときに 「1時間いらないっしょ、こんなの」 と是非ともほざくために 今から勉強します ダイクストラ法による最短経路探索 図におけるS点からG点に到達するための最短経路を求めたい 各ノードを結ぶエッジを糸としてS点をゆっくりと持ち上げた場合 緊張する糸が変移しながら最終的にS−B−D−Gを結ぶ糸が緊張して これが最短経路と分かる*1 計算機上でこの現象をシミュレートしたものを ダイクストラ法というらしい 今各ノードとそこから伸びるエッジの情報(コストと接続先)を渡して その最短経路および総コストを出力するプログラムを考えてみよう data = { :s => [[5, :a], [4, :b], [2, :c]], :a => [[5, :s], [2, :b], [6, :g]], :b => [[4, :s
1 class AStar 2 3 def initialize(adjacency_func, cost_func, distance_func) 4 @adjacency = adjacency_func 5 @cost = cost_func 6 @distance = distance_func 7 end 8 9 def find_path(start, goal) 10 been_there = {} 11 pqueue = PriorityQueue.new 12 pqueue << [1, [start, [], 0]] 13 while !pqueue.empty? 14 spot, path_so_far, cost_so_far = pqueue.next 15 next if been_there[spot] 16 newpath = path_so_far + [
今すぐお金が必要!でも他社で審査に落ちてしまった、そんな時におすすめの審査が柔軟なキャッシングサービスをご紹介します。
バックトラックとかしなくていいので、結構簡単にできた。 # -*- coding: utf-8 -*- require 'pp' class Graph def initialize(edges) @edges = edges @nodes = Hash.new{|h,k| h[k] = []} end def add_edge(edge) @edges.push edge unless @edges.index(edge) end def add_node(u, v) if @edges.index(u).nil? @edges.push u elsif @edges.index(v).nil? @edges.push v end unless @nodes[u].index(v) @nodes[u].push v end end def breadth_first_search(sta
前回書いた経路探索アルゴリズムA* - gan2 の Ruby 勉強日記が たくさんブクマされててちょっとびっくりです(;゚Д゚) 実装はFlash(Action Script)でやろうと思っていたのですが、 その前にRubyで書いてみることにしました。 途中、アルゴリズムの理解が不十分だったせいもあり、 多少てこづりましたがとりえず完成しました! ソースはあんまり整理してないけども、 あまり気にせずに貼り付けておきます(ノ∀`) =begin **** 経路探索アルゴリズムA*(エースター) a-star.rb **** アルゴリズムの概要 スタートノードから、あるノード n を通って、 ゴールまで辿り着くときの最短路経路を考える。 このとき、最短経路のコスト f(n) を次の式で表す。 f(n) = g(n) + h(n) ここで、g(n) はスタートノードから n までの最小コスト。
By Ilya Grigorik on March 26, 2009 A good choice of an algorithm or a data structure can make or break an application. By and large, Ruby provides enough native primitives such as Array, Hash, and Set, to get you by in most cases, but we've all ran into situations where the performance or the memory footprint of these structures left us wanting for more. Sensing a nice opportunity, Kanwei Li and A
Quiz FAQ Is Ruby Quiz Still Active? Yes, but it's under new management and this is no longer the site for the current challenges. After running three years worth of quizzes, I retired as quizmaster and passed the project on to some loyal fans. New quizzes are still posted to the Ruby Talk mailing list so look for them there if you want to participate. The rest of these questions are left as they w
奥村晴彦さんの「C言語による最新アルゴリズム事典」技術評論社、1991年、の C 言語プログラムの Ruby への翻訳に挑戦します。プログラムの説明は同書を読んでください。変換はできるだけ逐語的に行っています。プログラムの動作は原作の C プログラムのそれと比較してチェックしていますが、うまく動作しないときは C から Ruby への変換のさいに起きたものです。バグレポートは tnomura@mnet.ne.jp までお願いします。 この Ruby 翻訳版はできるだけレイアウトも含めて原作の C プログラムを変更しないようにしたため、必ずしもRuby らしいコーディングスタイルとは言えないかもしれませんが、プログラムがきちんと動作することを優先しました。C から Ruby への翻訳の著作権に関しては Ruby のライセンスに準じます。配布、改変は自由です。ただし、プログラム本体には原作者の
このページは、ソフトバンク パブリッシングから出版されている『プログラミングの宝箱 アルゴリズムとデータ構造』を読んでいるときに、せっかくなのでサンプルコードを Ruby で書き直した場合、どうなるんだろうと思いつつ作っています。 アルゴリズムに関する解説は特にしていませんので、参考書籍をご覧下さい。 また、内容には充分注意していますが、あくまでも僕の勉強メモになっているため、間違いや勘違いがあるかと思います。その点、ご了承いただければ幸いです。同時に間違いや勘違いを発見された方は、メールや掲示板でご指摘いただけると、すごく嬉しいです。 【参考書籍】 紀平拓男、春日伸弥 『プログラミングの宝箱 アルゴリズムとデータ構造』(ソフトバンク パブリッシング 2003) 参考URL:http://www.cmagazine.jp/books/takarabako/
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く