function [] = exercise_1_2_3() % % Written by: % -- % John L. Weatherwax 2007-07-11 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- close all; % the range of n: % n=8:16; % the first algorithm's running time: % fa = 100*(n.^2); % the second algorithms running time: % sa = 2.^n; figure; hfa = plot( n, fa, '-rx' ); hold on; hsa = plot( n, sa, '-bo' ); grid on; legend( [ hfa hsa ], 'quadratic algorithm', 'exponential algorithm' ); xlabel( 'n (steps)' ); ylabel( 'running time' ); % n=14:15; 100*(n.^2) - 2.^n