作者kevinying (police_is_dog)
看板Grad-ProbAsk
標題[商管] array相關的題目
時間Fri Mar 9 01:39:59 2012
不好意思題目有點多, 想請各位大大解答..
這幾題搞懂高第一近四年的題目就比較沒問題..
1.
Figure 1 is a tree representation of disjoint sets.
Finish the following array representation for these disjoint sets.
Figure1:
http://imageshack.us/f/13/79152975.jpg/
這題0~8我依序寫:-1, 0, 1, 6, 3, 6, -1, 6, -1
不知道有沒有錯, 麻煩各位大大幫忙看一下 :D
2.
我們用整數0到51來代表52張撲克牌, 順序依序是黑桃A, 黑桃2, ...., 黑桃K, 紅心A,
紅心2, ...., 紅心K, 方塊A, 方塊2, ...., 方塊K, ...., 梅花K.
現在利用一維陣列 card[0]...card[4] 來存5張撲克牌的對應資訊, 例如 card[0]=24,
card[1]=21, card[2]=20, card[3]=15, card[4]=14 代表下列情況
http://imageshack.us/f/803/29279249.jpg/
card[0]=47, card[1]=20, card[2]=45, card[3]=18, card[4]=30 代表下列情況
http://imageshack.us/f/32/75194676.jpg/
假設已經給定 card[0], ...., card[5]的值, 範圍介於0到51, 未排序,
分別撰寫一程式片段(可用C/C++或Java,並加註解說明), 來判斷陣列card 所代表的5張牌
(1) 是否是"同花"的牌型(五張牌都是同一花色)
(2) 是否是"順子"的牌型(五張牌恰好牌點差一, 須考慮AJQK也是順子)
3.
一個一般化方形矩陣An,n如下圖(A)所示, 共有 nxn個元素. 圖(B)為A4,4之範例,
假設此方陣內元素依序存在一維陣列B中, 而儲存方式為右下左上交錯如圖(B)的存放方式,
依序如圖(B)中的順序A(1,1)-> B(1) ; A(2,1)-> B(2) ; A(1,2)-> B(3) ;
A(1,3)-> B(4) ; A(4,4)-> B(16)
圖A與圖B:
http://imageshack.us/f/37/29640777.jpg/
(1) 在A100,100中, A(50,50) 在陣列B中排在什麼位置?
(2) 假設在A100,100中 A(i,j)排在陣列B中的B(2010), 問i和j值各位多少?
4.
If there are n values held in an array a[n], determine the number of values can be held in
(a) b[n][n2][n3]
(b) c[n][n-1]...[2]
這一題我看不懂在問什麼QQ
5.
A matrix consists of 4 rows and 5 columns of numbers as follows
圖:
http://imageshack.us/f/692/42725079m.jpg/
(1) A sparse matrix can be represented by using array of triples
<row, col, value>.
Write down the sparse matrix representation of the above matrix using
an array of triples <row, col, value>
(2) Write down the transpose of the above matrix using sparse
matrix representation
(3) Write an algorithm (using pseudo code) to transpose a
sparse matrix which is represented by an array of triples <row, col, value>
(4) What is the time complexity of your algorithm?
我會寫(1),但(2)-(4)就看不太懂了@@"
題目有點多...麻煩各位大大幫忙解答...謝謝!!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.40.68.235
1F:推 simonjoker:第4題是問3維的矩陣跟N維的矩陣分別可以存多少值吧? 03/09 11:59