4.3 Balanced Trees. let us assume that we can manipulate them conveniently and see how they can be put together to form trees.

Size: px
Start display at page:

Download "4.3 Balanced Trees. let us assume that we can manipulate them conveniently and see how they can be put together to form trees."

Transcription

1 428 T FOU 4.3 Blned Trees T BT GOIT IN T VIOU setion work well for wide vriety of pplitions, ut they hve poor worst-se performne. s we hve noted, files lredy in order, files in reverse order, files with lternting lrge nd smll keys, or files with ny lrge segment hving suh struture ll led to liner insert nd serh times. We introdue in this setion type of serh tree where osts re gurnteed to e logrithmi, no mtter wht sequene of keys is used to onstrut them. Idelly, we would like keep our trees perfetly lned, of height ~lg N, so tht we n gurntee tht ll serhes in n N-node tree n e ompleted in ~lg N ompres, just s for inry serh (see OOITION B). Unfortuntely, mintining perfet lne for dynmi insertions is too expensive. But we n relx the requirement to hve ner-perfet lne, where the height is gurnteed to e no lrger thn onstnt times lg N, sy 2 lg N. In this setion, we onsider dt struture tht mintins suh property nd provides gurnteed logrithmi performne for the insert nd serh opertions in our symol-tle I. It lso provides gurnteed logrithmi performne for ll of the other opertions (exept rnge serh). 2-3 serh trees The primry step to get the flexiility tht we need to gurntee lne in serh trees is to llow the nodes in our trees to hold more thn one key. peifilly, we refer to the nodes in stndrd BT s 2-nodes (they hold two links nd one key) nd lso llow 3-nodes, whih hold three links nd two keys. very node hs one link for eh of the intervls sutended y its keys. s in BTs, 2-node hs one link to sutree ontining keys smller thn its key nd one link to sutree ontining keys lrger thn its key. 3-node hs one link to sutree ontining keys smller thn oth its keys, one to sutree ontining keys in its two keys, nd one to sutree ontining keys lrger thn oth its keys. ter, we shll see effiient wys to define nd implement the si opertions on these extended nodes; for now, 3-node let us ssume tht we n mnipulte them onveniently nd see how they n e put together to form trees. J 2-node null link ntomy of 2-3 serh tree etion etion 4.3

2 YBO TB 429 Definition 2-3 serh tree is tree tht either is empty or: 2-node, with one key nd two links, left link to sutree with smller keys, nd right link to sutree with lrger keys; 3-node, with two keys nd three links, left link to sutree with smller keys, middle link to sutree with keys the node s keys nd right link to sutree with lrger keys. s usul, we refer to link to n empty tree s null link. perfetly lned 2-3 serh tree is one whose null links re ll the sme distne from the root. To e onise, we use the term 2-3 tree to refer to perfetly lned 2-3 serh tree (the term denotes more generl struture in other ontexts). Next, we desrie the use of 2-3 trees s the underlying dt struture for symol tle. erh. The serh lgorithm for keys in 2-3 tree diretly generlizes the serh lgorithm for BTs. To determine whether key is in the tree, we ompre it ginst the keys t the root: If it is equl to ny of them, we hve serh hit; otherwise, we follow the link from the root to the sutree orresponding to the intervl of key vlues tht ould ontin the serh key, nd then reursively serh in tht sutree. suessful serh for unsuessful serh for B is thn so look to the left B is thn so look to the left J J J is nd so look in the middle B is thn so look to the left J J J found so return vlue (serh hit) B is nd so look in the middle link is null so B is not in the tree (serh miss) uessful nd unsuessful serh in 2-3 tree Blned Trees

3 430 T FOU Insert into 2-node. To insert new node in 2-3 tree, we might do n unsuessful serh nd then hook on the node t the ottom, s we did with BTs, ut the new tree would not remin perfetly lned. The primry reson tht 2-3 trees re useful is tht we n do insertions nd still mintin perfet lne in the tree. It is esy to omplish this tsk if the node t whih the serh termintes is 2-node: We just reple the node with 3-node ontining its key nd the new key to e inserted. If the node where the serh termintes is 3-node, we hve more work to do. inserting K J J K serh for K ends here reple 2-node with new 3-node ontining K Insert into 2-node inserting Insert into tree onsisting of single 3-node. s first wrm-up efore onsidering the generl se, suppose tht we wnt to insert into tiny 2-3 tree onsisting of just single 3-node. uh tree hs two keys, ut no room for new key in its one node. To e le to perform the insertion, we temporrily put the new key into 4-node, nturl extension of our node type tht hs three keys nd four links. reting the 4-node is no room for mke 4-node split 4-node into this 2-3 tree Insert into single 3-node onvenient euse it is esy to onvert it into 2-3 tree mde up of three 2-nodes, one with the middle key (t the root), one with the smllest of the three keys (pointed to y the left link of the root), nd one with the lrgest of the three keys (pointed to y the right link of the root). uh tree is 3-node BT nd lso perfetly lned 2-3 serh tree, with ll the null links re t the sme distne from the root. Before the insertion, the height of the tree is 1; fter the insertion, the height of the tree is 2. This se is simple, ut it is worth onsidering euse it illustrtes height growth in 2-3 trees. inserting Z J J J K Z reple 3-node with temporry 4-node ontining Z reple 2-node with new 3-node ontining middle key Z split 4-node into two 2-nodes pss middle key to prent Insert into 3-node whose prent is 2-node serh for Z ends t this 3-node etion etion 4.3

4 YBO TB 431 Insert into 3-node whose prent is 2-node. s seond wrm-up, suppose tht the serh ends t 3-node t the ottom whose prent is 2-node. In this se, we n still mke room for the new key while mintining perfet lne in the tree, y mking temporry 4-node s just desried, then splitting the 4-node s just desried, ut then inserting the middle key in the node s prent (insted of putting it in its own 2-node). You n think of the trnsformtion s repling the link to the old 3-node in the prent y the middle key with links on either side to the new 2-nodes. By our ssumption, there is room for doing so in the prent: the prent ws 2-node nd eomes 3-node. Be ertin tht you understnd this trnsformtion it is the rux of 2-3 tree dynmis. Insert into 3-node whose prent is 3-node. Now suppose tht the serh ends t node whose prent is 3-node. gin, we mke temporry 4-node s just inserting D serh for D ends t this 3-node split 4-node into two 2-nodes pss middle key to prent split 4-node into three 2-nodes inresing tree height y 1 D dd middle key to 3-node to mke temporry 4-node D J dd new key D to 3-node to mke temporry 4-node J plitting the root J J D desried, then split it nd insert its middle key into the prent. The prent ws 3-node, so we reple it with temporry new 4-node ontining the middle key from the 4-node split. Then, we perform preisely the sme trnsformtion on tht node. Tht is we split the new 4-node nd insert its middle key into its prent. xtending to the generl se is ler: we ontinue up the tree, splitting 4-nodes nd inserting their middle keys in their inserting D serh for D ends t this 3-node dd new key D to 3-node to mke temporry 4-node J D dd middle key to 3-node to mke temporry 4-node prents until rehing 2-node, whih we reple with 3-node tht does not to e further split, or until rehing 3-node t the root. If we end up with temporry 4-node t the root, we split it into three 2-nodes, inressplit 4-node into two 2-nodes pss middle key to prent dd middle key to 2-node to mke new 3-node split 4-node into two 2-nodes pss middle key to prent D J J D J Insert into 3-node whose prent is 3-node Blned Trees

5 432 T FOU ing the height of the tree y 1, in just the sme wy s when inserting into tree onsisting of single 3-node. Note tht this trnsformtion preserves perfet lne in the tree only when it is performed t the root. ol trnsformtions. plitting temporry 4-node in 2-3 tree involves one of five trnsformtions, summrized t the top of the next pge. The 4-node my e the left hild or the right hild of 2-node, or it my e the left hild, middle hild, or right hild of 3-node. The sis of the lgorithm is tht ll of these trnsformtions re purely lol: No prt of the tree needs to e exmined or modified other thn the speified nodes. The numer of links hnged for eh trnsformtion is ounded y smll onstnt. In prtiulr, the trnsformtions re effetive when we find the speified ptterns nywhere in the thn thn nd nd nd d plitting 4-node is lol trnsformtion tree, not just t the ottom. h of the trnsformtions psses up one of the keys from 4-node to tht node s prent in the tree, nd then restrutures links ordingly. Glol properties. oreover, these lol trnsformtions preserve the glol properties tht the tree is ordered nd lned. For referene, omplete digrm illustrting this point for the se tht the 4-node is the middle hild of 3-node is shown here. If you re not fully onvined, you re enourged to work I 4.3., whih sks you to extend the digrms for the other four ses t the top of the next pge to illustrte the sme point. Before the split, if the height of the sutree rooted t ny node in the tree is h, then the height of the sutree rooted t its prent is h+1. h trnsformtion preserves this property, even while splitting the 4-node into two 2-nodes nd while hnging the prent from 2-node to 3-node. or from 3-node into temporry 4-node, or when splitting the root into three 2-nodes nd inresing the height of the whole tree y 1. Understnding tht every trnsformtion preserves order nd perfet lne in the whole tree is the key to understnding the lgorithm. nd e e nd d nd d d d nd e d nd e greter thn e greter thn e etion etion 4.3

6 YBO TB 433 prent is 3-node prent is 2-node left d e d e left d d middle e e right d d d d right d d e e plitting temporry 4-node in 2-3 tree (summry) UNIK TNDD BT, WI GOW DOWN from the top, 2-3 trees grow up from the ottom. If you tke the time to refully study the sequene of trees tht re produed y our stndrd indexing test lient nd the sequene of trees tht re produed when the sme keys re inserted in inresing order, you will hve good understnding of the wy tht 2-3 trees re uilt. ell tht in BT, the inresing-order sequene for 10 keys results in worst-se tree where serh might involve exmining ll the keys. In the 2-3 trees, ll keys n e found in every se y exmining t most three nodes. T DING DITION I UFFIINT TO define symol-tle implementtion with 2-3 trees s the underlying dt struture. nlyzing 2-3 trees is different from nlyzing BTs euse our primry interest is in worst-se performne, s opposed to verge-se performne (where we nlyze expeted performne under n ssumption tht key vlues ome from some rndom soure). In symol-tle implementtions, we normlly hve no ontrol over the order in whih lients insert keys into the tle nd worst-se nlysis is one wy to provide performne gurntees. roperty F. erh nd insert opertions in 2-3 trees re gurnteed to omplete in logrithmi time. roof. The height of N-node 2-3 tree is log 3 N = (lg N)/(lg 3) (if the tree is ll 3-nodes) nd lg N (if the tree is ll 2-nodes) (see I 4.3.). The mount of time required t eh node y eh of the opertions is ounded y onstnt, nd oth opertions exmine nodes on just one pth. Blned Trees

7 434 T FOU insert insert stndrd indexing lient sme keys in inresing order 2-3 tree onstrution tres etion etion 4.3

8 YBO TB 435 Thus, we n gurntee good worst-se performne with 2-3 trees. s you n see from exmining the tree depited t the ottom of this pge, perfetly lned tree strikes remrkly flt posture. For exmple, the height of 2-3 tree tht ontins 1 illion keys is nineteen nd thirty. It is quite remrkle tht we n gurntee to perform ritrry serh nd insertion opertions mong 1 illion keys y exmining thn thirty nodes. owever, we re only prt of the wy to n implementtion. lthough it would e possile to write ode tht performs trnsformtions on distint dt types representing 2- nd 3-nodes, most of the tsks tht we hve desried re inonvenient to implement in this diret representtion euse there re numerous different ses to e hndled. We would need to mintin two different types of nodes, ompre serh keys ginst eh of the keys in the nodes, opy links nd other informtion from one type of node to nother, onvert nodes from one type to nother, nd so forth. Not only is there sustntil mount of ode involved, ut the overhed inurred ould mke the lgorithms slower thn stndrd BT serh. The primry purpose of lning is to provide insurne ginst d worst se, ut we would prefer the overhed ost for tht insurne to e low. Fortuntely, s you will see, we n do the trnsformtions in uniform wy using little overhed eyond the osts inurred y stndrd BT serh. Typil 2-3 tree uilt from rndom keys Blned Trees

9 436 T FOU red lk tree ed Blk Trees The insertion lgorithm for 2-3 trees just desried is not diffiult to understnd; now, we will see tht it is lso not diffiult to implement. We will onsider simple representtion known s red-lk trees tht leds to nturl implementtion. In the end, not muh ode is required, ut understnding how nd why the ode gets the jo done requires reful look. noding 3-nodes The si ide ehind redlk trees is to enode 2-3 trees y strting with stndrd BTs, whih re mde up of 2-nodes, nd dding extr informtion to enode 3-nodes. We think of the links s eing of two different types: red links, whih ind together smll inry trees tht represent 3-nodes, nd lk links, whih ind together the 2-3 tree. peifilly, we represent 3-nodes s two 2-nodes onneted y single red link. To define 1-1 orrespondene, we require tht red links re lwys left links. One dvntge of using suh representtion is tht it llows us to horizontl red links 2-3 tree J J J 1 1 orrespondene red-lk nd 2-3 trees 3-node thn thn nd greter thn noding 3-node with two 2-nodes onneted y left-lening red link use our get() ode for stndrd BT serh without modifition., while we never fully speified the serh proess within 3-nodes for 2-3 trees. Given ny 2-3 tree, we n immeditely derive orresponding BT, just y onverting eh node s speified. We refer to BTs tht represent 2-3 trees in this wy s (lned) red lk BTs. n equivlent definition nother wy to proeed is to define red lk BTs s BTs hving red nd lk links nd stisfying the following three restritions: ed links len left. No node hs two red links onneted to it. The tree hs perfet lk lne : every pth from the root to null link hs the sme numer of lk links. nd greter thn etion etion 4.3

10 YBO TB 437 red-lk tree with horizontl red links is 2-3 tree There is 1-1 orrespondene red-lk BTs defined in this wy nd 2-3 trees: if we drw the red links horizontlly in red lk BT, ll of the null links re the sme distne from the root, nd if we then ollpse together the nodes onneted y red links, the result is 2-3 tree. For onveniene, we define the lk height of red lk BT s the numer of lk links on the pth from the root to every null link (the height of the orresponding 2-3 tree). Whihever wy we hoose to define them, red lk BTs re oth BTs nd 2-3 trees. Thus, if we n implement the lned 2-3 tree insertion lgorithm y mintining the 1-1 orrespondene, then we get the est of oth worlds: the simple nd effiient serh method from stndrd BTs nd the effiient insertion lning method from 2-3 trees. epresenttion For onveniene, sine eh node is pointed to y preisely one link (from its prent), we enode the olor of links in nodes (not links), y dding oolen instne vrile olor to our Node dt type, whih is true if the (left) link from the prent is red nd flse if the link from the prent to the node is lk (not red). For lrity in our ode, we define onstnts D nd BK for use in setting nd testing this vrile. For resons tht will lter eome more ler, new nodes re lwys D. We use privte method ised() to test node olor (insted of hving n instne method in Node) to void hving to test for null in lient ode. ottions When you sw the definition of red lk BTs, you my hve sked yourself why the red links should ll len to the left. Why not llow some privte stti finl oolen D = true; privte stti finl oolen BK = flse; privte lss Node { Key key; // key Vlue vl; // ssoited dt Node left, right; // sutrees } h.left.olor is D int N; oolen olor; // # nodes in this sutree // olor of link from // prent to this node Node(Key key, Vlue vl, int N, oolen olor) { this.key = key; this.vl = vl; this.n = 1; this.olor = D; } privte oolen ised(node x) { if (x == null) return flse; return x.olor == D; } D h Node representtion for red lk trees G J h.right.olor is BK Blned Trees

11 438 T FOU h thn of them to len to the right? This is resonle question tht is ddressed in the Q& t the end of this setion. Indeed, the stndrd implementtion of red lk BTs tht hs een in use for dedes llows for right-lening red links (see xerise 4.3.TODO). Node rotteeft(node h) { x = h.right; h.right = x.left; x.left = h; x.olor = h.olor; h.olor = D; x.n = h.n; h.n = 1 + size(h.left) + size(h.right); return x; } x h thn ould e right or left, red or lk nd nd eft rotte (right link of h) x greter thn greter thn In the implementtion tht we will onsider, we lso llow temporry right-lening red links during n opertion, ut lwys mke them len to the left efore the opertion ompletes. Next, we onsider the ode tht we need to swith orienttion of red links. This ode is ruil: y hnging links in the trees, it rings them into etter lne. First, suppose tht we hve right-lening red link tht needs to e rotted to len to the left (see the digrm t left). This opertion is lled left rottion. We orgnize the omputtion s method tht tkes link to red-lk BT s rgument, nd ssuming tht link to e to Node h whose right link is red, mkes the neessry djustments nd returns link to node tht is the root of red lk BT for the sme set of keys whose left link is red. If you think of the orresponding 3-node s you hek eh of the lines of ode ginst the efore/fter drwings in the digrm, you will find this opertion is esy to understnd: we re swithing from hving the smller of the two keys t the root to hving the lrger of the two keys t the root. Implementing right rottion tht onverts left-lening red link to rightlening one mounts to the sme ode, with left nd right interhnged. Whether left or right, every rottion leves us with link. Note tht this link my e red or lk oth rotteeft() nd rotteight() tke re to preserve its olor y setting x.olor to h.olor. One implition of this deision is tht our lgorithms might temporrily llow two red links in row to our within the tree. Indeed, we use rottions preisely to orret this ondition when it rises. In our lgorithms, we lwys use the link returned y rotteight() or rotteeft() to reset the pproprite link in the prent (or the root of the tree). Tht my x thn Node rotteight(node h) { x = h.left; h.left = x.right; x.right = h; x.olor = h.olor; h.olor = D; x.n = h.n; h.n = 1 + size(h.left) + size(h.right); return x; } x thn nd nd ight rotte (left link of h) h greter thn h greter thn etion etion 4.3

12 YBO TB 439 e right or left link, ut we n lwys use the returned link to reset the rgument link. For exmple, the ode h = rotteeft(h); rottes left right-lening red link tht is to the left of node h, setting h to point to the root of the resulting sutree (whih ontins ll the sme nodes s the sutree pointed to y h efore the rottion, ut different root). The ese of writing this type of ode is the primry reson we use reursive implementtions of BT methods, s it mkes doing rottions n esy ddition to norml serh, s you will see. The reson tht we n use rottions to help mintin the 1-1 orrespondene 2-3 trees nd red lk BTs s new keys re inserted is tht they preserve very importnt property: they preserve order nd perfet lk lne. Tht is, we n use rottions on red lk BT without hve to worry out losing its order nd its perfet lk lne. s just mentioned, our pproh is to use rottion to eliminte onneted red links. s efore, we wrm up with some esy ses. insert dd new node here right link red so rotte left Insert into 2-node t the ottom Insert into single 2-node red-lk tree with 1 key is just single 2-node. Inserting the seond key immeditely shows the need for hving rottion opertion. If the new key is smller thn the key in the tree, we just mke new (red) node with the new key nd we re done: we hve redlk tree tht is equivlent to single 3-node. But if the new key is lrger thn the key in the tree, then tthing new (red) node gives right-lening red link, nd the ode root = rotteeft(root); ompletes the insertion y rotting the red link to the left nd updting the tree root link. The result in oth ses is the red-lk representtion of single 3-node, with two keys, one left-lening red link nd lk height 1. right Insert into 2-node t the ottom We insert keys into red-lk tree s usul into BT, dding new node t the ottom (respeting the order), ut lwys onneted to its prent with red link. If the prent is 2-node, then the sme two ses just disussed re effetive. If the new node is tthed to the left link, the prent simply eomes 3-node; if it is tthed to right link, we hve 3-node lening the wrong wy, ut left rottion finishes the jo. left serh ends t this null link red link to new node ontining onverts 2-node to 3-node root serh ends t this null link tthed new node with red link root root root rotted left to mke legl 3-node Insert into single 2-node (two ses) Blned Trees

13 440 T FOU smller serh ends t this null link Insert into tree with 2 keys (in 3-node) This se redues to three suses, depending on whether the new key is thn oth keys in the tree, them, or greter thn oth of them. h of the ses introdues node with two red links onneted to it: our gol is to orret this ondition. The simplest of the three ses is when the new key is lrger thn the two in the tree nd is therefore tthed on the rightmost link of the 3-node, mking tthed new node with red link rotted right olors flipped to lk serh ends t this null link tthed new node with red link rotted left rotted right olors flipped to lk lrger Insert into single 3-node (three ses) serh ends t this null link tthed new node with red link olors flipped to lk lned tree with the middle key t the root, onneted with red links to nodes ontining smller nd lrger key. If we flip the olors of those two links from red to lk, then we hve three-node lned tree, of height 2, extly wht we need to mintin our 1-1 orrespondene to 2-3 trees. The other two ses eventully redue to this se. If the new key is smller thn the keys in the tree nd goes on the left link, then we hve two red links in row, oth lening to the left, whih we n redue to the previous se y rotting the top link to the right. If the new key goes in the middle, we gin hve two red links in row, right-lening one elow left lening one,whih we n redue to the previous se y rotting left the ottom link. In summry, we hieve the desired result y doing zero, one, or two rottions followed y flipping the olors of the two hildren of the root. s with 2-3 trees, e ertin tht you understnd these trnsformtions, s they re the key to redlk tree dynmis. Flipping olors To flip the olors of the hildren of node, we use method flip- olors(), shown t right. In ddition to flipping the olors of the hildren from red to lk, we lso flip the olor of the prent from lk to red. (In the se just onsidered, this will olor the root red y onvention, we olor the root lk fter eh insertion, whih inreses the lk height of the tree y 1 if it ws red.) ritilly importnt etion etion 4.3

14 YBO TB 441 hrteristi of this opertion is tht, like rottions, it is lol trnsformtion tht preserves perfet lk lne in the tree. oreover, this onvention immeditely leds us to full implementtion, s we desrie next. h ould e left or right link Insert into 3-node t the ottom Now suppose tht we dd new node t the ottom tht is onneted to 3-node. The sme three ses just disussed rise. ither the new link insert right link red so rotte left dd new node here two lefts in row so rotte right oth hildren red so flip olors Insert into 3-node t the ottom is onneted to the left link of the 3-node (in whih se we need to rotte the top link right nd flip olors) or to the right link of the 3-node (in whih se we just flip olors) or to the middle link of the 3-node (in whih se we rotte left the ottom link, then rotte right the top link, then flip olors). Flipping the olors mkes the link to the middle node red, whih mounts thn thn nd nd void flipolors(node h) { h.olor = D; h.left.olor = BK; h.right.olor = BK; } red link tthes middle node to prent lk links split to 2-nodes Flipping olors to split 4-node to pssing it up to its prent, putting us k in the sme sitution with respet to the prent, whih we n fix y moving up the tree. ssing red link up the tree The 2-3 insertion lgorithm lls for us to split the 3-node, pssing the middle key up to e inserted into its prent, ontinuing until enountering 2-node or the root. In every se we hve onsidered, we preisely omplish this ojetive: fter doing ny neessry rottions, we flip olors, whih turns the middle node to red. From the point of view of the prent of tht node, tht link eoming red n e hndled in preisely the sme mnner s if the red link me from tthing new node: we pss up red link to the middle node. The three ses summrized in the digrm on the next pge preisely pture the op- nd nd greter thn greter thn Blned Trees

15 442 T FOU ertions neessry in red-lk tree to implement the key opertion in 2-3 tree insertion: to insert into 3-node, rete temporry 4-node, split it, nd pss red link to the middle key up to its prent. ontinuing the sme proess, we pss red link up the tree until rehing 2-node or the root. right rotte left rotte flip olors IN UY, W N INTIN OU 1-1 orrespondene 2-3 trees nd red lk trees during insertion y judiious use of three simple opertions: left rotte, ssing red link up red-lk tree right rotte, nd olor flip. we n omplish the insertion y performing the following opertions, one fter the other, on eh node s we pss up the tree from the point of insertion: If the right hild is red nd the left hild is not red, rotte left. If oth the left hild nd its left hild re red, rotte right. If oth hildren re red, flip olors. It ertinly is worth your while to hek tht this sequene hndles eh of the ses just desried. Note tht the first opertion hndles oth the rottion neessry to len the 3-node to the left when the prent is 2-node nd the rottion neessry to len the ottom link to the left when the new red link is the middle link in 3-node. Implementtion ine the lning opertions re to e performed on the wy up the tree from the point of insertion, implementing them is esy in our stndrd reursive implementtion: we just do them fter the reursive lls, s shown in GO- IT 4.4. The three opertions listed in the previous prgrph re enpsulted in method fixup(). ven though it involves smll mount of ode, this implementtion would e quite diffiult to understnd without the two lyers of strtion tht we hve developed (2-3 trees nd red-lk trees) to implement it. t ost of testing three to five link olors (nd perhps doing rottion or two or flipping olors when test sueeds), we get trees tht hve nerly perfet lne. The tres for our stndrd indexing lient nd for the sme keys inserted in inresing order is given on the fing pge. onsidering these exmples simply in etion etion 4.3

16 YBO TB 443 lgorithm 4.4 Insert for red lk BTs puli lss edblkbt<key extends omprle<key>, Vlue> { privte lss Node // tndrd BT Node with olor it dded -- see text. privte oolen ised(node h) privte Node rotteeft(node h) privte Node rotteight(node h) privte void flipolors(node h) // ee text for implementtions of these methods. privte Node fixup(node h) { if (ised(h.right) &&!ised(h.left)) h = rotteeft(h); if (ised(h.left) && ised(h.left.left)) h = rotteight(h); if (ised(h.left) && ised(h.right)) flipolors(h); } } h.n = size(h.left) + size(h.right) + 1; return h; puli void put(key key, Vlue vl) { root = put(root, key, vl); } privte Node put(node h, Key key, Vlue vl) { if (h == null) return new Node(key, vl, 1, D); } int mp = key.ompreto(h.key); if (mp < 0) h.left = insert(h.left, key, vl); else if (mp > 0) h.right = insert(h.right, key, vl); else h.vl = vl; return fixup(h); The ode for the reursive put() for red-lk BTs is identil to put() in elementry BTs exept for the fixup() method, whih uses olor it in Node to provide ner-perfet lne in the tree y mintining 1-1 orrespondene with 2-3 trees. Blned Trees

17 444 T FOU etion etion 4.3 red-lk tree onstrution tres stndrd indexing lient sme keys in inresing order insert insert

18 YBO TB 445 terms of our three opertions on red lk trees, s we hve een doing, is n instrutive exerise. nother instrutive exerise is to hek the orrespondene with 2-3 trees tht the lgorithm mintins (using the figure for the sme keys given erlier in this setion). In oth ses, you n test your understnding of the lgorithm y onsidering the trnsformtions (two olor flips nd two rottions) tht re needed when is inserted into the tree. Blned Trees

Balanced Trees. 2-3 trees red-black trees B-trees. 2-3 trees red-black trees B-trees smaller than. 2-node. 3-node E J S X A C.

Balanced Trees. 2-3 trees red-black trees B-trees. 2-3 trees red-black trees B-trees smaller than. 2-node. 3-node E J S X A C. ymol tle review Blned Trees implementtion gurntee verge se serh insert delete serh hit insert delete ordered itertion? opertions on keys sequentil serh (linked list) N N N N/2 N N/2 no equls() 2-3 trees

More information

implementation sequential search (unordered list) binary search (ordered array) BST N N N log N log N N compareto()

implementation sequential search (unordered list) binary search (ordered array) BST N N N log N log N N compareto() OBT DGWIK KVIN WYN lgorithms OBT DGWIK KVIN WYN ymol tle review lgorithms F O U T D I T I O N http://lgs4.s.prineton.edu 3.3 BND T 2 3 serh trees red lk BTs B-trees implementtion sequentil serh (unordered

More information

2-3 search trees red-black BSTs B-trees

2-3 search trees red-black BSTs B-trees 2-3 serch trees red-lck BTs B-trees 3 2-3 tree llow 1 or 2 keys per node. 2-node: one key, two children. 3-node: two keys, three children. ymmetric order. Inorder trversl yields keys in scending order.

More information

CS 241 Week 4 Tutorial Solutions

CS 241 Week 4 Tutorial Solutions CS 4 Week 4 Tutoril Solutions Writing n Assemler, Prt & Regulr Lnguges Prt Winter 8 Assemling instrutions utomtilly. slt $d, $s, $t. Solution: $d, $s, nd $t ll fit in -it signed integers sine they re 5-it

More information

Duality in linear interval equations

Duality in linear interval equations Aville online t http://ijim.sriu..ir Int. J. Industril Mthemtis Vol. 1, No. 1 (2009) 41-45 Dulity in liner intervl equtions M. Movhedin, S. Slhshour, S. Hji Ghsemi, S. Khezerloo, M. Khezerloo, S. M. Khorsny

More information

2 Computing all Intersections of a Set of Segments Line Segment Intersection

2 Computing all Intersections of a Set of Segments Line Segment Intersection 15-451/651: Design & Anlysis of Algorithms Novemer 14, 2016 Lecture #21 Sweep-Line nd Segment Intersection lst chnged: Novemer 8, 2017 1 Preliminries The sweep-line prdigm is very powerful lgorithmic design

More information

Midterm Exam CSC October 2001

Midterm Exam CSC October 2001 Midterm Exm CSC 173 23 Otoer 2001 Diretions This exm hs 8 questions, severl of whih hve suprts. Eh question indites its point vlue. The totl is 100 points. Questions 5() nd 6() re optionl; they re not

More information

COMP 423 lecture 11 Jan. 28, 2008

COMP 423 lecture 11 Jan. 28, 2008 COMP 423 lecture 11 Jn. 28, 2008 Up to now, we hve looked t how some symols in n lphet occur more frequently thn others nd how we cn sve its y using code such tht the codewords for more frequently occuring

More information

Lesson 4.4. Euler Circuits and Paths. Explore This

Lesson 4.4. Euler Circuits and Paths. Explore This Lesson 4.4 Euler Ciruits nd Pths Now tht you re fmilir with some of the onepts of grphs nd the wy grphs onvey onnetions nd reltionships, it s time to egin exploring how they n e used to model mny different

More information

Greedy Algorithm. Algorithm Fall Semester

Greedy Algorithm. Algorithm Fall Semester Greey Algorithm Algorithm 0 Fll Semester Optimiztion prolems An optimiztion prolem is one in whih you wnt to fin, not just solution, ut the est solution A greey lgorithm sometimes works well for optimiztion

More information

Paradigm 5. Data Structure. Suffix trees. What is a suffix tree? Suffix tree. Simple applications. Simple applications. Algorithms

Paradigm 5. Data Structure. Suffix trees. What is a suffix tree? Suffix tree. Simple applications. Simple applications. Algorithms Prdigm. Dt Struture Known exmples: link tble, hep, Our leture: suffix tree Will involve mortize method tht will be stressed shortly in this ourse Suffix trees Wht is suffix tree? Simple pplitions History

More information

COMP108 Algorithmic Foundations

COMP108 Algorithmic Foundations Grph Theory Prudene Wong http://www.s.liv..uk/~pwong/tehing/omp108/201617 How to Mesure 4L? 3L 5L 3L ontiner & 5L ontiner (without mrk) infinite supply of wter You n pour wter from one ontiner to nother

More information

Distance vector protocol

Distance vector protocol istne vetor protool Irene Finohi finohi@i.unirom.it Routing Routing protool Gol: etermine goo pth (sequene of routers) thru network from soure to Grph strtion for routing lgorithms: grph noes re routers

More information

CS 551 Computer Graphics. Hidden Surface Elimination. Z-Buffering. Basic idea: Hidden Surface Removal

CS 551 Computer Graphics. Hidden Surface Elimination. Z-Buffering. Basic idea: Hidden Surface Removal CS 55 Computer Grphis Hidden Surfe Removl Hidden Surfe Elimintion Ojet preision lgorithms: determine whih ojets re in front of others Uses the Pinter s lgorithm drw visile surfes from k (frthest) to front

More information

Computational geometry

Computational geometry Leture 23 Computtionl geometry Supplementl reding in CLRS: Chpter 33 exept 33.3 There re mny importnt prolems in whih the reltionships we wish to nlyze hve geometri struture. For exmple, omputtionl geometry

More information

Problem Final Exam Set 2 Solutions

Problem Final Exam Set 2 Solutions CSE 5 5 Algoritms nd nd Progrms Prolem Finl Exm Set Solutions Jontn Turner Exm - //05 0/8/0. (5 points) Suppose you re implementing grp lgoritm tt uses ep s one of its primry dt strutures. Te lgoritm does

More information

Lecture 12 : Topological Spaces

Lecture 12 : Topological Spaces Leture 12 : Topologil Spes 1 Topologil Spes Topology generlizes notion of distne nd loseness et. Definition 1.1. A topology on set X is olletion T of susets of X hving the following properties. 1. nd X

More information

CMPUT101 Introduction to Computing - Summer 2002

CMPUT101 Introduction to Computing - Summer 2002 CMPUT Introdution to Computing - Summer 22 %XLOGLQJ&RPSXWHU&LUFXLWV Chpter 4.4 3XUSRVH We hve looked t so fr how to uild logi gtes from trnsistors. Next we will look t how to uild iruits from logi gtes,

More information

Parallelization Optimization of System-Level Specification

Parallelization Optimization of System-Level Specification Prlleliztion Optimiztion of System-Level Speifition Luki i niel. Gjski enter for Emedded omputer Systems University of liforni Irvine, 92697, US {li, gjski} @es.ui.edu strt This pper introdues the prlleliztion

More information

Advanced Programming Handout 5. Enter Okasaki. Persistent vs. Ephemeral. Functional Queues. Simple Example. Persistent vs.

Advanced Programming Handout 5. Enter Okasaki. Persistent vs. Ephemeral. Functional Queues. Simple Example. Persistent vs. Avne Progrmming Hnout 5 Purel Funtionl Dt Strutures: A Cse Stu in Funtionl Progrmming Persistent vs. Ephemerl An ephemerl t struture is one for whih onl one version is ville t time: fter n upte opertion,

More information

Introduction to Algebra

Introduction to Algebra INTRODUCTORY ALGEBRA Mini-Leture 1.1 Introdution to Alger Evlute lgeri expressions y sustitution. Trnslte phrses to lgeri expressions. 1. Evlute the expressions when =, =, nd = 6. ) d) 5 10. Trnslte eh

More information

Internet Routing. IP Packet Format. IP Fragmentation & Reassembly. Principles of Internet Routing. Computer Networks 9/29/2014.

Internet Routing. IP Packet Format. IP Fragmentation & Reassembly. Principles of Internet Routing. Computer Networks 9/29/2014. omputer Networks 9/29/2014 IP Pket Formt Internet Routing Ki Shen IP protool version numer heder length (words) for qulity of servie mx numer remining hops (deremented t eh router) upper lyer protool to

More information

Width and Bounding Box of Imprecise Points

Width and Bounding Box of Imprecise Points Width nd Bounding Box of Impreise Points Vhideh Keikh Mrten Löffler Ali Mohdes Zhed Rhmti Astrt In this pper we study the following prolem: we re given set L = {l 1,..., l n } of prllel line segments,

More information

Distributed Systems Principles and Paradigms. Chapter 11: Distributed File Systems

Distributed Systems Principles and Paradigms. Chapter 11: Distributed File Systems Distriuted Systems Priniples nd Prdigms Mrten vn Steen VU Amsterdm, Dept. Computer Siene steen@s.vu.nl Chpter 11: Distriuted File Systems Version: Deemer 10, 2012 2 / 14 Distriuted File Systems Distriuted

More information

CS553 Lecture Introduction to Data-flow Analysis 1

CS553 Lecture Introduction to Data-flow Analysis 1 ! Ide Introdution to Dt-flow nlysis!lst Time! Implementing Mrk nd Sweep GC!Tody! Control flow grphs! Liveness nlysis! Register llotion CS553 Leture Introdution to Dt-flow Anlysis 1 Dt-flow Anlysis! Dt-flow

More information

In the last lecture, we discussed how valid tokens may be specified by regular expressions.

In the last lecture, we discussed how valid tokens may be specified by regular expressions. LECTURE 5 Scnning SYNTAX ANALYSIS We know from our previous lectures tht the process of verifying the syntx of the progrm is performed in two stges: Scnning: Identifying nd verifying tokens in progrm.

More information

CS453 INTRODUCTION TO DATAFLOW ANALYSIS

CS453 INTRODUCTION TO DATAFLOW ANALYSIS CS453 INTRODUCTION TO DATAFLOW ANALYSIS CS453 Leture Register llotion using liveness nlysis 1 Introdution to Dt-flow nlysis Lst Time Register llotion for expression trees nd lol nd prm vrs Tody Register

More information

CS 340, Fall 2016 Sep 29th Exam 1 Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string.

CS 340, Fall 2016 Sep 29th Exam 1 Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string. CS 340, Fll 2016 Sep 29th Exm 1 Nme: Note: in ll questions, the speil symol ɛ (epsilon) is used to indite the empty string. Question 1. [10 points] Speify regulr expression tht genertes the lnguge over

More information

10.2 Graph Terminology and Special Types of Graphs

10.2 Graph Terminology and Special Types of Graphs 10.2 Grph Terminology n Speil Types of Grphs Definition 1. Two verties u n v in n unirete grph G re lle jent (or neighors) in G iff u n v re enpoints of n ege e of G. Suh n ege e is lle inient with the

More information

McAfee Web Gateway

McAfee Web Gateway Relese Notes Revision C MAfee We Gtewy 7.6.2.11 Contents Aout this relese Enhnement Resolved issues Instlltion instrutions Known issues Additionl informtion Find produt doumenttion Aout this relese This

More information

Lecture 8: Graph-theoretic problems (again)

Lecture 8: Graph-theoretic problems (again) COMP36111: Advned Algorithms I Leture 8: Grph-theoreti prolems (gin) In Prtt-Hrtmnn Room KB2.38: emil: iprtt@s.mn..uk 2017 18 Reding for this leture: Sipser: Chpter 7. A grph is pir G = (V, E), where V

More information

6.045J/18.400J: Automata, Computability and Complexity. Quiz 2: Solutions. Please write your name in the upper corner of each page.

6.045J/18.400J: Automata, Computability and Complexity. Quiz 2: Solutions. Please write your name in the upper corner of each page. 6045J/18400J: Automt, Computbility nd Complexity Mrh 30, 2005 Quiz 2: Solutions Prof Nny Lynh Vinod Vikuntnthn Plese write your nme in the upper orner of eh pge Problem Sore 1 2 3 4 5 6 Totl Q2-1 Problem

More information

Distributed Systems Principles and Paradigms

Distributed Systems Principles and Paradigms Distriuted Systems Priniples nd Prdigms Christoph Dorn Distriuted Systems Group, Vienn University of Tehnology.dorn@infosys.tuwien..t http://www.infosys.tuwien..t/stff/dorn Slides dpted from Mrten vn Steen,

More information

CS201 Discussion 10 DRAWTREE + TRIES

CS201 Discussion 10 DRAWTREE + TRIES CS201 Discussion 10 DRAWTREE + TRIES DrwTree First instinct: recursion As very generic structure, we could tckle this problem s follows: drw(): Find the root drw(root) drw(root): Write the line for the

More information

The Network Layer: Routing in the Internet. The Network Layer: Routing & Addressing Outline

The Network Layer: Routing in the Internet. The Network Layer: Routing & Addressing Outline CPSC 852 Internetworking The Network Lyer: Routing in the Internet Mihele Weigle Deprtment of Computer Siene Clemson University mweigle@s.lemson.edu http://www.s.lemson.edu/~mweigle/ourses/ps852 1 The

More information

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved.

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved. Chpter 9 Greey Tehnique Copyright 2007 Person Aison-Wesley. All rights reserve. Greey Tehnique Construts solution to n optimiztion prolem piee y piee through sequene of hoies tht re: fesile lolly optiml

More information

FEEDBACK: The standard error of a regression is not an unbiased estimator for the standard deviation of the error in a multiple regression model.

FEEDBACK: The standard error of a regression is not an unbiased estimator for the standard deviation of the error in a multiple regression model. Introutory Eonometris: A Moern Approh 6th Eition Woolrige Test Bnk Solutions Complete ownlo: https://testbnkre.om/ownlo/introutory-eonometris-moern-pproh-6th-eition-jeffreym-woolrige-test-bnk/ Solutions

More information

Lecture 13: Graphs I: Breadth First Search

Lecture 13: Graphs I: Breadth First Search Leture 13 Grphs I: BFS 6.006 Fll 2011 Leture 13: Grphs I: Bredth First Serh Leture Overview Applitions of Grph Serh Grph Representtions Bredth-First Serh Rell: Grph G = (V, E) V = set of verties (ritrry

More information

To access your mailbox from inside your organization. For assistance, call:

To access your mailbox from inside your organization. For assistance, call: 2001 Ative Voie, In. All rights reserved. First edition 2001. Proteted y one or more of the following United Sttes ptents:,070,2;,3,90;,88,0;,33,102;,8,0;,81,0;,2,7;,1,0;,90,88;,01,11. Additionl U.S. nd

More information

What are suffix trees?

What are suffix trees? Suffix Trees 1 Wht re suffix trees? Allow lgorithm designers to store very lrge mount of informtion out strings while still keeping within liner spce Allow users to serch for new strings in the originl

More information

COMMON FRACTIONS. or a / b = a b. , a is called the numerator, and b is called the denominator.

COMMON FRACTIONS. or a / b = a b. , a is called the numerator, and b is called the denominator. COMMON FRACTIONS BASIC DEFINITIONS * A frtion is n inite ivision. or / * In the frtion is lle the numertor n is lle the enomintor. * The whole is seprte into "" equl prts n we re onsiering "" of those

More information

Pattern Matching. Pattern Matching. Pattern Matching. Review of Regular Expressions

Pattern Matching. Pattern Matching. Pattern Matching. Review of Regular Expressions Pttern Mthing Pttern Mthing Some of these leture slides hve een dpted from: lgorithms in C, Roert Sedgewik. Gol. Generlize string serhing to inompletely speified ptterns. pplitions. Test if string or its

More information

Outline. Motivation Background ARCH. Experiment Additional usages for Input-Depth. Regular Expression Matching DPI over Compressed HTTP

Outline. Motivation Background ARCH. Experiment Additional usages for Input-Depth. Regular Expression Matching DPI over Compressed HTTP ARCH This work ws supported y: The Europen Reserh Counil, The Isreli Centers of Reserh Exellene, The Neptune Consortium, nd Ntionl Siene Foundtion wrd CNS-119748 Outline Motivtion Bkground Regulr Expression

More information

The Greedy Method. The Greedy Method

The Greedy Method. The Greedy Method Lists nd Itertors /8/26 Presenttion for use with the textook, Algorithm Design nd Applictions, y M. T. Goodrich nd R. Tmssi, Wiley, 25 The Greedy Method The Greedy Method The greedy method is generl lgorithm

More information

10.5 Graphing Quadratic Functions

10.5 Graphing Quadratic Functions 0.5 Grphing Qudrtic Functions Now tht we cn solve qudrtic equtions, we wnt to lern how to grph the function ssocited with the qudrtic eqution. We cll this the qudrtic function. Grphs of Qudrtic Functions

More information

and vertically shrinked by

and vertically shrinked by 1. A first exmple 1.1. From infinite trnsltion surfe mp to end-periodi mp. We begin with n infinite hlf-trnsltion surfe M 0 desribed s in Figure 1 nd n ffine mp f 0 defined s follows: the surfe is horizontlly

More information

COSC 6374 Parallel Computation. Non-blocking Collective Operations. Edgar Gabriel Fall Overview

COSC 6374 Parallel Computation. Non-blocking Collective Operations. Edgar Gabriel Fall Overview COSC 6374 Prllel Computtion Non-loking Colletive Opertions Edgr Griel Fll 2014 Overview Impt of olletive ommunition opertions Impt of ommunition osts on Speedup Crtesin stenil ommunition All-to-ll ommunition

More information

Final Exam Review F 06 M 236 Be sure to look over all of your tests, as well as over the activities you did in the activity book

Final Exam Review F 06 M 236 Be sure to look over all of your tests, as well as over the activities you did in the activity book inl xm Review 06 M 236 e sure to loo over ll of your tests, s well s over the tivities you did in the tivity oo 1 1. ind the mesures of the numered ngles nd justify your wor. Line j is prllel to line.

More information

CSCI 104. Rafael Ferreira da Silva. Slides adapted from: Mark Redekopp and David Kempe

CSCI 104. Rafael Ferreira da Silva. Slides adapted from: Mark Redekopp and David Kempe CSCI 0 fel Ferreir d Silv rfsilv@isi.edu Slides dpted from: Mrk edekopp nd Dvid Kempe LOG STUCTUED MEGE TEES Series Summtion eview Let n = + + + + k $ = #%& #. Wht is n? n = k+ - Wht is log () + log ()

More information

Error Numbers of the Standard Function Block

Error Numbers of the Standard Function Block A.2.2 Numers of the Stndrd Funtion Blok evlution The result of the logi opertion RLO is set if n error ours while the stndrd funtion lok is eing proessed. This llows you to rnh to your own error evlution

More information

Enterprise Digital Signage Create a New Sign

Enterprise Digital Signage Create a New Sign Enterprise Digitl Signge Crete New Sign Intended Audiene: Content dministrtors of Enterprise Digitl Signge inluding stff with remote ess to sign.pitt.edu nd the Content Mnger softwre pplition for their

More information

P(r)dr = probability of generating a random number in the interval dr near r. For this probability idea to make sense we must have

P(r)dr = probability of generating a random number in the interval dr near r. For this probability idea to make sense we must have Rndom Numers nd Monte Crlo Methods Rndom Numer Methods The integrtion methods discussed so fr ll re sed upon mking polynomil pproximtions to the integrnd. Another clss of numericl methods relies upon using

More information

COSC 6374 Parallel Computation. Dense Matrix Operations

COSC 6374 Parallel Computation. Dense Matrix Operations COSC 6374 Prllel Computtion Dense Mtrix Opertions Edgr Griel Fll Edgr Griel Prllel Computtion Edgr Griel erminology Dense Mtrix: ll elements of the mtrix ontin relevnt vlues ypilly stored s 2-D rry, (e.g.

More information

Distance Computation between Non-convex Polyhedra at Short Range Based on Discrete Voronoi Regions

Distance Computation between Non-convex Polyhedra at Short Range Based on Discrete Voronoi Regions Distne Computtion etween Non-onvex Polyhedr t Short Rnge Bsed on Disrete Voronoi Regions Ktsuki Kwhi nd Hiroms Suzuki Deprtment of Preision Mhinery Engineering, The University of Tokyo 7-3-1 Hongo, Bunkyo-ku,

More information

Section 3.1: Sequences and Series

Section 3.1: Sequences and Series Section.: Sequences d Series Sequences Let s strt out with the definition of sequence: sequence: ordered list of numbers, often with definite pttern Recll tht in set, order doesn t mtter so this is one

More information

COSC 6374 Parallel Computation. Communication Performance Modeling (II) Edgar Gabriel Fall Overview. Impact of communication costs on Speedup

COSC 6374 Parallel Computation. Communication Performance Modeling (II) Edgar Gabriel Fall Overview. Impact of communication costs on Speedup COSC 6374 Prllel Computtion Communition Performne Modeling (II) Edgr Griel Fll 2015 Overview Impt of ommunition osts on Speedup Crtesin stenil ommunition All-to-ll ommunition Impt of olletive ommunition

More information

LINX MATRIX SWITCHERS FIRMWARE UPDATE INSTRUCTIONS FIRMWARE VERSION

LINX MATRIX SWITCHERS FIRMWARE UPDATE INSTRUCTIONS FIRMWARE VERSION Overview LINX MATRIX SWITCHERS FIRMWARE UPDATE INSTRUCTIONS FIRMWARE VERSION 4.4.1.0 Due to the omplex nture of this updte, plese fmilirize yourself with these instrutions nd then ontt RGB Spetrum Tehnil

More information

Can Pythagoras Swim?

Can Pythagoras Swim? Overview Ativity ID: 8939 Mth Conepts Mterils Students will investigte reltionships etween sides of right tringles to understnd the Pythgoren theorem nd then use it to solve prolems. Students will simplify

More information

EXPONENTIAL & POWER GRAPHS

EXPONENTIAL & POWER GRAPHS Eponentil & Power Grphs EXPONENTIAL & POWER GRAPHS www.mthletics.com.u Eponentil EXPONENTIAL & Power & Grphs POWER GRAPHS These re grphs which result from equtions tht re not liner or qudrtic. The eponentil

More information

Type Checking. Roadmap (Where are we?) Last lecture Context-sensitive analysis. This lecture Type checking. Symbol tables

Type Checking. Roadmap (Where are we?) Last lecture Context-sensitive analysis. This lecture Type checking. Symbol tables Type Cheking Rodmp (Where re we?) Lst leture Contet-sensitie nlysis Motition Attriute grmmrs Ad ho Synt-direted trnsltion This leture Type heking Type systems Using synt direted trnsltion Symol tles Leil

More information

A Tautology Checker loosely related to Stålmarck s Algorithm by Martin Richards

A Tautology Checker loosely related to Stålmarck s Algorithm by Martin Richards A Tutology Checker loosely relted to Stålmrck s Algorithm y Mrtin Richrds mr@cl.cm.c.uk http://www.cl.cm.c.uk/users/mr/ University Computer Lortory New Museum Site Pemroke Street Cmridge, CB2 3QG Mrtin

More information

Compilers. Topic 4. The Symbol Table and Block Structure PART II. Mick O Donnell: Alfonso Ortega:

Compilers. Topic 4. The Symbol Table and Block Structure PART II. Mick O Donnell: Alfonso Ortega: Compilers Topi 4 The ol Tle nd Blok Struture PART II Mik O Donnell: mihel.odonnell@um.es Alfonso Orteg: lfonso.orteg@um.es Topi 2: Blok Struture 2 1 ol tles with lok strutures Blok Struture Progrmming

More information

6.3 Volumes. Just as area is always positive, so is volume and our attitudes towards finding it.

6.3 Volumes. Just as area is always positive, so is volume and our attitudes towards finding it. 6.3 Volumes Just s re is lwys positive, so is volume nd our ttitudes towrds finding it. Let s review how to find the volume of regulr geometric prism, tht is, 3-dimensionl oject with two regulr fces seprted

More information

SOFTWARE-BUG LOCALIZATION WITH GRAPH MINING

SOFTWARE-BUG LOCALIZATION WITH GRAPH MINING Chpter 17 SOFTWARE-BUG LOCALIZATION WITH GRAPH MINING Frnk Eihinger Institute for Progrm Strutures nd Dt Orgniztion (IPD) Universit-t Krlsruhe (TH), Germny eihinger@ipd.uk.de Klemens B-ohm Institute for

More information

Algorithm Design (5) Text Search

Algorithm Design (5) Text Search Algorithm Design (5) Text Serch Tkshi Chikym School of Engineering The University of Tokyo Text Serch Find sustring tht mtches the given key string in text dt of lrge mount Key string: chr x[m] Text Dt:

More information

INTEGRATED WORKFLOW ART DIRECTOR

INTEGRATED WORKFLOW ART DIRECTOR ART DIRECTOR Progrm Resoures INTEGRATED WORKFLOW PROGRAM PLANNING PHASE In this workflow phse proess, you ollorte with the Progrm Mnger, the Projet Mnger, nd the Art Speilist/ Imge Led to updte the resoures

More information

Package Contents. Wireless-G USB Network Adapter with SpeedBooster USB Cable Setup CD-ROM with User Guide (English only) Quick Installation

Package Contents. Wireless-G USB Network Adapter with SpeedBooster USB Cable Setup CD-ROM with User Guide (English only) Quick Installation A Division of Ciso Systems, In. Pkge Contents Wireless-G USB Network Adpter with SpeedBooster USB Cle Setup CD-ROM with User Guide (English only) Quik Instlltion 2,4 GHz 802.11g Wireless Model No. Model

More information

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming Lecture 10 Evolutionry Computtion: Evolution strtegies nd genetic progrmming Evolution strtegies Genetic progrmming Summry Negnevitsky, Person Eduction, 2011 1 Evolution Strtegies Another pproch to simulting

More information

Honors Thesis: Investigating the Algebraic Properties of Cayley Digraphs

Honors Thesis: Investigating the Algebraic Properties of Cayley Digraphs Honors Thesis: Investigting the Algebri Properties of Cyley Digrphs Alexis Byers, Wittenberg University Mthemtis Deprtment April 30, 2014 This pper utilizes Grph Theory to gin insight into the lgebri struture

More information

Fig.25: the Role of LEX

Fig.25: the Role of LEX The Lnguge for Specifying Lexicl Anlyzer We shll now study how to uild lexicl nlyzer from specifiction of tokens in the form of list of regulr expressions The discussion centers round the design of n existing

More information

box Boxes and Arrows 3 true 7.59 'X' An object is drawn as a box that contains its data members, for example:

box Boxes and Arrows 3 true 7.59 'X' An object is drawn as a box that contains its data members, for example: Boxes nd Arrows There re two kinds of vriles in Jv: those tht store primitive vlues nd those tht store references. Primitive vlues re vlues of type long, int, short, chr, yte, oolen, doule, nd flot. References

More information

Triple/Quadruple Patterning Layout Decomposition via Novel Linear Programming and Iterative Rounding

Triple/Quadruple Patterning Layout Decomposition via Novel Linear Programming and Iterative Rounding Triple/Qudruple Ptterning Lyout Deomposition vi Novel Liner Progrmming nd Itertive Rounding Yio Lin, Xioqing Xu, Bei Yu, Ross Bldik nd Dvid Z. Pn ECE Dept., University of Texs t Austin, Austin, TX USA

More information

Midterm 2 Sample solution

Midterm 2 Sample solution Nme: Instructions Midterm 2 Smple solution CMSC 430 Introduction to Compilers Fll 2012 November 28, 2012 This exm contins 9 pges, including this one. Mke sure you hve ll the pges. Write your nme on the

More information

Inter-domain Routing

Inter-domain Routing COMP 631: NETWORKED & DISTRIBUTED SYSTEMS Inter-domin Routing Jsleen Kur Fll 2016 1 Internet-sle Routing: Approhes DV nd link-stte protools do not sle to glol Internet How to mke routing slle? Exploit

More information

Minimal Memory Abstractions

Minimal Memory Abstractions Miniml Memory Astrtions (As implemented for BioWre Corp ) Nthn Sturtevnt University of Alert GAMES Group Ferury, 7 Tlk Overview Prt I: Building Astrtions Minimizing memory requirements Performnes mesures

More information

UTMC APPLICATION NOTE UT1553B BCRT TO INTERFACE PSEUDO-DUAL-PORT RAM ARCHITECTURE INTRODUCTION ARBITRATION DETAILS DESIGN SELECTIONS

UTMC APPLICATION NOTE UT1553B BCRT TO INTERFACE PSEUDO-DUAL-PORT RAM ARCHITECTURE INTRODUCTION ARBITRATION DETAILS DESIGN SELECTIONS UTMC APPLICATION NOTE UT1553B BCRT TO 80186 INTERFACE INTRODUCTION The UTMC UT1553B BCRT is monolithi CMOS integrte iruit tht provies omprehensive Bus Controller n Remote Terminl funtions for MIL-STD-

More information

Suffix Tries. Slides adapted from the course by Ben Langmead

Suffix Tries. Slides adapted from the course by Ben Langmead Suffix Tries Slides dpted from the course y Ben Lngmed en.lngmed@gmil.com Indexing with suffixes Until now, our indexes hve een sed on extrcting sustrings from T A very different pproch is to extrct suffixes

More information

Troubleshooting. Verify the Cisco Prime Collaboration Provisioning Installation (for Advanced or Standard Mode), page

Troubleshooting. Verify the Cisco Prime Collaboration Provisioning Installation (for Advanced or Standard Mode), page Trouleshooting This setion explins the following: Verify the Ciso Prime Collortion Provisioning Instlltion (for Advned or Stndrd Mode), pge 1 Upgrde the Ciso Prime Collortion Provisioning from Smll to

More information

Representation of Numbers. Number Representation. Representation of Numbers. 32-bit Unsigned Integers 3/24/2014. Fixed point Integer Representation

Representation of Numbers. Number Representation. Representation of Numbers. 32-bit Unsigned Integers 3/24/2014. Fixed point Integer Representation Representtion of Numbers Number Representtion Computer represent ll numbers, other thn integers nd some frctions with imprecision. Numbers re stored in some pproximtion which cn be represented by fixed

More information

Tries. Yufei Tao KAIST. April 9, Y. Tao, April 9, 2013 Tries

Tries. Yufei Tao KAIST. April 9, Y. Tao, April 9, 2013 Tries Tries Yufei To KAIST April 9, 2013 Y. To, April 9, 2013 Tries In this lecture, we will discuss the following exct mtching prolem on strings. Prolem Let S e set of strings, ech of which hs unique integer

More information

INTRODUCTION TO SIMPLICIAL COMPLEXES

INTRODUCTION TO SIMPLICIAL COMPLEXES INTRODUCTION TO SIMPLICIAL COMPLEXES CASEY KELLEHER AND ALESSANDRA PANTANO 0.1. Introduction. In this ctivity set we re going to introduce notion from Algebric Topology clled simplicil homology. The min

More information

Stack Manipulation. Other Issues. How about larger constants? Frame Pointer. PowerPC. Alternative Architectures

Stack Manipulation. Other Issues. How about larger constants? Frame Pointer. PowerPC. Alternative Architectures Other Issues Stck Mnipultion support for procedures (Refer to section 3.6), stcks, frmes, recursion mnipulting strings nd pointers linkers, loders, memory lyout Interrupts, exceptions, system clls nd conventions

More information

Tiling Triangular Meshes

Tiling Triangular Meshes Tiling Tringulr Meshes Ming-Yee Iu EPFL I&C 1 Introdution Astrt When modelling lrge grphis senes, rtists re not epeted to model minute nd repetitive fetures suh s grss or snd with individul piees of geometry

More information

Shared Memory Architectures. Programming and Synchronization. Today s Outline. Page 1. Message passing review Cosmic Cube discussion

Shared Memory Architectures. Programming and Synchronization. Today s Outline. Page 1. Message passing review Cosmic Cube discussion Tody s Outline Arhitetures Progrmming nd Synhroniztion Disuss pper on Cosmi Cube (messge pssing) Messge pssing review Cosmi Cube disussion > Messge pssing mhine Shred memory model > Communition > Synhroniztion

More information

ITEC2620 Introduction to Data Structures

ITEC2620 Introduction to Data Structures ITEC0 Introduction to Dt Structures Lecture 7 Queues, Priority Queues Queues I A queue is First-In, First-Out = FIFO uffer e.g. line-ups People enter from the ck of the line People re served (exit) from

More information

FASTEST METHOD TO FIND ALTERNATIVE RE-ROUTE

FASTEST METHOD TO FIND ALTERNATIVE RE-ROUTE INTERNATIONAL JOURNAL OF RESEARCH IN COMPUTER APPLICATIONS AND ROBOTICS ISSN 2320-7345 FASTEST METHOD TO FIND ALTERNATIVE RE-ROUTE 1 M.JothiLkshmi, M.S., M.Phil. 2 C.Theeendr, M.S., M.Phil. 3 M.K.Pvithr,

More information

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus Unit #9 : Definite Integrl Properties, Fundmentl Theorem of Clculus Gols: Identify properties of definite integrls Define odd nd even functions, nd reltionship to integrl vlues Introduce the Fundmentl

More information

Smart Output Field Installation for M-Series and L-Series Converter

Smart Output Field Installation for M-Series and L-Series Converter Smrt Output Field Instlltion for M-Series nd L-Series Converter Instlltion Proedure -- See setion 5.0, Instlltion Proedure 1. Open the Housing nd Prepre for Instlltion 2. Plug the Rion Cle into the Min

More information

1.1. Interval Notation and Set Notation Essential Question When is it convenient to use set-builder notation to represent a set of numbers?

1.1. Interval Notation and Set Notation Essential Question When is it convenient to use set-builder notation to represent a set of numbers? 1.1 TEXAS ESSENTIAL KNOWLEDGE AND SKILLS Prepring for 2A.6.K, 2A.7.I Intervl Nottion nd Set Nottion Essentil Question When is it convenient to use set-uilder nottion to represent set of numers? A collection

More information

Line The set of points extending in two directions without end uniquely determined by two points. The set of points on a line between two points

Line The set of points extending in two directions without end uniquely determined by two points. The set of points on a line between two points Lines Line Line segment Perpendiulr Lines Prllel Lines Opposite Angles The set of points extending in two diretions without end uniquely determined by two points. The set of points on line between two

More information

COMPUTER EDUCATION TECHNIQUES, INC. (WEBLOGIC_SVR_ADM ) SA:

COMPUTER EDUCATION TECHNIQUES, INC. (WEBLOGIC_SVR_ADM ) SA: In orer to lern whih questions hve een nswere orretly: 1. Print these pges. 2. Answer the questions. 3. Sen this ssessment with the nswers vi:. FAX to (212) 967-3498. Or. Mil the nswers to the following

More information

Grade 7/8 Math Circles Geometric Arithmetic October 31, 2012

Grade 7/8 Math Circles Geometric Arithmetic October 31, 2012 Fculty of Mthemtics Wterloo, Ontrio N2L 3G1 Grde 7/8 Mth Circles Geometric Arithmetic Octoer 31, 2012 Centre for Eduction in Mthemtics nd Computing Ancient Greece hs given irth to some of the most importnt

More information

Single-Layer Trunk Routing Using 45-Degree Lines within Critical Areas for PCB Routing

Single-Layer Trunk Routing Using 45-Degree Lines within Critical Areas for PCB Routing SASIMI 2010 Proeedings (R3-8) Single-Lyer Trunk Routing Using 45-Degree Lines within Critil Ares for PCB Routing Kyosuke SHINODA Yukihide KOHIRA Atsushi TAKAHASHI Tokyo Institute of Tehnology Dept. of

More information

Definition of Regular Expression

Definition of Regular Expression Definition of Regulr Expression After the definition of the string nd lnguges, we re redy to descrie regulr expressions, the nottion we shll use to define the clss of lnguges known s regulr sets. Recll

More information

Geometric transformations

Geometric transformations Geometric trnsformtions Computer Grphics Some slides re bsed on Shy Shlom slides from TAU mn n n m m T A,,,,,, 2 1 2 22 12 1 21 11 Rows become columns nd columns become rows nm n n m m A,,,,,, 1 1 2 22

More information

c s ha2 c s Half Adder Figure 2: Full Adder Block Diagram

c s ha2 c s Half Adder Figure 2: Full Adder Block Diagram Adder Tk: Implement 2-it dder uing 1-it full dder nd 1-it hlf dder omponent (Figure 1) tht re onneted together in top-level module. Derie oth omponent in VHDL. Prepre two implementtion where VHDL omponent

More information

MA1008. Calculus and Linear Algebra for Engineers. Course Notes for Section B. Stephen Wills. Department of Mathematics. University College Cork

MA1008. Calculus and Linear Algebra for Engineers. Course Notes for Section B. Stephen Wills. Department of Mathematics. University College Cork MA1008 Clculus nd Liner Algebr for Engineers Course Notes for Section B Stephen Wills Deprtment of Mthemtics University College Cork s.wills@ucc.ie http://euclid.ucc.ie/pges/stff/wills/teching/m1008/ma1008.html

More information

Geometrical reasoning 1

Geometrical reasoning 1 MODULE 5 Geometril resoning 1 OBJECTIVES This module is for study y n individul teher or group of tehers. It: looks t pprohes to developing pupils visulistion nd geometril resoning skills; onsiders progression

More information

1 Quad-Edge Construction Operators

1 Quad-Edge Construction Operators CS48: Computer Grphics Hndout # Geometric Modeling Originl Hndout #5 Stnford University Tuesdy, 8 December 99 Originl Lecture #5: 9 November 99 Topics: Mnipultions with Qud-Edge Dt Structures Scribe: Mike

More information

CSCI 3130: Formal Languages and Automata Theory Lecture 12 The Chinese University of Hong Kong, Fall 2011

CSCI 3130: Formal Languages and Automata Theory Lecture 12 The Chinese University of Hong Kong, Fall 2011 CSCI 3130: Forml Lnguges nd utomt Theory Lecture 12 The Chinese University of Hong Kong, Fll 2011 ndrej Bogdnov In progrmming lnguges, uilding prse trees is significnt tsk ecuse prse trees tell us the

More information