Ex4-22 單射函數問題
« 問題描述:
設函數f將點集S = {0,1, , n -1}映射為f (S) = { f (i) | iÎ S} Í S 。單射函數問題要
從S中選取最大子集X Í S 使f (X )是單射函數。
例如,當n=7, f (S) = {1,0,0,2,2,3,6} Í S 時, X = {0,1,6} Í S 是所求的最大子集。
« 編程任務:
對于給定的點集S = {0,1, , n -1}上函數f,試用抽象數據類型隊列,設計一個O(n)時
間算法,計算f的最大單射子集。
« 數據輸入:
由文件input.txt 提供輸入數據。文件的第1 行有1 個正整數n,表示給定的點集
S = {0,1, , n -1}。第2 行是f (i)的值,0 £ i < n。
« 結果輸出:
程序運行結束時,將計算出的f的最大單射子集的大小輸出到output.txt中。
輸入文件示例 輸出文件示例
input.txt
7
1 0 0 2 2 3 6
output.txt
3
標簽:
Iacute
61516
laquo
Icirc
上傳時間:
2016-05-28
上傳用戶:tyler
% EM algorithm for k multidimensional Gaussian mixture estimation
%
% Inputs:
% X(n,d) - input data, n=number of observations, d=dimension of variable
% k - maximum number of Gaussian components allowed
% ltol - percentage of the log likelihood difference between 2 iterations ([] for none)
% maxiter - maximum number of iteration allowed ([] for none)
% pflag - 1 for plotting GM for 1D or 2D cases only, 0 otherwise ([] for none)
% Init - structure of initial W, M, V: Init.W, Init.M, Init.V ([] for none)
%
% Ouputs:
% W(1,k) - estimated weights of GM
% M(d,k) - estimated mean vectors of GM
% V(d,d,k) - estimated covariance matrices of GM
% L - log likelihood of estimates
%
標簽:
multidimensional
estimation
algorithm
Gaussian
上傳時間:
2013-12-03
上傳用戶:我們的船長