vj1073 4-Hanoi-Tower

vj1073 4-Hanoi-Tower - / / i i-2 i-1 i / / f [ i ] = 2 * f...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//±ÉÈ˵ĴíÎóÏë·¨ //ÒªÒƶ¯ i ¸öÅÌ×Ó ÏÈ°ÑÇ° i-2 ¸öÒƵ½Ò»¸öÖмäÖùÉÏ ÔÙ°ÑµÚ i-1 ¸öÒƵ½ÁíÒ»¸öÖù×ÓÉÏ ÕâÑù¾ÍÄÜ°ÑµÚ i ¸öÒƵ½Ä¿±êÉÏ //ÓÉ´ËÍƵù«Ê½Îª f [ i ] = 2 * f [ i-2 ] + 3 / //ÆäʵÉÏÊöÇé¿ö¿ÉÒÔ¹é½á³É °ÑÇ° i-2 ¸öÅÌ×Óͨ¹ý 4 ¸öÖù×ÓÒƵ½Ò»¸öÖмäÖùÉÏ ÔÙ °ÑÊ£ÏÂÁ½¸öÅÌ×Óͨ¹ý 3 ¸öÖù×ÓÒƵ½Ä¿±êÉÏ ×îºóͨ¹ý 4 ¸öÖù×Ó°ÑÇ° i-2 ¸öÒƵ½Ä¿±êÖù //Éè f3[ i ] f4[ i ] ·Ö±ðΪ 3 ¸öÖù×Ó ºÍ 4 ¸öÖù×Ó Òƶ¯ i ¸öÅÌ×ÓµÄ×îÓŽâ //´Ë·½·¨ÎÊÌâÔÚÓÚ 2*f4[i-2]+f3[2] ²¢²»ÊÇ f4[i] µÄ×îÓŽâ ÐèҪö¾Ùͨ¹ý 4 ¸öÖù×ÓÒƶ¯µÄÅÌ×Ó¸öÊý //¼´ f4[i]=min(2*f4[j]+f3[i-j]) (j<i) //ÕâÑùµÄʱ¼ä¸´ÔÓ¶ÈΪ O(n^2)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/21/2011 for the course CS 001 taught by Professor 001 during the Spring '11 term at Shandong University.

Ask a homework question - tutors are online