锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久久99精品成人片试看,久久综合色区,蜜桃麻豆www久久http://www.shnenglu.com/Husiwa/category/15704.htmlzh-cnFri, 17 Dec 2010 01:15:59 GMTFri, 17 Dec 2010 01:15:59 GMT60鎶婁簩鍏冩煡鎵炬爲(wèi)杞彉鎴愭帓搴忕殑鍙屽悜閾捐〃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/
棰樼洰錛氳緭鍏ヤ竴媯典簩鍏冩煡鎵炬爲(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 鍙戣〃璇勮
]]>
久久精品亚洲欧美日韩久久| 久久无码中文字幕东京热| 香蕉久久夜色精品升级完成| 亚洲乱码精品久久久久..| 久久99国产综合精品| 久久国产精品二国产精品| 久久久久亚洲国产| 色综合久久精品中文字幕首页| 久久亚洲天堂| 狠狠色丁香久久综合婷婷| 久久综合九色综合久99| 久久人人爽人人爽人人片av高请| 91久久九九无码成人网站| 亚洲色欲久久久综合网| 狠狠人妻久久久久久综合| 麻豆一区二区99久久久久| 精品久久人人做人人爽综合| 久久亚洲欧美国产精品| 性高湖久久久久久久久AAAAA| 99久久成人国产精品免费| 久久久久久久精品成人热色戒| 成人精品一区二区久久| 国内精品久久久久久久97牛牛| 麻豆精品久久久久久久99蜜桃| 久久久WWW免费人成精品| 久久精品国产一区二区三区日韩| 偷窥少妇久久久久久久久| 国产亚洲美女精品久久久| 国产韩国精品一区二区三区久久 | 亚洲国产精品无码久久久不卡| 99久久精品国产综合一区| 99久久99久久久精品齐齐| 久久精品亚洲AV久久久无码| 少妇久久久久久被弄到高潮| 国内精品久久久久久久久电影网| 久久精品国产亚洲av高清漫画| 人妻无码αv中文字幕久久琪琪布 人妻无码久久一区二区三区免费 人妻无码中文久久久久专区 | 久久久久久久精品成人热色戒| 久久久无码精品午夜| 欧美午夜A∨大片久久 | 97香蕉久久夜色精品国产|