技事録

大学で人工知能の研究しています.

Algorithm

二分探索木

先日の大学院の入試でデータ構造の定義や挿入のプログラム記述などピンポイントで出ました.超ラッキー binary search tree

ヒープとヒープソート

ヒープの生成とヒープソートをC言語で書きました.Gist初めてつかってみます. Heap

クイックソート

C言語でクイックソートです. #include <stdio.h> #include <stdlib.h> #define swap(type, x ,y) do {type t = x; x = y; y = t;} while(0) void __quick_sort ( int* a, int left, int right ) { int pl, pr; int mid; int pivot; if ( left < right ) { // 中央の要素をpivot</stdlib.h></stdio.h>…

マージソート

久々にC言語つかいました. 院試勉強の一環ですが懐かしい... #include <stdio.h> #include <stdlib.h> int *buff; // 再帰呼び出し用 void __merge_sort ( int* a, int left, int right ) { if ( left < right ) { int mid = ( left + right ) / 2; // 左半分ソートの再帰呼</stdlib.h></stdio.h>…