Advanced Programming Handout 5. Enter Okasaki. Persistent vs. Ephemeral. Functional Queues. Simple Example. Persistent vs.
|
|
- Ami Paul
- 6 years ago
- Views:
Transcription
1 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, the struture s it eiste efore the upte is lost. A persistent struture is one where multiple versions re simultneousl essile: fter n upte, oth ol n new versions n e use. Persistent vs. Ephemerl In impertive lnguges, most t strutures re ephemerl. It is generll epte tht persistent vrints, when the re possile t ll, will e more omple to oe n smptotill less effiient. In purel funtionl lnguges like Hskell, ll t strutures re persistent! Sine there is no ssignment, there is no w to estro ol informtion. When we re one with it, we just rop it on the floor n let the grge olletor tke re of it. So one might worr tht effiient t strutures might e hr or even impossile to oe in Hskell. Enter Okski Interestingl, it turns out tht mn ommon t strutures hve purel funtionl vrints tht re es to unerstn n hve el the sme smptoti effiien s their impertive, ephemerl vrints. These strutures hve een eplore in n influentil ook, Purel Funtionl Dt Strutures, Chris Okski, n in long series of reserh ppers Okski n others. Simple Emple To get strte, let s tke quite simple trik tht ws known to funtionl progrmmers long efore Okski... Funtionl Queues A queue (of vlues of tpe ) is struture supporting the following opertions: enqueue :: -> Queue -> Queue equeue :: Queue -> (, Queue ) We epet tht eh opertion shoul run in O(1) --- i.e., onstnt --- time, no mtter the sie of the queue.
2 Nive Implementtion A queue of vlues of tpe is just list of s: tpe Queue = [] To equeue the first element of the queue, use the he n til opertors on lists: equeue q = (he q, til q) To enqueue n element, ppen it to the en of the list: enqueue e q = q ++ [e] Nive Implementtion This works, ut the effiien of enqueue is isppointing: eh enqueue requires O(n) ons opertions! Of ourse, ons opertions re not the onl things tht tke time! But ounting just onses tull iels prett goo estimte of the (smptoti) wll-lok effiien of progrms. Here, it is ertinl ler tht the rel effiien n e no etter thn O(n). Better Implementtion Better Implementtion Ie: Represent queue using two lists: 1. the front prt of the queue 2. the k prt of the queue in reverse orer E.g.: ([1,2,3],[7,6,5,]) represents the queue with elements 1,2,3,,5,6,7 ([],[3,2,1]) n ([1,2,3],[]) oth represent the queue with elements 1,2,3 To enqueue n element, just ons it onto the k list. To equeue n element, just remove it from the front list......unless the front list is empt, in whih se we reverse the k list n use it s the front list from now on. Better Implementtion t Queue = Queue [] [] enqueue :: -> Queue -> Queue enqueue e (Queue front k) = Queue front (e:k) Effiien Intuition: equeue m require O(n) ons opertions (to reverse the k list), ut this nnot hppen too often. equeue :: Queue -> (, Queue ) equeue (Queue (e:front) k) = (e, (Queue front k)) equeue (Queue [] k) = equeue (Queue (reverse k) [])
3 Effiien In more etil: Note tht eh element n prtiipte in t most one list reversl uring its lifetime in the queue. When n element is enqueue, we n hrge two tokens for two ons opertions. One of these is performe immeitel; the other we put in the nk. At ever moment, the numer of tokens in the nk is equl to the length of the k list. When we fin we nee to reverse the k list to perform equeue, we will lws hve just enough tokens in the nk to p for ll of the ons opertions involve. Effiien So we n s tht the mortie ost of eh enqueue opertion is two onses. The mortie ost of eh equeue is ero (i.e., no onses --- just some pointer mnipultion). Cvet: This effiien rgument is somewht rough n re --- it is intene just to give n intuition for wht is going on. Mking everthing preise requires more work, espeill in l lnguge. Morl We n implement persistent queue t struture whose opertions hve the sme (smptoti, mortie) effiien s the stnr (ephemerl, oulepointer) impertive implementtion. Binr Serh Trees Suppose we wnt to implement tpe Set supporting the following opertions: empt :: Set memer :: Or => -> Set -> Bool insert :: Or => -> Set -> Set One ver simple implementtion for sets is in terms of inr serh trees... Binr Serh Trees t Set = E -- empt T (Set ) (Set ) -- nonempt empt = E memer E = Flse memer (T ) < = memer > = memer True = True insert E = T E E insert (T ) < = T (insert ) > = T (insert ) True = T Quik Digression on Ptterns The insert funtion is little hr to re euse it is not immeitel ovious tht the phrse T in the o just mens return the input. insert E = T E E insert (T ) < = T (insert ) > = T (insert ) True = T
4 Quik Digression on Ptterns Hskell for suh situtions. insert E = T E E insert t@(t ) < = T (insert ) > = T (insert ) True = t The pttern t@(t ) mens hek tht the input vlue ws onstrute with T, in its prts to,, n, n itionll let t stn for the whole input vlue in wht follows... Blne Trees If our sets grow lrge, we m fin tht the simple inr tree implementtion is not fst enough: in the worse se, eh insert or memer opertion m tke O(n) time! We n o muh etter keeping the trees lne. There re mn ws of oing this. Let s look t one firl simple (ut still ver fst) one tht ou hve prol seen efore in n impertive setting: re-lk trees. Re-Blk Trees Invrints A re-lk tree is inr serh tree where ever noe is itionll mrke with olor (re or lk) n in whih the following invrints re mintine... The empt noes t the leves re onsiere lk. Invrints The root is lws lk. Invrints From eh noe, ever pth to lef hs the sme numer of lk noes. Re noes hve lk hilren
5 Invrints Together, these invrints impl tht ever relk tree is pproimtel lne, in the sense tht the longest pth to n empt noe is no more thn twie the length of the shortest. From this, it follows tht ll opertions will run in O(log2 n) time. Now let s look t the etils... Tpe Delrtion The t elrtion is strightforwr moifition of the one for unlne trees: t Color = R B t ReBlkSet = E T Color (ReBlkSet ) (ReBlkSet ) Memership The empt tree is the sme s efore. Memership testing requires just trivil hnge. pronoune where empt = E memer E = Flse memer (T _ ) < = memer > = memer True = True Insertion Insertion is implemente in terms of reursive uilir funtion ins, whih wlks own the tree until it either gets to n empt lef noe, in whih se it onstruts new (re) noe ontining the vlue eing inserte... ins E = T R E E Insertion is more interesting... Insertion... or isovers tht the vlue eing inserte is lre in the tree, in whih se it returns the input unhnge: ins s@(t olor ) < =... > =... The reursive ses re where the rel work hppens... Insertion In the reursive se, ins etermines whether the new vlue elongs in the left or right sutree, mkes reursive ll to insert it there, n reuils the urrent noe with the new sutree. ins s@(t olor ) < =... (T olor (ins ) ) > =... (T olor (ins ))
6 Insertion Before returning it, however, we m nee to relne to mintin the re-lk invrints. The oe to o this is enpsulte in helper funtion lne. ins s@(t olor ) < = lne (T olor (ins ) ) > = lne (T olor (ins )) Blning The ke insight in writing the lning funtion is tht we o not tr to relne s soon s we see re noe with re hil. Inste, we return this tree s-is n wit until we re lle with the lk prent of this noe. I.e., the jo of the lne funtion is to relne trees with lk-re-re pth strting t the root. Sine the root hs two hilren n four grnhilren, there re four ws in whih suh pth n hppen. Blning Blning Blning Blning All tht remins is to turn these pitures into oe...
7 Blning lne (T B (T R (T R ) ) ) = T R (T B ) (T B ) lne (T B (T R (T R )) ) = T R (T B ) (T B ) lne (T B (T R (T R ) )) = T R (T B ) (T B ) lne (T B (T R (T R ))) = T R (T B ) (T B ) lne t = t One Finl Detil Sine we onl relne lk noes with re hilren n grnhilren, it is possile tht the ins funtion oul return re noe with re hil s its finl result. We n fi this foring the root noe of the returne tree to e lk, regrless of the olor returne ins. Finl Version insert t = mkerootblk (ins t) where ins E = T R E E ins s@(t olor ) < = lne (T olor (ins ) ) > = lne (T olor (ins )) mkerootblk (T _ ) = T B The Whole Bnn t Color = R B t ReBlkSet = E T Color (ReBlkSet ) (ReBlkSet ) empt = E memer E = Flse memer (T _ ) < = memer > = memer otherwise = True lne (T B (T R (T R ) ) ) = T R (T B ) (T B ) lne (T B (T R (T R )) ) = T R (T B ) (T B ) lne (T B (T R (T R ) )) = T R (T B ) (T B ) lne (T B (T R (T R ))) = T R (T B ) (T B ) lne t = t insert t = olorrootblk (ins t) where ins E = T R E E ins s@(t olor ) < = lne (T olor (ins ) ) > = lne (T olor (ins )) otherwise = s olorrootblk (T _ ) = T B For Comprison... /* This funtion n e lle onl if K2 hs left hil */ /* Perform rotte etween noe (K2) n its left hil */ /* Upte heights, then return new root */ stti Position SingleRotteWithLeft( Position K2 ) Position K1; K1 = K2->Left; K2->Left = K1->Right; K1->Right = K2; return K1; /* New root */ /* This funtion n e lle onl if K1 hs right hil */ /* Perform rotte etween noe (K1) n its right hil */ /* Upte heights, then return new root */ stti Position SingleRotteWithRight( Position K1 ) Position K2; K2 = K1->Right; K1->Right = K2->Left; K2->Left = K1; return K2; /* New root */ /* Perform rottion t noe X */ /* (whose prent is psse s prmeter) */ /* The hil is eue emining Item */ stti Position Rotte( ElementTpe Item, Position Prent ) if( Item < Prent->Element ) return Prent->Left = Item < Prent->Left->Element? SingleRotteWithLeft( Prent->Left ) : SingleRotteWithRight( Prent->Left ); else return Prent->Right = Item < Prent->Right->Element? SingleRotteWithLeft( Prent->Right ) : SingleRotteWithRight( Prent->Right ); stti Position X, P, GP, GGP; stti voi HnleReorient( ElementTpe Item, ReBlkTree T ) X->Color = Re; /* Do the olor flip */ X->Left->Color = Blk; X->Right->Color = Blk; if( P->Color == Re ) /* Hve to rotte */ GP->Color = Re; if( (Item < GP->Element)!= (Item < P->Element) ) P = Rotte( Item, GP ); /* Strt oule rotte */ X = Rotte( Item, GGP ); X->Color = Blk; T->Right->Color = Blk; /* Mke root lk */ ReBlkTree Insert( ElementTpe Item, ReBlkTree T ) X = P = GP = T; NullNoe->Element = Item; while( X->Element!= Item ) /* Desen own the tree */ GGP = GP; GP = P; P = X; if( Item < X->Element ) X = X->Left; else X = X->Right; if( X->Left->Color == Re && X->Right->Color == Re ) HnleReorient( Item, T ); if( X!= NullNoe ) return NullNoe; /* Duplite */ X = mllo( sieof( strut ReBlkNoe ) ); if( X == NULL ) FtlError( "Out of spe!!!" ); X->Element = Item; X->Left = X->Right = NullNoe; if( Item < P->Element ) /* Atth to its prent */ P->Left = X; else P->Right = X; HnleReorient( Item, T ); /* Color it re; me rotte */ return T;
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 informationGreedy 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 informationCS 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 informationContainers: Queue and List
Continers: Queue n List Queue A ontiner in whih insertion is one t one en (the til) n eletion is one t the other en (the he). Also lle FIFO (First-In, First-Out) Jori Cortell n Jori Petit Deprtment of
More informationType 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 information10.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 informationCOMMON 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 informationEXPONENTIAL & 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 information2-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 informationCOMP 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 informationAdvanced Programming Handout 5. Purely Functional Data Structures: A Case Study in Functional Programming
Advanced Programming Handout 5 Purely Functional Data Structures: A Case Study in Functional Programming Persistent vs. Ephemeral An ephemeral data structure is one for which only one version is available
More informationbox 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 informationAdvanced Programming Handout 6. Purely Functional Data Structures: A Case Study in Functional Programming
Advanced Programming Handout 6 Purely Functional Data Structures: A Case Study in Functional Programming Persistent vs. Ephemeral An ephemeral data structure is one for which only one version is available
More information2 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 informationV = set of vertices (vertex / node) E = set of edges (v, w) (v, w in V)
Definitions G = (V, E) V = set of verties (vertex / noe) E = set of eges (v, w) (v, w in V) (v, w) orere => irete grph (igrph) (v, w) non-orere => unirete grph igrph: w is jent to v if there is n ege from
More informationMTH 146 Conics Supplement
105- Review of Conics MTH 146 Conics Supplement In this section we review conics If ou ne more detils thn re present in the notes, r through section 105 of the ook Definition: A prol is the set of points
More informationIntroduction 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 informationCSCI 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 information6.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 information4.3 Balanced Trees. let us assume that we can manipulate them conveniently and see how they can be put together to form trees.
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
More informationIn 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 informationParadigm 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 informationimplementation 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 informationXML and Databases. Outline. XPath. Outline - Lectures. XPath Data Model. Outline - Assignments. XPath. Sebastian Maneth NICTA and UNSW
Outline XML n Dtses Leture 6 Noe Seleting Queries: XPth 1.0 1. XPth Dt Moel: 7 types of noes 2. Simple Exmples 3. Lotion Steps n Pths 4. Vlue Comprison, n Other Funtions Sestin Mneth NICTA n UNSW CSE@UNSW
More informationProblem 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 informationFig.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 informationError 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 informationUTMC 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 informationBalanced 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 informationChapter 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 informationSection 2.3 Functions. Definition: Let A and B be sets. A function (mapping, map) f from A to B, denoted f :A B, is a subset of A B such that
Setion 2.3 Funtions Definition: Let n e sets. funtion (mpping, mp) f from to, enote f :, is suset of suh tht x[x y[y < x, y > f ]] n [< x, y 1 > f < x, y 2 > f ] y 1 = y 2 Note: f ssoites with eh x in
More informationSection 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 informationToday. CS 188: Artificial Intelligence Fall Recap: Search. Example: Pancake Problem. Example: Pancake Problem. General Tree Search.
CS 88: Artificil Intelligence Fll 00 Lecture : A* Serch 9//00 A* Serch rph Serch Tody Heuristic Design Dn Klein UC Berkeley Multiple slides from Sturt Russell or Andrew Moore Recp: Serch Exmple: Pncke
More informationPattern 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 information3D convex hulls. Convex Hull in 3D. convex polyhedron. convex polyhedron. The problem: Given a set P of points in 3D, compute their convex hull
Convex Hull in The rolem: Given set P of oints in, omute their onvex hull onvex hulls Comuttionl Geometry [si 3250] Lur Tom Bowoin College onvex olyheron 1 2 3 olygon olyheron onvex olyheron 4 5 6 Polyheron
More informationDefinition 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 informationCalculus Differentiation
//007 Clulus Differentition Jeffrey Seguritn person in rowot miles from the nerest point on strit shoreline wishes to reh house 6 miles frther down the shore. The person n row t rte of mi/hr nd wlk t rte
More informationStack 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 informationParallelization 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 informationClass Overview. Database Design. Database Design Process. Database Design. Introduction to Data Management CSE 414
Introution to Dt Mngement CSE 44 Unit 6: Coneptul Design E/R Digrms Integrity Constrints BCNF Introution to Dt Mngement CSE 44 E/R Digrms ( letures) CSE 44 Autumn 08 Clss Overview Dtse Design Unit : Intro
More informationAnnouncements. CS 188: Artificial Intelligence Fall Recap: Search. Today. Example: Pancake Problem. Example: Pancake Problem
Announcements Project : erch It s live! Due 9/. trt erly nd sk questions. It s longer thn most! Need prtner? Come up fter clss or try Pizz ections: cn go to ny, ut hve priority in your own C 88: Artificil
More information1 Which of the following keyword can not be appeared inside the class? a)virtual b)static c)template d)friend c
1 Whih of the following keywor n not e ppere insie the lss? )virtul )stti )templte )frien 2 Wht is templte? )Templte is formul for reting generi lss )Templte is use to mnipulte lss )Templte is use for
More informationMidterm 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 informationLesson 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 informationWORKSHOP 19 GLOBAL/LOCAL MODELING USING FEM FIELDS
WORKSHOP 19 GLOBAL/LOCAL MODELING USING FEM FIELDS WS19-1 WS19-2 Prolem Desription This exerise is use to emonstrte how to mp isplement results from the nlysis of glol(overll) moel onto the perimeter of
More informationMinimal 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 information8.2 Areas in the Plane
39 Chpter 8 Applictions of Definite Integrls 8. Ares in the Plne Wht ou will lern out... Are Between Curves Are Enclosed Intersecting Curves Boundries with Chnging Functions Integrting with Respect to
More informationCOMP108 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 informationPROBLEM OF APOLLONIUS
PROBLEM OF APOLLONIUS In the Jnury 010 issue of Amerin Sientist D. Mkenzie isusses the Apollonin Gsket whih involves fining the rius of the lrgest irle whih just fits into the spe etween three tngent irles
More informationDr. D.M. Akbar Hussain
Dr. D.M. Akr Hussin Lexicl Anlysis. Bsic Ide: Red the source code nd generte tokens, it is similr wht humns will do to red in; just tking on the input nd reking it down in pieces. Ech token is sequence
More informationConvex Hull Algorithms. Convex hull: basic facts
CG Leture D Conve Hull Algorithms Bsi fts Algorithms: Nïve, Gift wrpping, Grhm sn, Quik hull, Divide-nd-onquer Lower ound 3D Bsi fts Algorithms: Gift wrpping, Divide nd onquer, inrementl Conve hulls in
More informationCS 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 informationCMPUT101 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 informationWhat 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 informationCompilers. 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 informationLecture 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 information1 Disjoint-set data structure.
CS 124 Setion #4 Union-Fin, Greey Algorithms 2/20/17 1 Disjoint-set ata struture. 1.1 Operations Disjoint-set ata struture enale us to effiiently perform operations suh as plaing elements into sets, querying
More informationGENG2140 Modelling and Computer Analysis for Engineers
GENG4 Moelling n Computer Anlysis or Engineers Letures 9 & : Gussin qurture Crete y Grn Romn Joles, PhD Shool o Mehnil Engineering, UWA GENG4 Content Deinition o Gussin qurture Computtion o weights n points
More informationOrthogonal line segment intersection
Computtionl Geometry [csci 3250] Line segment intersection The prolem (wht) Computtionl Geometry [csci 3250] Orthogonl line segment intersection Applictions (why) Algorithms (how) A specil cse: Orthogonl
More informationMatrices and Systems of Equations
Mtrices Mtrices nd Sstems of Equtions A mtri is rectngulr rr of rel numbers. CHAT Pre-Clculus Section 8. m m m............ n n n mn We will use the double subscript nottion for ech element of the mtri.
More informationLesson 11 MA Nick Egbert
Lesson MA 62 Nick Eert Overview In this lesson we return to stndrd Clculus II mteril with res etween curves. Recll rom irst semester clculus tht the deinite interl hd eometric menin, nmel the re under
More informationDeletion The Two Child Case 10 Delete(5) Deletion The Two Child Case. Balanced BST. Finally
Deletion Te Two Cild Cse Delete() Deletion Te Two Cild Cse Ide: Replce te deleted node wit vlue gurnteed to e etween te two cild sutrees! Options: succ from rigt sutree: findmin(t.rigt) pred from left
More informationAlgorithm 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 informationCICS Application Design
CICS Applition Design 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
More informationComputational 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 informationCOMPUTER 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 informationMa/CS 6b Class 1: Graph Recap
M/CS 6 Clss 1: Grph Recp By Adm Sheffer Course Detils Adm Sheffer. Office hour: Tuesdys 4pm. dmsh@cltech.edu TA: Victor Kstkin. Office hour: Tuesdys 7pm. 1:00 Mondy, Wednesdy, nd Fridy. http://www.mth.cltech.edu/~2014-15/2term/m006/
More informationInformation Retrieval and Organisation
Informtion Retrievl nd Orgnistion Suffix Trees dpted from http://www.mth.tu.c.il/~himk/seminr02/suffixtrees.ppt Dell Zhng Birkeck, University of London Trie A tree representing set of strings { } eef d
More informationPremaster Course Algorithms 1 Chapter 6: Shortest Paths. Christian Scheideler SS 2018
Premster Course Algorithms Chpter 6: Shortest Pths Christin Scheieler SS 8 Bsic Grph Algorithms Overview: Shortest pths in DAGs Dijkstr s lgorithm Bellmn-For lgorithm Johnson s metho SS 8 Chpter 6 Shortest
More informationPointers and Arrays. More Pointer Examples. Pointers CS 217
Pointers nd Arrs CS 21 1 2 Pointers More Pointer Emples Wht is pointer A vrile whose vlue is the ddress of nother vrile p is pointer to vrile v Opertions &: ddress of (reference) *: indirection (dereference)
More informationCS553 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 informationTries. 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 informationCSEP 573 Artificial Intelligence Winter 2016
CSEP 573 Artificil Intelligence Winter 2016 Luke Zettlemoyer Problem Spces nd Serch slides from Dn Klein, Sturt Russell, Andrew Moore, Dn Weld, Pieter Abbeel, Ali Frhdi Outline Agents tht Pln Ahed Serch
More informationCS201 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ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών
ΕΠΛ323 - Θωρία και Πρακτική Μταγλωττιστών Lecture 3 Lexicl Anlysis Elis Athnsopoulos elisthn@cs.ucy.c.cy Recognition of Tokens if expressions nd reltionl opertors if è if then è then else è else relop
More informationSuffix 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 informationLecture 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 informationINTEGRATED 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 informationOutline. 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 informationCOSC 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 informationMIPS I/O and Interrupt
MIPS I/O nd Interrupt Review Floting point instructions re crried out on seprte chip clled coprocessor 1 You hve to move dt to/from coprocessor 1 to do most common opertions such s printing, clling functions,
More informationGeometric 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 informationCS453 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 informationFunctor (1A) Young Won Lim 8/2/17
Copyright (c) 2016-2017 Young W. Lim. Permission is grnted to copy, distribute nd/or modify this document under the terms of the GNU Free Documenttion License, Version 1.2 or ny lter version published
More informationAsurveyofpractical algorithms for suffix tree construction in external memory
Asurveyofprtil lgorithms for suffix tree onstrution in externl memory M. Brsky,, U. Stege n A. Thomo University of Vitori, PO Box, STN CSC Vitori, BC, VW P, Cn SUMMAY The onstrution of suffix trees in
More information10.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 informationFinal 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 informationChapter 16. Shortest Paths Shortest Weighted Paths
Chpter 6 Shortet Pth Given grph where ege re lle with weight (or itne) n oure vertex, wht i the hortet pth etween the oure n ome other vertex? Prolem requiring u to nwer uh querie re roly known hortet-pth
More informationFunctor (1A) Young Won Lim 10/5/17
Copyright (c) 2016-2017 Young W. Lim. Permission is grnted to copy, distribute nd/or modify this document under the terms of the GNU Free Documenttion License, Version 1.2 or ny lter version published
More information4/29/18 FIBONACCI NUMBERS GOLDEN RATIO, RECURRENCES. Fibonacci function. Fibonacci (Leonardo Pisano) ? Statue in Pisa Italy
/9/8 Fioncci (Leonrdo Pisno) -? Sttue in Pis Itly FIBONACCI NUERS GOLDEN RATIO, RECURRENCES Lecture CS Spring 8 Fioncci function fi() fi() fi(n) fi(n-) + fi(n-) for n,,,,,, 8,,, In his ook in titled Lier
More informationTyping with Weird Keyboards Notes
Typing with Weird Keyords Notes Ykov Berchenko-Kogn August 25, 2012 Astrct Consider lnguge with n lphet consisting of just four letters,,,, nd. There is spelling rule tht sys tht whenever you see n next
More informationFEEDBACK: 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 informationUnit #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 informationDistributed 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 information12/9/14. CS151 Fall 20124Lecture (almost there) 12/6. Graphs. Seven Bridges of Königsberg. Leonard Euler
CS5 Fll 04Leture (lmost there) /6 Seven Bridges of Königserg Grphs Prof. Tny Berger-Wolf Leonrd Euler 707-783 Is it possile to wlk with route tht rosses eh ridge e Seven Bridges of Königserg Forget unimportnt
More informationMa/CS 6b Class 1: Graph Recap
M/CS 6 Clss 1: Grph Recp By Adm Sheffer Course Detils Instructor: Adm Sheffer. TA: Cosmin Pohot. 1pm Mondys, Wednesdys, nd Fridys. http://mth.cltech.edu/~2015-16/2term/m006/ Min ook: Introduction to Grph
More informationIf you are at the university, either physically or via the VPN, you can download the chapters of this book as PDFs.
Lecture 5 Wlks, Trils, Pths nd Connectedness Reding: Some of the mteril in this lecture comes from Section 1.2 of Dieter Jungnickel (2008), Grphs, Networks nd Algorithms, 3rd edition, which is ville online
More informationSuffix trees, suffix arrays, BWT
ALGORITHMES POUR LA BIO-INFORMATIQUE ET LA VISUALISATION COURS 3 Rluc Uricru Suffix trees, suffix rrys, BWT Bsed on: Suffix trees nd suffix rrys presenttion y Him Kpln Suffix trees course y Pco Gomez Liner-Time
More informationCOMPUTER SCIENCE 123. Foundations of Computer Science. 6. Tuples
COMPUTER SCIENCE 123 Foundtions of Computer Science 6. Tuples Summry: This lecture introduces tuples in Hskell. Reference: Thompson Sections 5.1 2 R.L. While, 2000 3 Tuples Most dt comes with structure
More informationTiling 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