亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? 11.cpp

?? 《數(shù)據(jù)結(jié)構(gòu)與程序設(shè)計》書本所有源代碼!!!!
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
Error_code B_tree<Record, order>::recursive_remove(   B_node<Record, order> *current, const Record &target)/*Pre:  current is either NULL or      points to the root node of a subtree of a B_tree.Post: If a Record with Key matching that of target belongs to the subtree,      a code of success is returned and the corresponding node is removed      from the subtree so that the properties of a B-tree are maintained.      Otherwise, a code of not_present is returned.Uses: Functions search_node, copy_in_predecessor,      recursive_remove (recursively), remove_data, and restore.*/{   Error_code result;   int position;   if (current == NULL) result = not_present;   else {      if (search_node(current, target, position) == success) {  //  The target is in the current node.         result = success;         if (current->branch[position] != NULL) {     //  not at a leaf node            copy_in_predecessor(current, position);            recursive_remove(current->branch[position],                             current->data[position]);         }         else remove_data(current, position);     //  Remove from a leaf node.      }      else result = recursive_remove(current->branch[position], target);      if (current->branch[position] != NULL)         if (current->branch[position]->count < (order - 1) / 2)            restore(current, position);   }   return result;}template <class Record, int order>void B_tree<Record, order>::remove_data(B_node<Record, order> *current,                                        int position)/*Pre:  current points to a leaf node in a B-tree with an entry at position.Post: This entry is removed from *current.*/{   for (int i = position; i < current->count - 1; i++)      current->data[i] = current->data[i + 1];   current->count--;}template <class Record, int order>void B_tree<Record, order>::copy_in_predecessor(                    B_node<Record, order> *current, int position)/*Pre:  current points to a non-leaf node in a B-tree with an entry at position.Post: This entry is replaced by its immediate predecessor under order of keys.*/{   B_node<Record, order> *leaf = current->branch[position];  //   First go left from the current entry.   while (leaf->branch[leaf->count] != NULL)      leaf = leaf->branch[leaf->count]; //   Move as far rightward as possible.   current->data[position] = leaf->data[leaf->count - 1];}template <class Record, int order>void B_tree<Record, order>::restore(B_node<Record, order> *current,                                    int position)/*Pre:  current points to a non-leaf node in a B-tree; the node to which      current->branch[position] points has one too few entries.Post: An entry is taken from elsewhere to restore the minimum number of      entries in the node to which current->branch[position] points.Uses: move_left, move_right, combine.*/{   if (position == current->count)   //  case:  rightmost branch      if (current->branch[position - 1]->count > (order - 1) / 2)         move_right(current, position - 1);      else         combine(current, position);   else if (position == 0)       //  case: leftmost branch      if (current->branch[1]->count > (order - 1) / 2)         move_left(current, 1);      else         combine(current, 1);   else                          //  remaining cases: intermediate branches      if (current->branch[position - 1]->count > (order - 1) / 2)         move_right(current, position - 1);      else if (current->branch[position + 1]->count > (order - 1) / 2)         move_left(current, position + 1);      else         combine(current, position);}template <class Record, int order>void B_tree<Record, order>::move_left(B_node<Record, order> *current,                                      int position)/*Pre:  current points to a node in a B-tree with more than the minimum      number of entries in branch position and one too few entries in branch      position - 1.Post: The leftmost entry from branch position has moved into      current, which has sent an entry into the branch position - 1.*/{   B_node<Record, order> *left_branch = current->branch[position - 1],                         *right_branch = current->branch[position];   left_branch->data[left_branch->count] = current->data[position - 1];  //  Take entry from the parent.   left_branch->branch[++left_branch->count] = right_branch->branch[0];   current->data[position - 1] = right_branch->data[0];  //   Add the right-hand entry to the parent.   right_branch->count--;   for (int i = 0; i < right_branch->count; i++) {   //  Move right-hand entries to fill the hole.      right_branch->data[i] = right_branch->data[i + 1];      right_branch->branch[i] = right_branch->branch[i + 1];   }   right_branch->branch[right_branch->count] =      right_branch->branch[right_branch->count + 1];}template <class Record, int order>void B_tree<Record, order>::move_right(B_node<Record, order> *current,                                       int position)/*Pre:  current points to a node in a B-tree with more than the minimum      number of entries in branch position and one too few entries      in branch position + 1.Post: The rightmost entry from branch position has moved into      current, which has sent an entry into the branch position + 1.*/{   B_node<Record, order> *right_branch = current->branch[position + 1],                         *left_branch = current->branch[position];   right_branch->branch[right_branch->count + 1] =      right_branch->branch[right_branch->count];   for (int i = right_branch->count ; i > 0; i--) {  //  Make room for new entry.      right_branch->data[i] = right_branch->data[i - 1];      right_branch->branch[i] = right_branch->branch[i - 1];   }   right_branch->count++;   right_branch->data[0] = current->data[position]; //  Take entry from parent.   right_branch->branch[0] = left_branch->branch[left_branch->count--];   current->data[position] = left_branch->data[left_branch->count];}template <class Record, int order>void B_tree<Record, order>::combine(B_node<Record, order> *current,                                    int position)/*Pre:  current points to a node in a B-tree with entries in the branches      position and position - 1, with too few to move entries.Post: The nodes at branches position - 1 and position have been combined      into one node, which also includes the entry formerly in current at      index  position - 1.*/{   int i;   B_node<Record, order> *left_branch = current->branch[position - 1],                         *right_branch = current->branch[position];   left_branch->data[left_branch->count] = current->data[position - 1];   left_branch->branch[++left_branch->count] = right_branch->branch[0];   for (i = 0; i < right_branch->count; i++) {      left_branch->data[left_branch->count] = right_branch->data[i];      left_branch->branch[++left_branch->count] =                                        right_branch->branch[i + 1];   }   current->count--;   for (i = position - 1; i < current->count; i++) {      current->data[i] = current->data[i + 1];      current->branch[i + 1] = current->branch[i + 2];   }   delete right_branch;}// Section 11.4:enum Color {red, black};template <class Record>struct RB_node: public Binary_node<Record> {   Color color;   RB_node(const Record &new_entry) { color = red; data = new_entry;                                      left = right = NULL; }   RB_node()                { color = red; left = right = NULL; }   void set_color(Color c)  { color = c; }   Color get_color() const  { return color; }};template <class Entry>struct Binary_node {   Entry data;   Binary_node<Entry> *left;   Binary_node<Entry> *right;   virtual Color get_color() const { return red; }   virtual void set_color(Color c) { }   Binary_node()                   { left = right = NULL; }   Binary_node(const Entry &x)     { data = x; left = right = NULL; }};template <class Record>class RB_tree: public Search_tree<Record> {public:   Error_code insert(const Record & new_entry);private:  //  Add prototypes for auxiliary functions here.};enum RB_code {okay, red_node, left_red, right_red, duplicate};/*  These outcomes from a call to the recursive insertion function describethe following results:okay:      The color of the current root (of the subtree) has not changed;           the tree now satisfies the conditions for a red-black tree.red_node:  The current root has changed from black to red; modification           may or may not be needed to restore the red-black properties.right_red: The current root and its right child are now both red;           a color flip or rotation is needed.left_red:  The current root and its left child are now both red;           a color flip or rotation is needed.duplicate: The entry being inserted duplicates another entry; this is           an error.*/template <class Record>Error_code RB_tree<Record>::insert(const Record &new_entry)/*Post: If the key of new_entry is already in the RB_tree, a code of duplicate_error      is returned.  Otherwise, a code of success is returned and the Record new_entry is      inserted into the tree in such a way that the properties of an RB-tree      have been preserved.Uses: Methods of struct RB_node and recursive function rb_insert.*/{   RB_code status = rb_insert(root, new_entry);   switch (status) {   //  Convert private RB_code to public Error_code.      case red_node:             //  Always split the root node to keep it black.         root->set_color(black); /*  Doing so prevents two red nodes at the top                  of the  tree and a resulting attempt to rotate                  using a parent node that does not exist. */      case okay:         return success;      case duplicate:         return duplicate_error;      case right_red:      case left_red:         cout << "WARNING: Program error detected in RB_tree::insert" << endl;         return internal_error;   }}template <class Record>RB_code RB_tree<Record>::rb_insert(Binary_node<Record> *&current,                                   const Record &new_entry)/*Pre:  current is either NULL or points to the      first node of a subtree of an RB_treePost: If the key of new_entry is already in the subtree, a code of duplicate      is returned.  Otherwise, the Record new_entry is inserted into the subtree      pointed to by current.  The properties of a red-black tree have been      restored, except possibly at the root current and one of its children,      whose status is given by the output RB_code.Uses: Methods of class RB_node, rb_insert recursively, modify_left,      and modify_right.*/{   RB_code status,           child_status;   if (current == NULL) {      current = new RB_node<Record>(new_entry);      status = red_node;   }   else if (new_entry == current->data)      return duplicate;   else if (new_entry < current->data) {      child_status = rb_insert(current->left, new_entry);      status = modify_left(current, child_status);   }   else {      child_status = rb_insert(current->right, new_entry);      status = modify_right(current, child_status);   }   return status;}template <class Record>RB_code RB_tree<Record>::modify_left(Binary_node<Record> *&current,                                     RB_code &child_status)/*Pre:  An insertion has been made in the left subtree of *current that      has returned the value of child_status  for this subtree.Post: Any color change or rotation needed for the tree rooted at current      has been made, and a status code is returned.Uses: Methods of struct RB_node, with rotate_right,      double_rotate_right, and flip_color.*/{   RB_code status = okay;   Binary_node<Record> *aunt = current->right;   Color aunt_color = black;   if (aunt != NULL) aunt_color = aunt->get_color();   switch (child_status) {   case okay:      break;         //  No action needed, as tree is already OK.   case red_node:      if (current->get_color() == red)         status = left_red;      else         status = okay;        //  current is black, left is red, so OK.      break;   case left_red:      if (aunt_color == black) status = rotate_right(current);      else                     status = flip_color(current);      break;   case right_red:      if (aunt_color == black) status = double_rotate_right(current);      else                     status = flip_color(current);      break;   }   return status;}/*************************************************************************/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
97久久人人超碰| 国产精品私房写真福利视频| 久久一区二区三区国产精品| 国产精品午夜在线观看| 免费欧美在线视频| 91视频国产观看| 久久免费精品国产久精品久久久久| 亚洲欧美福利一区二区| 国产成人精品一区二| 欧美一二区视频| 亚洲一二三四在线| 95精品视频在线| 欧美国产一区二区在线观看| 久久99九九99精品| 欧美日本在线观看| 亚洲一区二区三区中文字幕| proumb性欧美在线观看| 国产区在线观看成人精品| 日本在线不卡一区| 欧美色男人天堂| 亚洲人一二三区| 99视频精品在线| 中文字幕一区二区三中文字幕| 久久99精品久久久久久国产越南| 欧美丰满一区二区免费视频| 一区二区三国产精华液| 成人av在线影院| 欧美激情综合网| 成人app软件下载大全免费| 国产亚洲污的网站| 成人一区二区三区在线观看| 26uuu色噜噜精品一区二区| 久久国产精品99精品国产| 在线电影国产精品| 日日夜夜免费精品视频| 欧美裸体bbwbbwbbw| 性做久久久久久免费观看| 欧美人xxxx| 日本中文字幕一区二区视频| 欧美一级日韩一级| 国内精品伊人久久久久av影院 | 日韩一级免费观看| 免费在线视频一区| 久久综合色播五月| 成人一区在线看| 亚洲免费三区一区二区| 91黄色免费网站| 日韩av不卡在线观看| 日韩午夜激情视频| 国产mv日韩mv欧美| 亚洲人被黑人高潮完整版| 欧美日精品一区视频| 免费观看30秒视频久久| 久久久久国产精品麻豆ai换脸 | 99视频一区二区| 一区二区三区在线观看网站| 欧美精品精品一区| 国产精品自在在线| 亚洲精品成人在线| 日韩一区二区三区电影在线观看| 国产一区二区三区在线观看免费| 欧美国产精品久久| 色狠狠色狠狠综合| 九色综合狠狠综合久久| 中文字幕高清一区| 这里只有精品电影| 成人福利在线看| 亚洲福利视频一区二区| 欧美成人精品福利| 色系网站成人免费| 免费在线欧美视频| 亚洲欧美经典视频| 久久天堂av综合合色蜜桃网| 色综合中文字幕| 国产一区二区三区久久悠悠色av| 亚洲人成伊人成综合网小说| 正在播放一区二区| 97久久久精品综合88久久| 日韩成人精品在线观看| 国产精品不卡在线| 精品国产乱码久久久久久图片| 99久久伊人久久99| 黄网站免费久久| 偷偷要91色婷婷| 国产精品毛片高清在线完整版| 欧美日韩成人在线| 91免费国产在线| 国产一区二区主播在线| 日韩中文字幕一区二区三区| 国产精品―色哟哟| 精品久久久久久久一区二区蜜臀| 91久久线看在观草草青青| 看电视剧不卡顿的网站| 亚洲综合免费观看高清在线观看| 久久精品在这里| 日韩欧美国产一区二区在线播放| 99国产精品视频免费观看| 国产一区二区三区精品欧美日韩一区二区三区 | 337p日本欧洲亚洲大胆精品| 欧美伊人久久久久久久久影院 | 久久国产欧美日韩精品| 亚洲国产综合在线| 亚洲黄色av一区| 国产精品久久久久影院亚瑟 | 最好看的中文字幕久久| 欧美韩国日本一区| 精品国产制服丝袜高跟| 日韩欧美不卡一区| 日韩欧美国产综合| 欧美不卡一区二区| 日韩午夜激情视频| 日韩精品一区国产麻豆| 日韩亚洲欧美综合| 欧美成人女星排名| 精品国产亚洲一区二区三区在线观看| 欧美精三区欧美精三区| 欧美喷潮久久久xxxxx| 欧美日韩精品二区第二页| 欧美视频在线一区| 欧美日韩午夜在线| 欧美绝品在线观看成人午夜影视| 欧洲亚洲精品在线| 欧美系列日韩一区| 欧美午夜精品免费| 在线成人高清不卡| 欧美成人精品3d动漫h| 337p日本欧洲亚洲大胆色噜噜| 久久综合九色综合欧美98| 久久久久久97三级| 国产精品久久久久一区二区三区| 中文字幕二三区不卡| 亚洲视频每日更新| 亚洲一区在线视频| 美女任你摸久久 | 青青草97国产精品免费观看无弹窗版| 天天综合网天天综合色| 精品一区二区三区免费毛片爱| 激情综合网天天干| 成人免费视频app| 色国产综合视频| 日韩欧美一二三四区| 国产精品婷婷午夜在线观看| 亚洲色图欧美激情| 日韩高清欧美激情| 国产米奇在线777精品观看| 91小视频在线观看| 欧美一卡二卡在线| 中文字幕av资源一区| 亚洲大型综合色站| 国产不卡视频在线观看| 欧美特级限制片免费在线观看| 日韩一区二区三区观看| 国产精品毛片久久久久久久| 亚洲va韩国va欧美va| 国产精品18久久久久久vr| 91丨porny丨首页| 日韩免费电影一区| 亚洲裸体xxx| 激情图片小说一区| 欧美午夜片在线观看| 久久久精品天堂| 图片区小说区区亚洲影院| 懂色av一区二区夜夜嗨| 在线观看91av| 一区二区在线看| 国产一区欧美一区| 91精品久久久久久蜜臀| 国产精品电影一区二区三区| 日本欧美在线观看| 91蝌蚪porny九色| 国产亚洲自拍一区| 日本成人在线一区| 色狠狠色噜噜噜综合网| 中文在线一区二区| 国产一区二区在线影院| 欧美一区二区三区在| 亚洲最新视频在线观看| 国产99久久久国产精品潘金| 在线观看91av| 亚洲福利视频一区| 91浏览器打开| 综合在线观看色| 国产精品99久久不卡二区| 精品少妇一区二区三区免费观看| 亚洲午夜精品网| 色视频一区二区| 亚洲日本一区二区| 成人av电影在线网| 国产精品午夜电影| 国产精品99久久久久久有的能看| 日韩午夜在线影院| 日本在线不卡视频一二三区| 欧美三级日本三级少妇99| 中文字幕亚洲电影| 91欧美一区二区| 成人免费在线观看入口| 成人在线综合网站| 中文字幕中文字幕一区二区 | 蜜臀av亚洲一区中文字幕| 欧美日韩一级黄|