id
int64
0
25.6k
text
stringlengths
0
4.59k
24,000
notes printf "\ /traverse the entire linked list *while !null printf "% " -data -link printf "\ /counts the number of nodes present in the linked list representing stack *count struct node int /traverse the entire linked list *while !null -link +return summary stack is linear data structure having very interesting prop...
24,001
postfixnotation of an arithmetic expression in which operators come after their operands notes prefixnotation of an arithmetic expression in which operators come before their operands pushstack operation which puts value on the stack stacka linear data structure where insertion and deletion of elements can take place o...
24,002
notes review questions write an algorithm to reverse an input string of characters using stack explain how function calls may be implemented using stacks for return values what are the advantages of implementing stack using dynamic memory allocation method trace the execution of infix-to-postfix algorithm on the follow...
24,003
further readings books notes brian kernighan and dennis ritchiethe programming languageprentice hall data structures and algorithmsshi-kuo changworld scientific data structures and efficient algorithmsburkhard monienthomas ottmannspringer kruse data structure program designprentice hall of indianew delhi mark allen wel...
24,004
anil sharmalovely professional university unit queues notes contents objectives introduction queue model array implementation array-based implementation pointer-based implementation applications of queues summary keywords self assessment review questions further readings objectives after studying this unityou will be a...
24,005
notes queue operations in pseudo-codeenqueue(qxq[tail[ ]< if tail[qlength[qthen tail[ < else tail[ <tail[ dequeue(qx < [head[ ]if head[qlength[qthen head[ < else head[ <head[ return these are also ( time operations figure shows the operations on queue figure operations on queue frontrear (aempty queue front rear (ba in...
24,006
notes array implementation here toothere are two possible implementation strategies one where the memory is used statically and the other where memory is used dynamically array-based implementation to represent queue we require one-dimensional array of some maximum size say to hold the data items and two other variable...
24,007
notes /this function checks if the queue is empty or not if( front = rearreturn(trueelse return(false)void initialize(queue []/this procedure initializes queue front rear an important point to be noticed in the above implementation is that the queue has tendency to move to the right unless occasionally 'frontcatches up...
24,008
notes an implementation of the circular queue is shown belowstruct cqueue data[ ]int frontrearvoid insert(queue [] /this procedure inserts an element into the queue * rear ( rear nif( rear = frontprintf("queue full")else data[ rearxvoid delete(queue qt /deletes an element stores it in *if( front = rearprintf("queue emp...
24,009
pointer-based implementation notes as in stacksa queue could be implemented using linked list queue can be implemented by the following declarations and algorithmsstruct queuenode itemqueuenode *next}struct queuenode*front*rearvoid insert(queuenode *frontqueuenode *reart estruct queuenode *xx new(queuenode) ->item eif(...
24,010
notes applications of queues one major application of the queue data structure is in the computer simulation of real-world situation queues are also used in many ways by the operating systemthe program that schedules and allocates the resources of computer system one of these resources is the cpu (central processing un...
24,011
notes if(front =nullfront xx->next nullrear / is the first node being added to the priority queue*elseif(front->priority px->next frontfront / has the highest priority hence should be at the front*elseif(rear->priority px->next nullrear->next xrear / has the least priority hence should be at the rear*else / has to be i...
24,012
notes case study convert an infix expression to prefix form #include #include #include #define typedef enum {falsetruebool#include "stack #include "queue #define nops char operators ["()^/*+-"int priorities[{ , , , , , , }char associates[rllll"char [ ]char *tptr /this is where prefix will be saved int getindexchar op /...
24,013
notes performs processing of op *switch(opcase ')'printf"\ pushing \ )spushsop )breakcase '('while!qempty( *tptr+qpop( )printf"\tq popping % \ "*(tptr- )while!sempty(schar popop spop( )printf"\ts popping % \ "popop )ifpopop =')break*tptr+popopbreakdefaultint priop/priority of op char topop/operator on stack top int pri...
24,014
notes printf"\ts pushing % \ "op )spushsop )breakbool isopchar op /is op an operator*return (getindex(op!- )char *in prechar *str /returns valid infix expr in str to prefix *char *sptrqueue {null}stack nullchar *res (char *)mallocn*sizeof(char)char *resptr restptr tforsptr=str+strlen(str)- sptr!=str- -sptr printf"proce...
24,015
notes *tptr printf" =% \ " )for-tptrtptr!= - -tptr *resptr+*tptr*resptr return resint main(char [ ]puts"enter infix freespaces max )gets( )while(*sputsin pre( )gets( )return explanation in an infix expressiona binary operator separates its operands ( unary operator precedes its operandin postfix expressionthe operands ...
24,016
notes summary queue is list of elements in which insertions are made at one end called the rear and deletions are made from the other end called the front queue exhibits the fifo (first in first outproperty to represent queue we require one-dimensional array of some maximum size say to hold the data items and two other...
24,017
more efficient queue representation is obtained by regarding the array of elements of queue to be queue could be implemented using reverse polish notation is also called is used in time-sharing multi-user systems where programs of high priority are processed first amid programs with the same priority form standard queu...
24,018
notes answersself assessment ( ( circular linked list postfix notation priority queue fifo (first in first out arraylinked list priority queue further readings books brian kernighan and dennis ritchiethe programming languageprentice hall data structures and algorithmsshi-kuo changworld scientific data structures and ef...
24,019
unit trees unit trees notes contents objectives introduction concept of tree binary tree types of binary tree properties of binary tree binary representation implementation of binary tree binary tree traversal order of traversal of binary tree procedure for inorder traversal summary keywords self assessment review ques...
24,020
notes concept of tree tree is set of one or more nodes such that there is specially designated node called rootand remaining nodes are partitioned into > disjoint set of nodes ,tn each of which is tree shown below in figure is structurewhich is tree figure tree structure this is tree because it is set of nodes {abcdefg...
24,021
notes consider the tree given in figure figure the degree of each node of the treenode degree the degree of the treemaximum (degree of all the nodes the level of nodes of the treenode task level in figure calculate the degree of true binary tree binary tree is special tree where each non-leaf node can have atmost two c...
24,022
notes in formal waywe can define binary tree as finite set of nodes which is either empty or partitioned in to sets of tltrwhere is the root and tl and tr are left and right binary treesrespectively figure binary tree structure sofor binary tree we find that the maximum number of nodes at level will be - if is the dept...
24,023
complete binary tree notes complete binary tree of depth is tree with nodes in which these nodes can be numbered sequentially from to nas if it would have been the first nodes in full binary tree of depth complete binary tree with depth is shown in figure figure complete binary tree properties of binary tree main prope...
24,024
notes array tree an array representation of complete binary tree having nodes and depth shown in figure is another example of an array representation of complete binary tree with depth with the number of nodes array tree an array representation of complete binary tree with nodes and depth in generalany binary tree can ...
24,025
and deletion in tree costly thereforeinstead of using an array representationwe can use linked representationin which every node is represented as structure with three fieldsone for holding dataone for linking it with the left subtreeand the third for linking it with right subtree as shown herenotes leftchild data righ...
24,026
notes the leftthen make your new element as the left child of that current element or else compare it with the existing left child and follow the same rule exactlythe same has to done for the case when your new element is greater than the current element in the tree but this time with the right child though this logic ...
24,027
notes curr->right newprogrambinary tree creation array-based representation of binary tree consider complete binary tree having nodes where each node contains an item (valuelabel the nodes of the complete binary tree tht from top to bottom and from left to right - associate with the array where the entry of is the item...
24,028
notes wherel stands for traversing the left sub-treer stands for traversing the right sub-treeand stands for processing the data of the node thereforethe order ldr is the order of traversal in which we start with the root nodevisit the left sub-tree firstthen process the data of the root nodeand then go for visiting th...
24,029
notes different order path in figure areinorder postorderabc*+de*given an order of traversal of tree it is possible to construct tree exampleconsider the following orderinorder dbeac we can construct the binary trees shown below in figure using this order of traversala binary trees constructed using given inorder there...
24,030
notes unique binary constructed using the inorder and postorder procedure for inorder traversal void inorder(tnode *pif( !nullinorder( ->lchild)printf( ->data)inorder( ->rchild) non-recursive/iterative procedure for traversing binary tree in inorder is given below for the purpose of doing the analysis void inorder(tnod...
24,031
notes stack[top]top top-lprintf( ->data) ->rchildif( !null/*push right child*top top+ stack[toppp ->lchildanalysis consider the iterative version of the inorder given above if the binary tree to be traversed is having nodesthen the number of nil links is since every node is placed on the stack oncethe statements stack[...
24,032
notes consider the following example given the preorder and inorder traversal of binary tree draw the tree and write down its postorder traversal inorderzaqpyxcb preorderqazypcxb to obtain the binary tree take the first node in preorderit is root nodewe then search for this node in the inorder traversalall the nodes to...
24,033
notes tnode *tempif( !nullswaptree( -> child)swaptree( ->rchild)temp -> childp-> child ->rchildp->rchild tempthe following function checks whether the two binary trees are equal or not boolean equal(tnode * tnode * boolean ansif(( =null&( =null)ans trueelse if((( ==null)&&( !=null))||(( !=null)&&( ==null))ans falseelse...
24,034
notes new(tnode) ->data ->dataq->lchild copytree( ->lchild) ->rchild copytree( ->rchild)return( ) summary tree is set of one or more nodes such that there is specially designated node called rootand remaining nodes are partitioned into disjoint set of nodes the degree of node of tree is the number of sub-trees having t...
24,035
self assessment notes in the context of the figure given below give the answers of self assessment what is the degree of node ( ( ( ( what is the degree of node ( ( ( ( what is the level of node ( ( ( ( what is the level of node ( ( ( ( fill in the blanks to delete node from binary search tree the method to be used dep...
24,036
notes how many binary trees are possible with three nodes construct binary tree whose in-order and pre-order traversal is given below in-order , , , , , , , , pre-order , , , , , , , , what do you mean by binary treealso explain the various properties of binary tree consider the tree given below(afind the degree of eac...
24,037
inorderpostorderpreorder ternary terminal/leaf true true true notes further readings books brian kernighan and dennis ritchiethe programming languageprentice hall data structures and algorithmsshi-kuo changworld scientific data structures and efficient algorithmsburkhard monienthomas ottmannspringer kruse data structur...
24,038
mandeep kaurlovely professional university unit binary search tree and avl trees notes contents objectives introduction binary search tree counting the number of nodes in binary search tree searching for target key in binary search tree deletion of node from binary search tree deletion of node with two children deletio...
24,039
notes tree shown below in figure is binary search treefigure binary search tree binary search tree is basically binary treeand therefore it can be traversed is inorderpreorderand postorder if we traverse binary search tree in inorder and print the identifiers contained in the nodes of the treewe get sorted list of iden...
24,040
notes when temp becomes nilthe new node is inserted as left child of the node pointed to by temp if data value of the node pointed to by temp is greater than data value supplied as parameter otherwise the new node is inserted as right child of node pointed to by temp therefore the insert procedure is void insert(tnode ...
24,041
counting the number of nodes in binary search tree notes counting the number of nodes in given binary treethe tree is required to be traversed recursively until leaf node is encountered when leaf node is encountereda count of is returned to its previous activation (which is an activation for its parent)which takes the ...
24,042
notes else temp /traverse the tree to get pointer to that node whose child will be the newly created node*while(temp !nulltemp temp iftemp ->data valtemp temp ->lchildelse temp temp ->rchildiftemp ->data valtemp ->lchild (struct tnode*)malloc(sizeof(struct tnode))*inserts the newly created node as left child*temp temp ...
24,043
notes return( )/ function to binary tree in inorder *void inorder(struct tnode *pif( !nullinorder( ->lchild)printf("% \ ", ->data)inorder( ->rchild)void main(struct tnode *root nullint ,xprintf("enter the number of nodes\ ")scanf("% ",& )whilen -- printf("enter the data value\ ")scanf("% ",& )root insert(root, )inorder...
24,044
notes boolean search(tnode *pint valboolean anstnode *temptemp pans falsewhile ((temp !null&(!ans)if(temp->data =valans trueelse if(temp->data valtemp temp->leftelse temp temp->right deletion of node from binary search tree there is another simple situationsuppose the node we're deleting has only one subtree in the fol...
24,045
notes which we normally drawl finallylet us consider the only remaining casehow to delete node having two subtrees for examplehow to delete ` 'we' like to do this with minimum amount of work and disruption to the structure of the tree the standard solution is based on this ideawe leave the node containing ` exactly whe...
24,046
notes here it isl so our general algorithm isto delete nif it has two subtreesreplace the value in with the largest value in its left subtree and then delete the node with the largest value from its left subtree note the largest value in the left subtree will never have two subtrees whybecause if it' the largest value ...
24,047
notes figure deletion of nod having left and right child now we need todelete this empty node shown in figure thereforethe final structure would be figure figure tree alter deletion of node having left and right child deletion of node with one child consider the binary search tree shown below in figure figure binary tr...
24,048
notes if we want to delete node pointed to by xthen we can do it as followslet be pointer to the node which is the root of the node pointed to by make the left child of the node pointed by to be the right child of the node pointed by xand dispose the node pointed by as shown below in figure figure binary tree after del...
24,049
figure binary tree after deletion of node pointed to by notes nil nil nil search for key in bst to search the binary tree for particular nodewe use procedures similar to those we used when adding to it beginning at the root nodethe current node and the entered key are compared if the values are equal success is output ...
24,050
notes else there is no left subtree return (string not foundelse if (key-value value stored in current nodeif (right child existsfind-key (key-valuerot child)else there is no right subtreereturn (string not foundlab exercise programc program to delete nodewhere the data value of the node to be deleted is knownis as fol...
24,051
notes else * temp/*store this pointer as root *if(temp->data keytemp temp->lchildelse temp temp->rchildreturn(null)/ function to delete the node whose data value is given *struct tnode *delete(struct tnode * ,int valstruct tnode * * *tempx getptr( ,val,& )ifx =nullprintf("the node does not exists\ ")return( )else /this...
24,052
notes temp ->lchildy->lchild ->lchildwhile(temp->rchild !nulltemp temp->rchildtemp->rchild= ->rchildx->lchild=nullx->rchild=nullelse temp ->rchildy->rchild ->rchildwhile(temp->lchild !nulltemp temp->lchildtemp->lchild= ->lchildx->lchild=nullx->rchild=nullfree( )return( )/this code is for deleting node with on child*if(...
24,053
notes return( )/this code is for deleting node with no child*if( ->lchild =null & ->rchild =nullif( ->lchild =xy->lchild null else ->rchild nullfree( )return( )/*an iterative function to print the binary tree in inorder*void inorder (struct tnode *pstruct tnode *stack[ ]int toptop - if( !nulltop++stack[toppp ->lchildwh...
24,054
notes / function to insert new node in binary search tree to get tree created*struct tnode *insert(struct tnode * ,int valstruct tnode *temp ,*temp if( =nullp (struct tnode *malloc(sizeof(struct tnode))/insert the new node as root node*if( =nullprintf("cannot allocate\ ")exit( ) ->data valp->lchild= ->rchild=nullelse t...
24,055
notes exit( )temp ->data valtemp ->lchild=temp ->rchild nullelse temp ->rchild (struct tnode*)malloc(sizeof(struct tnode));*inserts the newly created node as left child*temp temp ->rchildif(temp =nullprintf("cannot allocate\ ")exit( )temp ->data valtemp ->lchild=temp ->rchild nullreturn( )void main(struct tnode *root n...
24,056
notes explanation this program first creates binary tree with specified number of nodes with their respective data values it then takes the data value of the node to be deletedobtains pointer to the node containing that data valueand obtains another pointer to the root of the node to be deleted depending on whether the...
24,057
notes tnode *rootkey itemint nroot nullprintf("number of data values:")scanf("% "& )whilen printf("enter the data value")scanf("% "item)insert(rootitem) - printtree(root)task discuss how will you delete node with one child avl tree an avl tree is another balanced binary search tree it takes its name from the initials o...
24,058
notes sub-tree)balanced (both sub-trees are the same heightor right-heavy (the height of the right sub-tree is greater than the left sub-treeif the balance would be destroyed by an insertiona rotation is performed to correct the balance let us consider the following avl tree in which node has been inserted in the left ...
24,059
to fix thiswe must perform left rotationrooted at this is done in the following stepsnotes becomes the new root takes ownership of ' left child as its right childor in this casenull takes ownership of as its left child the tree now looks like thisb / right rotation (rra right rotation is mirror of the left rotation ope...
24,060
notes our initial reaction here is to do single left rotation let' try that our left rotation has completedand we're stuck in the same situation if we were to do single right rotation in this situationwe would be right back where we started what' causing thisthe answer is that this is result of the right subtree having...
24,061
right-left rotiation (rlor "double rightnotes double right rotationor right-left rotationor simply rlis rotation that must be performed when attempting to balance tree which has left subtreethat is right heavy this is mirror operation of what was illustrated in the section on left-right rotationsor double left rotation...
24,062
notes this is tree which can now be balanced using single right rotation we can now perform our right rotation rooted at the resultb / balance at last avl operation insertion into avl trees to implement avl treesyou need to maintain the height of each node you insert into an avl tree by performing standard binary tree ...
24,063
notes howeversuppose now try to insert waluigi get the following treeeunice fred binky baby daisy calista ahmed luther daisy waluigi traveling from the new node to the rooti see that fred violates the balance condition it' left child has height of - and its right child has height of have to rebalance the tree rebalanci...
24,064
notes node is the new root of the subtree before the insertionnode ' height was - so the height of the subtree has not changed because of the rotation thusinsertion is overand you are left with valid avl tree if the path from the imbalanced node to the newly added node starts with two left childrenthen you have another...
24,065
notes - - - - - or - - or - second rotation about once againthe height of the subtree before deletion was - so when you're done with the double rotationyou are done your tree is balanced againthe mirror image case is treated in the exact same manner here' an example suppose our tree is the followingrather large treeeun...
24,066
notes daisy eunice binky baby daisy ahmed calista dontonio luther boo fred waluigi deletion when you delete nodethere are three things that can happen to the parent its height is decremented by one an example of this is if boo is deleted from the above tree baby daisy' height is decremented by one its height doesn' cha...
24,067
the imbalanced node is if the height of subtree is - then the height of will be - and the tree is zig-zig you can rebalance by rotating about node if the height of subtree is - then the height of is - and the tree is zig-zag you rebalance by doing double rotation about the root of if both and have heights of - then you...
24,068
notes firsteunice has two children sowe find the child with the greatest key in eunice' left subtreewhich is dontoniodelete itand replace eunice with dontonio we start by deleting dontoniodaisy eunice binky baby daisy calista luther ahmed boo fred and we start checking at eunice it is imbalanced looking at itwe see tha...
24,069
/void printtree--print tree in sorted order notes /******************errors*******************************/throws underflowexception as warranted template class avltree publicavltreerootnull avltreeconst avltree rhs rootnull *this rhs~avltreemakeempty)/*find the smallest item in the tree throw underflowexception if emp...
24,070
notes /*returns true if is found in the tree *bool containsconst comparable xint &comps const return containsxrootcomps)/*test if the tree is logically empty return true if emptyfalse otherwise *bool isemptyconst return root =null/*print the tree contents in sorted order *void printtreeconst ifisemptycout <"empty tree<...
24,071
notes void insertconst comparable insertxroot )/*remove from the tree nothing is done if is not found *void removeconst comparable cout <"sorryremove unimplemented< <still present<endl/*deep copy *const avltree operator=const avltree rhs ifthis !&rhs makeempty)root clonerhs root )return *thisprivatestruct avlnode compa...
24,072
notes avlnode *root/*internal method to insert into subtree is the item to insert is the node that roots the subtree set the new root of the subtree *void insertconst comparable xavlnode ift =null new avlnodexnullnull )else ifx element insertxt->left )ifheightt->left heightt->right = ifx left->element rotatewithleftchi...
24,073
notes ift =null return nullift->left =null return treturn findmint->left )/*internal method to find the largest item in subtree return node containing the largest item *avlnode findmaxavlnode * const ift !null whilet->right !null ->rightreturn /*internal method to test if an item is in subtree is item to search for is ...
24,074
notes ifx element ->leftelse ift->element ->rightelse return truereturn false/match /no match *****************************************************/*internal method to make subtree empty *void makeemptyavlnode ift !null makeemptyt->left )makeemptyt->right )delete tt null/*internal method to print subtree rooted at in s...
24,075
notes *avlnode cloneavlnode * const ift =null return nullelse return new avlnodet->elementclonet->left )clonet->right ) ->height )/avl manipulations /*return the height of node or - if null *int heightavlnode * const return =null - ->heightint maxint lhsint rhs const return lhs rhs lhs rhs/*rotate binary tree node with...
24,076
notes update heightsthen set new root *void rotatewithrightchildavlnode avlnode * ->rightk ->right ->leftk ->left ->height maxheightk ->left )heightk ->right ->height maxheightk ->right ) ->height /*double rotate binary tree nodefirst left child with its right childthen node with new left child for avl treesthis is dou...
24,077
applications of avl trees notes avl trees are applied in the following situations there are few insertion and deletion operations short search time is needed input data is sorted or nearly sorted avl tree structures can be used in situations which require fast searching butthe large cost of rebalancing may limit the us...
24,078
notes self assessment state whether the following statements are true or false binary search tree is not binary tree which may be fulland every node contains an identifier dictionary is an ordered list which is required to be searched frequentlyand is also required to be updated frequently avl tree invented by adelsonv...
24,079
show the keys with which each of the following targets will be compared in search of the preceding binary search tree notes insert each of the following keys into the preceding binary search tree show the comparisons of keys that will be made in each case do each part independentlyinserting the key into the original tr...
24,080
notes answersself assessment false true true false true postorder binary search tree delete node adding characters further readings books brian kernighan and dennis ritchiethe programming languageprentice hall burkhard moniendata structures and efficient algorithmsthomas ottmannspringer krusedata structure program desi...
24,081
unit splay trees unit splay trees notes contents objectives introduction splay trees operations splay operation rotations splay tree application summary keywords self assessment review questions further readings objectives after studying this unityou will be able todescribe splay trees explain splay tree operation intr...
24,082
notes operations splay trees support the following operations we write for setsx for elements and for key values splay(skreturns an access to an element with key in the set in case no such element existswe return an access to the next smaller or larger element split(skreturns (s_ ,s_ )where for each in s_ holdskey[ < a...
24,083
splay tree application notes the application is lexicographic search tree (lstfigure an example of lst in lst all the circles and squares are the nodes of the tree each node will contain character and the square nodes are terminal nodes of the strings there are two kinds of edgessolid line edges and dashed line edges i...
24,084
notes figure splay character 'ain lst splay at 'ad rules for splaying here are the rules for splaying denote the node being accessed as xthe parent of as and the grandparent of as gzigin this casep is the root of the tree zig_leftx if is left child zig_rightx if is right child lovely professional university
24,085
notes figure splay tree zig rotations of node ( )zig_left ( )zig_right zigzagp is not the root of the tree and are opposite types of children (left or rightthe path from to is "crooked zig_right_zag_left if is right child and is left child zig_left_zag_right if is left child and is right child lovely professional unive...
24,086
notes figure splay tree zig_zag rotations of node ( )zig_right_zag_left ( )zig_left_zag_right zigzigp is not the root of the tree and are the same type of children (left or rightxp and are in straight line zig_zig_left if and are both right children zig_zig_right if and are both left children figure splay tree zig_zig ...
24,087
notes (bzig_zag_right splay tree algorithms to show that splay trees deliver the promised amortized performancewe define potential function ph(tto keep track of the extra time that can be consumed by later operations on the tree as beforewe define the amortized time taken by single tree operation that changes the tree ...
24,088
notes simple rotation the only two nodes that change rank are and so the cost is '(xr(xr'(yr(ysince decreases in rankthis is at most '(xr(xsince increases in rankr'(xr(xis positive and this is bounded by ( '(xr( )zig-zig rotation only the nodes xyand change in rank since this is double rotationwe assume it has actual c...
24,089
keywords notes access timethe time required to access and retrieve word from high-speed memory is few microseconds at most splay treessplay trees are binary search trees which are self adjusting self assessment choose the appropriate answer splay trees were invented by (asleator (btarjan (cnewton (dboth (aand (bthe run...
24,090
notes consider the following binary search treesplay this tree at each of the following keys in turnd each part builds on the previousthat isuse the final tree of each solution as the starting tree for the next part "splay trees are binary search trees that achieve our goals by being self-adjusting in quite remarkable ...
24,091
thomas cormencharles eleiserson ronald rivestintroduction to algorithmsprentice-hall of india pvt limitednew delhi notes timothy buddclassic data structures in ++addison wesley online links www en wikipedia org www web-source net www webopedia com lovely professional university
24,092
mandeep kaurlovely professional university unit -trees notes contents objectives introduction -trees structure of -trees height of -trees operations on -trees inserting new item -tree-deleting an item -tree algorithms applications summary keywords self assessment review questions further readings objectives after study...
24,093
search treesbut may waste some spacesince nodes are not entirely full the lower and upper bounds on the number of child nodes are typically fixed for particular implementation notes -tree is kept balanced by requiring that all leaf nodes are at the same depth this depth will increase slowly as elements are added to the...
24,094
notes height of -trees for greater than or equal to onethe height of an -key -tree of height with minimum degree greater than or equal to <log + the worst case height is (log nsince the "branchinessof -tree can be large compared to many other balanced tree structuresthe base of the logarithm tends to be largethereforet...
24,095
notes leaf[ <true [ < disk-write(xroot[ < the -tree-create operation creates an empty -tree by allocating new root node that has no keys and is leaf node only the root node is permitted to have these propertiesall other nodes must meet the criteria outlined previously the -tree-create operation runs in time ( -tree-spl...
24,096
notes then <allocate-node(root[ < leaf[ <false [ < < -tree-split-child( rb-tree-insert-nonfull(skelse -tree-insert-nonfull(rkb-tree-insert-nonfull(xki < [xif leaf[xthen while > and keyi[xdo keyi+ [ <keyi[xi < keyi+ [ < [ < [ disk-write(xelse while >and keyi[xdo < < disk-read(ci[ ]if [ci[ ] then -tree-split-child(xici[ ...
24,097
inserting new item notes when inserting an itemfirst do search for it in the -tree if the item is not already in the -treethis unsuccessful search will end at leaf if there is room in this leafjust insert the new item here note that this may require that some existing keys be moved one to the right to make room for the...
24,098
notes the letters fwland are then added without needing any split when is addedthe rightmost leaf must be split the median item is moved up into the parent node note that by moving up the median keythe tree is kept fairly balancedwith keys in each of the resulting nodes the insertion of causes the leftmost leaf to be s...
24,099
notes -tree-deleting an item deletion of key from -tree is possiblehoweverspecial care must be taken to ensure that the properties of -tree are maintained several cases must be considered if the deletion reduces the number of keys in node below the minimum degree of the treethis violation must be corrected by combining...