锘??xml version="1.0" encoding="utf-8" standalone="yes"?>97超级碰碰碰碰久久久久,久久国产精品99久久久久久老狼 ,国产精品亚洲综合专区片高清久久久 http://www.shnenglu.com/Husiwa/category/15704.htmlzh-cnFri, 17 Dec 2010 01:15:59 GMTFri, 17 Dec 2010 01:15:59 GMT60鎶婁簩鍏冩煡鎵炬爲杞彉鎴愭帓搴忕殑鍙屽悜閾捐〃http://www.shnenglu.com/Husiwa/archive/2010/12/17/136705.htmlHusiwaHusiwaFri, 17 Dec 2010 00:58:00 GMThttp://www.shnenglu.com/Husiwa/archive/2010/12/17/136705.htmlhttp://www.shnenglu.com/Husiwa/comments/136705.htmlhttp://www.shnenglu.com/Husiwa/archive/2010/12/17/136705.html#Feedback0http://www.shnenglu.com/Husiwa/comments/commentRss/136705.htmlhttp://www.shnenglu.com/Husiwa/services/trackbacks/136705.html

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

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

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

銆銆鍒嗘瀽錛氭湰棰樻槸寰蔣鐨勯潰璇曢銆傚緢澶氫笌鏍戠浉鍏崇殑棰樼洰閮芥槸鐢ㄩ掑綊鐨勬濊礬鏉ヨВ鍐籌紝鏈涔熶笉渚嬪銆備笅闈㈡垜浠敤涓ょ涓嶅悓鐨勯掑綊鎬濊礬鏉ュ垎鏋愩?/span>

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

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

鍙傝冧唬鐮侊細

棣栧厛鎴戜滑瀹氫箟浜屽厓鏌ユ壘鏍戠粨鐐圭殑鏁版嵁緇撴瀯濡備笅錛?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
    };

鎬濊礬涓瀵瑰簲鐨勪唬鐮侊細
///////////////////////////////////////////////////////////////////////
// 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 鍙戣〃璇勮
]]>
欧美激情精品久久久久久| 国产亚洲美女精品久久久2020| 久久经典免费视频| 99久久夜色精品国产网站| 三上悠亚久久精品| 久久久久久久久久久久中文字幕| 亚洲国产精品无码久久九九| 欧美成人免费观看久久| 亚洲精品无码专区久久同性男| 久久久久99精品成人片三人毛片| 久久国产视频网| 久久中文字幕精品| 日本人妻丰满熟妇久久久久久| 久久久久久夜精品精品免费啦| 国产精品美女久久久久| 99久久精品免费国产大片| 狠狠色综合久久久久尤物| 久久久精品久久久久久 | 久久午夜福利无码1000合集| 久久综合久久美利坚合众国| 人妻无码αv中文字幕久久| 日本道色综合久久影院| 久久九色综合九色99伊人| 99精品国产综合久久久久五月天| 久久综合给合久久国产免费| 日韩亚洲欧美久久久www综合网 | 久久无码精品一区二区三区| 区久久AAA片69亚洲| 久久婷婷综合中文字幕| 热久久视久久精品18| 精品久久久久久久| 亚洲性久久久影院| 国产午夜免费高清久久影院| 青青草国产97免久久费观看| 久久综合国产乱子伦精品免费| 久久久久亚洲AV成人网| 日韩乱码人妻无码中文字幕久久| 国产精品免费看久久久香蕉| 亚洲色欲久久久综合网东京热| 久久93精品国产91久久综合| 久久青青草原精品国产|