锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久久99精品成人片试看,久久综合色区,蜜桃麻豆www久久http://m.shnenglu.com/Husiwa/category/15704.htmlzh-cnFri, 17 Dec 2010 01:15:59 GMTFri, 17 Dec 2010 01:15:59 GMT60鎶婁簩鍏冩煡鎵炬爲(wèi)杞彉鎴愭帓搴忕殑鍙屽悜閾捐〃http://m.shnenglu.com/Husiwa/archive/2010/12/17/136705.htmlHusiwaHusiwaFri, 17 Dec 2010 00:58:00 GMThttp://m.shnenglu.com/Husiwa/archive/2010/12/17/136705.htmlhttp://m.shnenglu.com/Husiwa/comments/136705.htmlhttp://m.shnenglu.com/Husiwa/archive/2010/12/17/136705.html#Feedback0http://m.shnenglu.com/Husiwa/comments/commentRss/136705.htmlhttp://m.shnenglu.com/Husiwa/services/trackbacks/136705.html

鍘熸枃鍦板潃錛?a >http://zhedahht.blog.163.com/blog/static/254111742007127104759245/
棰樼洰錛氳緭鍏ヤ竴媯典簩鍏冩煡鎵炬爲(wèi)錛屽皢璇ヤ簩鍏冩煡鎵炬爲(wèi)杞崲鎴愪竴涓帓搴忕殑鍙屽悜閾捐〃銆傝姹備笉鑳藉垱寤轟換浣曟柊鐨勭粨鐐癸紝鍙皟鏁存寚閽堢殑鎸囧悜銆?/span>

銆銆姣斿灝嗕簩鍏冩煡鎵炬爲(wèi)
    
                                        10
                                          /    \
                                        6       14
                                      /  \     /銆 \
                                   銆4     8  12 銆  16
杞崲鎴愬弻鍚戦摼琛?/span>

4=6=8=10=12=14=16銆?/span>

銆銆鍒嗘瀽錛氭湰棰樻槸寰蔣鐨勯潰璇曢銆傚緢澶氫笌鏍?wèi)鐩稿叧鐨勯鐩兘鏄敤閫掑綊鐨勬濊礬鏉ヨВ鍐籌紝鏈?shù)篃涓嶄緥澶栥備笅闈㈡垜浠敤涓ょ涓嶅悓鐨勯掑綊鎬濊礬鏉ュ垎鏋愩?/span>

銆銆鎬濊礬涓錛氬綋鎴戜滑鍒拌揪鏌愪竴緇撶偣鍑嗗璋冩暣浠ヨ緇撶偣涓烘牴緇撶偣鐨勫瓙鏍?wèi)鏃跺Q屽厛璋冩暣鍏跺乏瀛愭爲(wèi)灝嗗乏瀛愭爲(wèi)杞崲鎴愪竴涓帓濂藉簭鐨勫乏瀛愰摼琛紝鍐嶈皟鏁村叾鍙沖瓙鏍?wèi)铦{鎹㈠彸瀛愰摼琛ㄣ傛渶榪戦摼鎺ュ乏瀛愰摼琛ㄧ殑鏈鍙崇粨鐐癸紙宸﹀瓙鏍?wèi)鐨勬渶澶х粨鐐癸級(jí)銆佸綋鍓嶇粨鐐瑰拰鍙沖瓙閾捐〃鐨勬渶宸︾粨鐐癸紙鍙沖瓙鏍?wèi)鐨勬渶灝忕粨鐐癸級(jí)銆備粠鏍?wèi)鐨勬牴缁撶偣寮濮嬮掑綊璋冩暣鎵鏈夌粨鐐廣?/span>

銆銆鎬濊礬浜岋細(xì)鎴戜滑鍙互涓簭閬嶅巻鏁存5鏍?wèi)銆傛寜鐓ц繖涓柟寮忛亶鍘嗘爲(wèi)錛屾瘮杈冨皬鐨勭粨鐐瑰厛璁塊棶銆傚鏋滄垜浠瘡璁塊棶涓涓粨鐐癸紝鍋囪涔嬪墠璁塊棶榪囩殑緇撶偣宸茬粡璋冩暣鎴愪竴涓帓搴忓弻鍚戦摼琛紝鎴戜滑鍐嶆妸璋冩暣褰撳墠緇撶偣鐨勬寚閽堝皢鍏墮摼鎺ュ埌閾捐〃鐨勬湯灝俱傚綋鎵鏈夌粨鐐歸兘璁塊棶榪囦箣鍚庯紝鏁存5鏍?wèi)涔煘p漿鎹㈡垚涓涓帓搴忓弻鍚戦摼琛ㄤ簡(jiǎn)銆?/span>

鍙傝冧唬鐮侊細(xì)

棣栧厛鎴戜滑瀹氫箟浜屽厓鏌ユ壘鏍?wèi)缁撶偣鐨勬暟鎹l撴瀯濡備笅錛?br style="LINE-HEIGHT: 22px">    struct BSTreeNode // a node in the binary search tree
    {
        int          m_nValue; // value of node
        BSTreeNode  *m_pLeft;  // left child of node
        BSTreeNode  *m_pRight; // right child of node
    };

鎬濊礬涓瀵瑰簲鐨勪唬鐮侊細(xì)
///////////////////////////////////////////////////////////////////////
// Covert a sub binary-search-tree into a sorted double-linked list
// Input: pNode - the head of the sub tree
//        asRight - whether pNode is the right child of its parent
// Output: if asRight is true, return the least node in the sub-tree
//         else return the greatest node in the sub-tree
///////////////////////////////////////////////////////////////////////
BSTreeNode* ConvertNode(BSTreeNode* pNode, bool asRight)
{
      if(!pNode)
            return NULL;

      BSTreeNode *pLeft = NULL;
      BSTreeNode *pRight = NULL;

      // Convert the left sub-tree
      if(pNode->m_pLeft)
            pLeft = ConvertNode(pNode->m_pLeft, false);

      // Connect the greatest node in the left sub-tree to the current node
      if(pLeft)
      {
            pLeft->m_pRight = pNode;
            pNode->m_pLeft = pLeft;
      }

      // Convert the right sub-tree
      if(pNode->m_pRight)
            pRight = ConvertNode(pNode->m_pRight, true);

      // Connect the least node in the right sub-tree to the current node
      if(pRight)
      {
            pNode->m_pRight = pRight;
            pRight->m_pLeft = pNode;
      }

      BSTreeNode *pTemp = pNode;

      // If the current node is the right child of its parent, 
      // return the least node in the tree whose root is the current node
      if(asRight)
      {
            while(pTemp->m_pLeft)
                  pTemp = pTemp->m_pLeft;
      }
      // If the current node is the left child of its parent, 
      // return the greatest node in the tree whose root is the current node
      else
      {
            while(pTemp->m_pRight)
                  pTemp = pTemp->m_pRight;
      }
 
      return pTemp;
}

///////////////////////////////////////////////////////////////////////
// Covert a binary search tree into a sorted double-linked list
// Input: the head of tree
// Output: the head of sorted double-linked list
///////////////////////////////////////////////////////////////////////
BSTreeNode* Convert(BSTreeNode* pHeadOfTree)
{
      // As we want to return the head of the sorted double-linked list,
      // we set the second parameter to be true
      return ConvertNode(pHeadOfTree, true);
}

鎬濊礬浜屽搴旂殑浠g爜錛?br style="LINE-HEIGHT: 22px">///////////////////////////////////////////////////////////////////////
// Covert a sub binary-search-tree into a sorted double-linked list
// Input: pNode -           the head of the sub tree
//        pLastNodeInList - the tail of the double-linked list
///////////////////////////////////////////////////////////////////////
void ConvertNode(BSTreeNode* pNode, BSTreeNode*& pLastNodeInList)
{
      if(pNode == NULL)
            return;

      BSTreeNode *pCurrent = pNode;

      // Convert the left sub-tree
      if (pCurrent->m_pLeft != NULL)
            ConvertNode(pCurrent->m_pLeft, pLastNodeInList);

      // Put the current node into the double-linked list
      pCurrent->m_pLeft = pLastNodeInList; 
      if(pLastNodeInList != NULL)
            pLastNodeInList->m_pRight = pCurrent;

      pLastNodeInList = pCurrent;

      // Convert the right sub-tree
      if (pCurrent->m_pRight != NULL)
            ConvertNode(pCurrent->m_pRight, pLastNodeInList);
}

///////////////////////////////////////////////////////////////////////
// Covert a binary search tree into a sorted double-linked list
// Input: pHeadOfTree - the head of tree
// Output: the head of sorted double-linked list
///////////////////////////////////////////////////////////////////////
BSTreeNode* Convert_Solution1(BSTreeNode* pHeadOfTree)
{
      BSTreeNode *pLastNodeInList = NULL;
      ConvertNode(pHeadOfTree, pLastNodeInList);

      // Get the head of the double-linked list
      BSTreeNode *pHeadOfList = pLastNodeInList;
      while(pHeadOfList && pHeadOfList->m_pLeft)
            pHeadOfList = pHeadOfList->m_pLeft;

      return pHeadOfList;
}



Husiwa 2010-12-17 08:58 鍙戣〃璇勮
]]>
久久青青草原精品国产| 国内精品人妻无码久久久影院| 国产成人精品久久综合| 久久激情亚洲精品无码?V| 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 亚洲人成网站999久久久综合| 久久只这里是精品66| 久久久久人妻一区精品色 | 欧美亚洲另类久久综合| 亚洲第一永久AV网站久久精品男人的天堂AV | 一级A毛片免费观看久久精品| 97超级碰碰碰久久久久| 色综合久久久久综合99| 91精品国产综合久久精品| 大香伊人久久精品一区二区| 久久精品国产免费| 亚洲国产精品无码久久98| 国产免费久久久久久无码| 久久久久亚洲AV成人片| 午夜视频久久久久一区 | 久久国产劲爆AV内射—百度| aaa级精品久久久国产片| 久久综合久久美利坚合众国| 国产高潮国产高潮久久久91 | 久久国产福利免费| 久久精品中文騷妇女内射| 亚洲欧美国产精品专区久久 | 亚洲va中文字幕无码久久| 亚洲人成无码久久电影网站| 四虎国产永久免费久久| 久久精品国产亚洲AV高清热| 精品伊人久久大线蕉色首页| 亚洲欧美日韩精品久久亚洲区 | 国产一区二区精品久久| 新狼窝色AV性久久久久久| 三级三级久久三级久久| 亚洲精品乱码久久久久久蜜桃 | 色综合久久88色综合天天 | 久久精品亚洲欧美日韩久久| 国产精品伊人久久伊人电影| 亚洲国产精品久久久久|