平成26年度大学院修士全科生入学者選考筆記試験問題 第2問
(1)
(ア)完全2分木の葉の数は2^n、葉以外のノードの数は2^n-1
(イ)木が持ち得る葉の最小の数は2^1で2、最大の数は2^\inftyで\inftyだろうか...
(2)
(ア)10011
(イ)引数の値を2進数に変換する
こういうのは実際に書くのが一番確実ですね。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdlib.h> | |
#include<stdio.h> | |
void func(int n){ | |
int q,r; | |
if(n < 0){ | |
return; | |
} | |
q = n / 2; | |
r = n % 2; | |
if(q > 0){ | |
func(q); | |
} | |
printf("%d",r); | |
return; | |
} | |
int main(int argc, char *argv[]){ | |
func(atoi(argv[1])); | |
} |
平成25年度大学院修士全科生入学者選考筆記試験問題 第2問
(1)C言語の特徴とよく使われる分野はまとめるのは大変なのでwikipediaを見てね。
(2)
(ア)34512 -> 34152 -> 34125 -> 31425-> 31245 -> 13245 -> 12345
(イ)数字を降順にソートする機能。根拠は...すべての値に対してデータの比較と交換を行っているからでしょうか?
(ウ)(n-1)+(n-2)+\cdots+3+2+1=\dfrac{n(n-1)}{2}
(エ)O(n^2)