## Part 1

1. ½Ð¸ÑÄÀ¬°¦ó»Ý­n¨Ï¥Îµ}²¨¯x°}¡H
Ans: ­Y¤@­Ó¯x°}¤¤ªº¤j³¡¤À¤¸¯À¬°¹s¡A«h¦¹¯x°}¬°µ}²¨¯x°}¡A­Y±Ä¨ú¤@¯ë¯x°}ªºÀx¦s¤è¦¡¡A«h¨ä¨Ï¥Îªº°O¾ÐÅéªÅ¶¡©M¯x°}Á¤¸¯À­Ó¼Æ¦¨¥¿¤ñ¡A³y¦¨°O¾ÐÅéªÅ¶¡ªº®ö¶O¡A¦]¦¹§Ú­Ì¥²¶·±Ä¥Îµ}²¨¯x°}ªº°}¦CÀx¦s¤è¦¡¡A¤~¯à§Q¥Î¸û¤Öªº°O¾ÐÅéªÅ¶¡¨ÓÀx¦s³o¤@Ãþµ}²¨¯x°}¡C
2. ½Ð¨Ï¥Î MATLAB ªº sparse «ü¥O¡A²£¥Í¤@­Ó 5x10 µ}²¨¯x°} S¡A¥]§t¥H¤U¤¸¯À¡G (1,4)=5 (5,1)=1 (4,3)=7
Ans: S=sparse([1 5 4],[4 1 3], [5 1 7],5,10);
3. °²³]¦³¤@­Ó 100X100 ªº¯x°} A¡A¨ä¤¸¯À¤j³¡¤À¬O¹s¡A¥u¦³¤U¦C´X­Ó¯S©w¤¸¯À¤£¬°¹s¡G A(1, 3)=4 A(2, 5)=10 A(35, 70)=4 A(54, 98)=5
1. ½Ð¥Î sparse «ü¥O¨Ó«Ø¥ß¦¹µ}²¨¯x°} A¡C
2. A ¦û±¼¦h¤Ö¦ì¤¸²Õ¡H
3. ­Y A ¬O§¹¥þ¯x°}¡A¥B¬O double ªº¸ê®Æ«¬ºA¡A«h·|¦û¥h¦h¤Ö¦ì¤¸²Õ¡H
4. ­Y A ¬O§¹¥þ¯x°}¡A¥B¬O uint8 ªº¸ê®Æ«¬ºA¡A«h·|¦û¥h¦h¤Ö¦ì¤¸²Õ¡H
5. ¨Ï¥Î spy ¨Óµe¥X«D¹s¤¸¯Àªº¤À§Gª¬ªp¡C
Hint: 16*nnz + 8*n + 8 > 8*m*n
5. µ}²¨¯x°}¥u¦s«D¹s¤¸¯À¬O¬°¤F¸¬Ù°O¾ÐÅéªÅ¶¡¡C½Ð¤À§O­pºâ 8x4 ¤Î 4x8 ªº double ¯x°}¤¤¡A¯àÅýµ}²¨¯x°}¹F¨ì¥Øªº¤§«D¹s¤¸¯Àªº³Ì¤j­Ó¼Æ¡C¡]°²³]§Ú­Ì¨Ï¥Î MATLAB ²Ä¤Cª©¡C¡^
µª®×¡G13, 11
6. ­Y¤@­Ó 10x10 ¯x°} A ªº¦æ¦C¦¡­È¤£¬° 0¡A½Ð°Ý¡G
8. ­Y nodes = [0 1 1 2 2 ]¡A½Ð°Ý treeplot(nodes) ·|µe¥Xªº¾ðª¬¹Ï¬°¦ó¡H
Ans: o / \ o \ / \ \ o o o
Ans: ¥ý±N¯x°}§ï¥Îµ}²¨¯x°}ªº«¬ºA¶i¦æÀx¦s¡A¦A¥Îeigs()¹ï¯x°}¨D¯S¼x­È§Y¥i¡C

## Part 2

1. Scenic spot identification: In this exercise, you are going to deal with a real-world problem of extracting scenic spots from the latitude & longitude infomation from the photos archives such as flickr. You can download the data file at here, which contains three columns of longitudes, latitude, and URL of the photos. You can plot the data distribution as follows:

Example 1: 05-µ}²¨¯x°}/goShowPhotoLocation.mfid=fopen('photoRawData276299.txt'); contents = textscan(fid, '%f %f %s'); fclose(fid); x=contents{1}; y=contents{2}; h=plot(x, y, '.'); axis image xlabel('Longitude'); ylabel('Latitude'); set(h, 'markersize', 1); print('-dpng', mfilename);

From the above plot, you can almost see the shape of Taiwan. Probably you can also identify several big cities. Our goal is to identify the mostly visited places of Taiwan, or scenic spots. One way to achieve the goal is to partition the whole map into grids and counting the photos in each square. The square with the higher counts will be regarded as the scenic spots. To do so along the x-axis, please following the general steps as follows:
1. Find the center points of each square along the x-axis:
xCenter=linspace(min(x), max(x), m);
Note that m is used to determine the size of each square.
2. Find the boundary of each square along the x-axis:
xBoundary=(xCenter(1:end-1)+xCenter(2:end))/2;
3. Determine the intervl of of each photo's location along the x-axis. For instance, if you want to determine the interval indices of photos 3 to 5 when m=1000, use the command:
squareIndex=rangeSearchBin(x(3:5), xBoundary);
The result is [278; 199; 960]. (Note that rangeSearchBin is available within the Utility Toolbox.)
Please follow the above procedure to find the counts along the y-axis, and then combine them to get the counts for all the squares. When m (resolution on the x-axis) is 1000, n (resolution on the y-axis) is around 1778, so you should initialize a sparse matrix countMat of size m by n to store all the count information. This is just like a 2d histogram.) You need to complete the following tasks, assuming m = 1000.
1. Plot the sparse matrix countMat using spy command as shown next. What is the density of the sparse matrix?

2. Plot the grid lines and the data distribution, and overlay the top-10 scenic spots with their counts, as follows:

Note that you should be able to zoom in to view the details. For instance, you can zoom in the scenic spot at Tainan to get the following plot:

3. Please find a way to specify a region as the scenic spot instead of a single dot. Here you can use convhull to find the region and then plot it on top of the data distribution.
When m is 1000, the size of the square is about 200000/m = 200 meters. This indicates we are interested in big-area scenic spots, such as Taipei 101 and its surroundings. When m is 10000, the size of the square is about 200000/m = 20 meters. This indicates we are interested in small-area scenic spots, possibly some famous restaurant (for example, ¹©®õÂ×). Please repeat the above process when m is 10000.
2. Improvement to scenic spot identification: Apparently the method proposed in the previous exercise for scenic spot identification is not quite satisfactory since some scenic spots are likely to be divided by a grid line. Please propose your own methods and demonstrate the improved results.
3. Tree representation: Plot a tree specified by the vector [0 1 1 2 2 1 6 6 6 7 7 11].

MATLABµ{¦¡³]­p¡G¶i¶¥½g