學校練習題目(數列比較和砲彈投擲) 請高手幫忙><

1. Bubble sorting compares each pair of adjacent items and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed
For sorting the array 51428. 
First Pass
( 5 1 4 2 8 )->( 1 5 4 2 8 ), 5>1, swap
( 1 5 4 2 8 )->( 1 4 5 2 8 ), 5>4, swap
( 1 4 5 2 8 )->( 1 4 2 5 8 ), 5>2, swap
( 1 4 2 5 8 )->( 1 4 2 5 8 ), 5<8, no swap
Second Pass
( 1 4 2 5 8 )->( 1 4 2 5 8 ), 1<4, no swap
( 1 4 2 5 8 )->( 1 2 4 5 8 ), 4>2, swap
( 1 2 4 5 8 )->( 1 2 4 5 8 ), 4<5, no swap
Third Pass
( 1 4 2 5 8 )->( 1 4 2 5 8 ), 1<4, no swap
( 1 2 4 5 8 )->( 1 2 4 5 8 ), 2>4, no swap
Please Generate 1024 0~10000 random values and put them into a 1D array. Visualize the sorting process on a waveform graph with a slightly delay.

2. Design a VI to predict the trajectory of a cannonball out of a canon on the ground. Draw a horizontal ground surface in the front panel with decoration elements. With four controls, including the initial velocity, initial angle, percentage of energy loss when the ball hit the ground, and the threshold of energy the cannonball will not bounce again. 
Try to draw the trajectory of the cannonball with a LED in the front panel and update the coordinate with property nodes. Please consider gravity but ignore the air drag effect. 
Try to tune the parameters to have the ball bounce 3 times before it stay on the ground, and make the final parameters as default values saved with the VI.  

建議自行搜尋泡沫排序法關鍵字Bubble sorting

題目可能有誤,首先Second Pass結束跟Third Pass開始不同
( 1 2 4 5 8 )->( 1 2 4 5 8 ), 4<5, no swap
Third Pass
( 1 4 2 5 8 )->( 1 4 2 5 8 ), 1<4, no swap
( 1 2 4 5 8 )->( 1 2 4 5 8 ), 2>4, no swap

修正之後,swap過程也要跟著修改。順序應該是:
( 1 2 4 5 8 )->( 1 2 4 5 8 ), 4<5, no swap
Third Pass
( 1 2 4 5 8 )->( 1 2 4 5 8 ), 1<2, no swap
( 1 2 4 5 8 )->( 1 2 4 5 8 ), 2<4, no swap

如果你寫到一個程度了,上傳寫到一半的檔案上來,我會比較有辦法知道你的瓶頸在哪裡。
如果真的連開始都不容易,可以點出你現在會做到哪些步驟,但是出現了什麼狀況的疑問 [抓圖]

[QUOTE=yamato]1. Bubble sorting compares each pair of adjacent items and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed
For sorting the array 51428. 
First Pass
( 5 1 4 2 8 )->( 1 5 4 2 8 ), 5>1, swap
( 1 5 4 2 8 )->( 1 4 5 2 8 ), 5>4, swap
( 1 4 5 2 8 )->( 1 4 2 5 8 ), 5>2, swap
( 1 4 2 5 8 )->( 1 4 2 5 8 ), 5<8, no swap
Second Pass
( 1 4 2 5 8 )->( 1 4 2 5 8 ), 1<4, no swap
( 1 4 2 5 8 )->( 1 2 4 5 8 ), 4>2, swap
( 1 2 4 5 8 )->( 1 2 4 5 8 ), 4<5, no swap
Third Pass
( 1 4 2 5 8 )->( 1 4 2 5 8 ), 1<4, no swap
( 1 2 4 5 8 )->( 1 2 4 5 8 ), 2>4, no swap
Please Generate 1024 0~10000 random values and put them into a 1D array. Visualize the sorting process on a waveform graph with a slightly delay.

2. Design a VI to predict the trajectory of a cannonball out of a canon on the ground. Draw a horizontal ground surface in the front panel with decoration elements. With four controls, including the initial velocity, initial angle, percentage of energy loss when the ball hit the ground, and the threshold of energy the cannonball will not bounce again. 
Try to draw the trajectory of the cannonball with a LED in the front panel and update the coordinate with property nodes. Please consider gravity but ignore the air drag effect. 
Try to tune the parameters to have the ball bounce 3 times before it stay on the ground, and make the final parameters as default values saved with the VI.   [/QUOTE]MingYen42481.5773148148