Containers: Queue and List
|
|
- Elijah Welch
- 5 years ago
- Views:
Transcription
1 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 Computer Siene push (enqueue) Queue pop (equeue) Queue usge Queue<int> Q; // Construtor Q.push(); Q.push(8); Q.push(); int n = Q.size(); // n = while (not Q.empty()) { int = Q.front(); out << << enl; Q.pop(); // Inserting few ents // Get the ent // Delete the ent Continers Dept. CS, UPC templte<typenme T> lss Queue { puli: Queue(); ~Queue(); Queue(onst T& Q); The lss Queue // Construtor // Destrutor // Copy onstrutor Queue& opertor= (onst Queue& Q); // Assignment opertor voi push(onst& T x); voi pop(); T front() onst; int size() onst; // Enqueues n ent // Dequeues the ent // Returns the ent // Numer of ents in the queue ool empty() onst; ; // Is the queue empty? Continers Dept. CS, UPC Continers Dept. CS, UPC
2 Implementtion with linke lists lst, lst Implementtion with linke lists, lst lst Q.push() Q.push(8) 8 templte<typenme T> lss Queue { privte: strut Noe { T ; Noe* ; ; Noe *; Noe *lst; int n; // Pointer to the ent // Pointer to the lst ent // Numer of ents Q.push() Q.pop() 8 8 lst lst Continers Dept. CS, UPC Queue: some methos Continers Dept. CS, UPC Queue: onstrutors n estrutor /** Returns the numer of ents. */ int size() onst { return n; /** Cheks whether the queue is empty. */ ool empty() onst { return size() == ; /** Inserts new ent t the en of the queue. */ voi push(onst T& x) { Noe* p = new Noe {x, nullptr; if (n++ == ) = lst = p; else lst = lst-> = p; /** Removes the ent. Pre: the queue is not empty. */ voi pop() { ssert(not empty()); Noe* ol = ; = ->; elete ol; if (--n == ) lst = nullptr; /** Returns the ent. Pre: the queue is not empty. */ T front() onst { ssert(not empty()); return ->; /** Defult onstrutor: n empty queue. */ Queue() : (nullptr), lst(nullptr), n() { /** Copy onstrutor. */ Queue(onst Queue& Q) { opy(q); /** Assignment opertor. */ Queue& opertor= (onst Queue& Q) { if (&Q!= this) { free(); opy(q); return *this; /** Destrutor. */ ~Queue() { free(); privte: /** Frees the linke list of noes in the queue. */ voi free() { Noe* p = ; while (p) { Noe* ol = p; p = p->; elete ol; Continers Dept. CS, UPC Continers Dept. CS, UPC 8
3 Q: *this: Queue: opy (privte) Q. /** Copies queue. */ voi opy(onst Queue& Q) { n = Q.n; if (n == ) { = lst = nullptr; else { Noe* p = Q.; Noe* p = = new Noe {p->; while (p->) { p = p->; p = p-> = new Noe {p->; p-> = nullptr; lst = p; Continers Dept. CS, UPC 9 Implementtion with irulr uffer p p Implementtion with irulr uffer A queue n lso e implemente with n rry (vetor) of ents. It is more effiient representtion if the mximum numer of ents in the queue is known in vne. Continers Dept. CS, UPC Implementtion with irulr uffer re re e fter Q.push(e) Continers Dept. CS, UPC Continers Dept. CS, UPC
4 Implementtion with irulr uffer Implementtion with irulr uffer re e re fter Q.pop() Continers Dept. CS, UPC Implementtion with irulr uffer Continers Dept. CS, UPC The lss Queue templte<typenme T> lss Queue { puli: Queue(int pity = ); ~Queue(); // Construtor (with pity) // Destrutor Queue(onst T& Q); // Copy onstrutor Queue& opertor= (onst Queue& Q); // Assignment opertor re voi push(onst& T x); voi pop(); T front() onst; // Enqueues n ent // Dequeues the ent t the he // Returns the ent int size() onst; // Numer of ents in the queue int pity() onst; // Returns the pity of the queue ool empty() onst; // Is the queue empty? fter Q.push() ool full() onst; ; // Is the queue full? Continers Dept. CS, UPC Continers Dept. CS, UPC
5 The lss Queue (inomplete) The lss Queue (inomplete) templte<typenme T> lss Queue { privte: vetor<t> uffer; int re, ; int n; // The uffer to store ents // The re/ inies // The numer of ents puli: /** Construtor with pity of the queue. */ Queue(int pity=) : uffer(pity), re(), (), n() { /** Returns the size of the queue. */ int size() onst { return n; /** Returns the pity of the queue. */ int pity() onst { return uffer.size(); /** Cheks whether the queue is full. */ ool full() onst { return size() == pity(); /** Enqueues new ent. Pre: the queue is not full. */ voi push(onst T& x) { ++n; ssert(not full()); uffer[] = x; in(); /** Dequeues the ent. Pre: the queue is not empty. */ voi pop() { ssert(not empty()); in(re); --n; /** Returns the ent. Pre: the queue is not empty. */ T front() onst { ssert(not empty()); return uffer[re]; privte: /** Inreses inex irulrly. */ voi in(int& i) { if (++i == pity()) i = ; Continers Dept. CS, UPC Queue: Complexity All opertions in queues n run in onstnt time, exept for: Copy: liner in the size of the list. Delete: liner in the size of the list. Continers Dept. CS, UPC 8 Exerise Exten the vetor-se implementtion of the queue to remove the onstrint on mximum pity. Queues o not llow to ess/inserte/elete ents in the mile of the queue. How: Inrese pity of the vetor. Reorgnize the ents in the queue. Continers Dept. CS, UPC 9 Continers Dept. CS, UPC
6 List List: grphil representtion List: ontiner with sequentil ess. lst It llows to insert/erse ents in the mile of the list in onstnt time. A list n e onsiere s sequene of ents with one or severl s (itertors) pointing t internl ents. For simpliity, we will only onsier lists with one itertor. Chek the STL list: it n e visite y ny numer of itertors L.insert() L.move_right() L.erse() 8 8 Continers Dept. CS, UPC List implementtions Continers Dept. CS, UPC The lss List: privte representtion templte <typenme T> lss List { Two stks Douly linke noes Sentinel : pointer t the noe fter the /** Douly linke noe of the list. */ strut Noe { Noe* prev; /** Pointer to the previous noe. */ T ; /** The ent of the list. */ Noe* ; /** Pointer to the ent. */ ; Noe* sentinel; /** Sentinel of the list. */ Noe* ; /** Noe fter the. */ int n; /** Numer of ents (without sentinel). */ efore the fter the Continers Dept. CS, UPC Continers Dept. CS, UPC
7 The lss List: puli methos The lss List: puli methos puli: /** Construtor of n empty list. */ List() : sentinel(new Noe), (sentinel), n() { sentinel-> = sentinel->prev = sentinel; /** Destrutor. */ ~List() { free(); /** Copy onstrutor. */ List(onst List& L) { opy(l); /** Assignment opertor. */ List& opertor= (onst List& L) { if (&L!= this) { free(); opy(l); return *this; /** Returns the numer of ents in the list. */ int size() onst { return n; /** Cheks whether the list is empty. */ ool empty() onst { return size() == ; puli: /** Cheks whether the is t the eginning of the list. */ ool is_t_front() onst { return == sentinel->; /** Cheks whether the is t the en of the list. */ ool is_t_en() onst { return == sentinel; /** Moves the one position kwr. Pre: the is not t the eginning of the list. */ voi move_kwr() { ssert(not is_t_front()); = ->prev; /** Moves the one position forwr. Pre: the is not t the en of the list. */ voi move_forwr() { ssert(not is_t_en()); = ->; Continers Dept. CS, UPC The lss List: puli methos Continers Dept. CS, UPC The lss List: puli methos puli: /** Moves the to the eginning of the list. */ voi move_to_front() { = sentinel->; /** Moves the to the en of the list. */ voi move_to_en() { = sentinel; /** Inserts n ent x efore the. */ voi insert(onst T& x) { Noe* p = new Noe {->prev, x, ; ->prev = ->prev-> = p; ++n; x x p puli: /** Erses the ent fter the. Pre: is not t the en. */ voi erse() { ssert(not is_t_en()); Noe* p = ; p->->prev = p->prev; = p->prev-> = p->; elete p; --n; /** Returns the ent fter the. Pre: the is not t the en. */ T front() onst { ssert(not is_t_en()); return ->; p Exerises: implement the privte methos opy() n free(). Continers Dept. CS, UPC Continers Dept. CS, UPC 8
8 Exerises for lists Exerises for lists Design the metho reverse() tht reverses the ontents of the list: No uxiliry lists shoul e use. No opies of the ents shoul e performe. Solve the Josephus prolem, for n people n exeuting every k-th person, using irulr list: Design the metho merge(onst List& L) tht merges the list with nother list L, ssuming tht oth lists re sorte. Assume tht pir of ents n e ompre with the opertor <. Design the metho sort() tht sorts the list oring to the < opertor. Consier merge sort n quik sort s possile lgorithms. Exten the previous methos with the ompre funtion s prmeter of eh metho. Continers Dept. CS, UPC 9 Higher-orer funtions A higher-orer funtion is funtion tht n reeive other funtions s prmeters or return funtion s result. Most lnguges support higher-orer funtions (C++, python, R, Hskell, Jv, JvSript, ). The hve ifferent pplitions: sort in STL is higher-orer funtion (the ompre funtion is prmeter). funtions to visit the ents of ontiners (lists, trees, et.) n e psse s prmeters. Mthemtis: funtions for omposition n integrtion reeive funtion s prmeter. et Continers Dept. CS, UPC Higher-orer funtions: exmple templte <typenme T> lss List { /** Trnsforms every ent of the list using f. It returns referene to the list. */ List<T>& trnsform(voi f(t&)); /** Returns list with the ents for whih f is true */ List<T> filter(ool f(onst T&)) onst; /** Applies f sequentilly to the list n returns single vlue. For the list [x, x, x,, x n ] it returns f( f f x, x, x, x n ). If the list hs one ent, it returns x. The list is ssume to e non-empty */ T reue(t f(onst T&, onst T&)) onst; Continers Dept. CS, UPC Continers Dept. CS, UPC
9 Higher-orer funtions: exmple Higher-orer funtions: exmple /** Cheks whether numer is prime */ ool isprime(int n) { /** As two numers */ int (int x, int y) { return x + y; /** Returns the squre of numer */ int squre(int x) { return x*x; /** The following oe omputes: */ x L, x is prime Note: it ssumes tht there is t lest one prime in the list. int n = L.filter(isPrime).trnsform(squre).reue(); Continers Dept. CS, UPC x List<T>& trnsform(voi f(t&)) { Noe* p = sentinel->; while (p!= sentinel) { // Visit ll ents n pply f to eh one f(p->); p = p->; return *this; List<T> filter(ool f(onst T&)) onst { List<T> L; Noe* p = sentinel->; while (p!= sentinel) { // Pik ents only if f is sserte if (f(p->)) L.insert(p->); p = p->; return L; T reue(t f(onst T&, onst T&)) onst { ssert(l.size() > ); T x = sentinel->->; // First ent (n result) Noe* p = sentinel->->; while (p!= sentinel) { x = f(x, p->); // Composition with ent p = p->; return x; Continers Dept. CS, UPC
Containers: Queue and List. Jordi Cortadella and Jordi Petit Department of Computer Science
Containers: Queue and List Jordi Cortadella and Jordi Petit Department of Computer Science Queue A container in which insertion is done at one end (the tail) and deletion is done at the other end (the
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 informationDistance 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 informationCOSC 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 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 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 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 informationWORKSHOP 3 FRAME MODEL CREATION USING CURVES, AND ANALYSIS
WORKSHOP 3 FRAME MODEL CREATION USING CURVES, AND ANALYSIS WS3-1 WS3-2 Workshop Ojetives Moel simple frme struture using geometri urves n 1D Br elements. The frme moel is to e onstrine using pin restrints,
More informationAdvanced 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 informationCOSC 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 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 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 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 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 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 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 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 informationMITSUBISHI ELECTRIC RESEARCH LABORATORIES Cambridge, Massachusetts. Introduction to Matroids and Applications. Srikumar Ramalingam
Cmrige, Msshusetts Introution to Mtrois n Applitions Srikumr Rmlingm MERL mm//yy Liner Alger (,0,0) (0,,0) Liner inepenene in vetors: v, v2,..., For ll non-trivil we hve s v s v n s, s2,..., s n 2v2...
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 informationComparing Hierarchical Data in External Memory
Compring Hierrhil Dt in Externl Memory Surshn S. Chwthe Deprtment of Computer Siene University of Mryln College Prk, MD 090 hw@s.um.eu Astrt We present n externl-memory lgorithm for omputing minimum-ost
More informationRolling Back Remote Provisioning Changes. Dell Command Integration for System Center
Rolling Bk Remote Provisioning Chnges Dell Commn Integrtion for System Center Notes, utions, n wrnings NOTE: A NOTE inites importnt informtion tht helps you mke etter use of your prout. CAUTION: A CAUTION
More informationTable-driven look-ahead lexical analysis
Tle-riven look-he lexil nlysis WUU YANG Computer n Informtion Siene Deprtment Ntionl Chio-Tung University, HsinChu, Tiwn, R.O.C. Astrt. Moern progrmming lnguges use regulr expressions to efine vli tokens.
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 informationChapter 4 Fuzzy Graph and Relation
Chpter 4 Fuzzy Grph nd Reltion Grph nd Fuzzy Grph! Grph n G = (V, E) n V : Set of verties(node or element) n E : Set of edges An edge is pir (x, y) of verties in V.! Fuzzy Grph ~ n ( ~ G = V, E) n V :
More informationDistributed 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 informationUT1553B BCRT True Dual-port Memory Interface
UTMC APPICATION NOTE UT553B BCRT True Dul-port Memory Interfce INTRODUCTION The UTMC UT553B BCRT is monolithic CMOS integrted circuit tht provides comprehensive MI-STD- 553B Bus Controller nd Remote Terminl
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 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.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 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 informationProduct of polynomials. Introduction to Programming (in C++) Numerical algorithms. Product of polynomials. Product of polynomials
Product of polynomils Introduction to Progrmming (in C++) Numericl lgorithms Jordi Cortdell, Ricrd Gvldà, Fernndo Orejs Dept. of Computer Science, UPC Given two polynomils on one vrile nd rel coefficients,
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 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 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 informationDuality 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 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 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 informationAbstract Data Types 1
Abstract Data Types 1 Purpose Abstract Data Types (ADTs) Lists Stacks Queues 2 Abstract Data Types (ADTs) ADT is a set of objects together with a set of operations. Abstract in that implementation of operations
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 informationTopological Sort. CSE 373 Data Structures Lecture 19
Topological Sort S 373 ata Structures Lecture 19 Readings and References Reading Section 9.2 Some slides based on: S 326 by S. Wolfman, 2000 11/27/02 Topological Sort - Lecture 19 2 Topological Sort 142
More informationITEC2620 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 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 informationWORKSHOP 8A TENSION COUPON
WORKSHOP 8A TENSION COUPON WS8A-2 Workshop Ojetives Buil the tension oupon geometry Control the mesh y using tehniques isusse in lss Compre FEA stress results to theoretil results From Stress Conentrtion
More informationAbstract Data Types. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University
Abstract Data Types CptS 223 Advanced Data Structures Larry Holder School of Electrical Engineering and Computer Science Washington State University 1 Purpose Abstract Data Types (ADTs) Lists Stacks Queues
More informationOutline. CS38 Introduction to Algorithms. Graphs. Graphs. Graphs. Graph traversals
Outline CS38 Introution to Algorithms Leture 2 April 3, 2014 grph trversls (BFS, DFS) onnetivity topologil sort strongly onnete omponents heps n hepsort greey lgorithms April 3, 2014 CS38 Leture 2 2 Grphs
More informationWORKSHOP 9 HEX MESH USING SWEEP VECTOR
WORKSHOP 9 HEX MESH USING SWEEP VECTOR WS9-1 WS9-2 Prolem Desription This exerise involves importing urve geometry from n IGES file. The urves re use to rete other urves. From the urves trimme surfes re
More informationAbstract Data Types 1
Abstract Data Types 1 Purpose Abstract Data Types (ADTs) Lists Stacks Queues 2 Primitive vs. Abstract Data Types Primitive DT: programmer ADT: programmer Interface (API) data Implementation (methods) Data
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 informationWORKSHOP 2 CANTILEVERED PLATE
WORKSHOP 2 CANTILEVERED PLATE WS2-1 WS2-2 Prolem Desription This is simple exerise tht involves the simultion of the eformtion of ntilevere plte ue to the pplition of n en lo. The exerise involves 1) retion
More informationLINX 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 informationFrom Dependencies to Evaluation Strategies
From Dependencies to Evlution Strtegies Possile strtegies: 1 let the user define the evlution order 2 utomtic strtegy sed on the dependencies: use locl dependencies to determine which ttriutes to compute
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 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 informationUsing SIMD Registers and Instructions to Enable Instruction-Level Parallelism in Sorting Algorithms
Using SIMD Registers n Instrutions to Enle Instrution-Level Prllelism in Sorting Algorithms Timothy Furtk furtk@s.ulert. José Nelson Amrl mrl@s.ulert. Roert Niewiomski niewio@s.ulert. Deprtment of Computing
More informationWORKSHOP 6 FRAME SURFACE MODEL ANALYSIS
WORKSHOP 6 FRAME SURFACE MODEL ANALYSIS WS6-1 WS6-2 Workshop Ojetives Crete finite element moel (meshes; onnet jent elements; pply e los, operting los, n grvity los; onstrin noes) for intermeitely iffiult
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 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 informationIntroduction. Example
OMS0 Introution isjoint sets n minimum spnning trees In this leture we will strt by isussing t struture use for mintining isjoint subsets of some bigger set. This hs number of pplitions, inluing to mintining
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 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 informationCS 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 informationMath 227 Problem Set V Solutions. f ds =
Mth 7 Problem Set V Solutions If is urve with prmetriztion r(t), t b, then we define the line integrl f ds b f ( r(t) ) dr dt (t) dt. Evlute the line integrl f(x,y,z)ds for () f(x,y,z) xosz, the urve with
More informationDiscussion 1 Recap. COP4600 Discussion 2 OS concepts, System call, and Assignment 1. Questions. Questions. Outline. Outline 10/24/2010
COP4600 Discussion 2 OS concepts, System cll, nd Assignment 1 TA: Hufeng Jin hj0@cise.ufl.edu Discussion 1 Recp Introduction to C C Bsic Types (chr, int, long, flot, doule, ) C Preprocessors (#include,
More informationThe 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 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 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 informationUnion-Find Problem. Using Arrays And Chains. A Set As A Tree. Result Of A Find Operation
Union-Find Problem Given set {,,, n} of n elements. Initilly ech element is in different set. ƒ {}, {},, {n} An intermixed sequence of union nd find opertions is performed. A union opertion combines two
More informationCSc 453 Compilers and Systems Software. 6 : Top-Down Parsing I
C 45 Compilers n ystems oftwre 6 : op-down Prsing I Christin Collberg Deprtment of Computer iene University of rizon ollberg@gmil.om Copyright 2009 Christin Collberg eptember 14, 2009 1 Overview 2 Compiler
More informationGraph Contraction and Connectivity
Chpter 14 Grph Contrtion n Connetivity So fr we hve mostly overe tehniques for solving problems on grphs tht were evelope in the ontext of sequentil lgorithms. Some of them re esy to prllelize while others
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 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 informationSolving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence Winter 2016
Solving Prolems y Serching CS 486/686: Introduction to Artificil Intelligence Winter 2016 1 Introduction Serch ws one of the first topics studied in AI - Newell nd Simon (1961) Generl Prolem Solver Centrl
More informationQueues. A queue is a special type of structure that can be used to maintain data in an organized way.
A queue is a special type of structure that can be used to maintain data in an organized way. This data structure is commonly implemented in one of two ways: as an array or as a linked list. In either
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 information[Prakash* et al., 5(8): August, 2016] ISSN: IC Value: 3.00 Impact Factor: 4.116
[Prksh* et l 58: ugust 6] ISSN: 77-9655 I Vlue: Impt Ftor: 6 IJESRT INTERNTIONL JOURNL OF ENGINEERING SIENES & RESERH TEHNOLOGY SOME PROPERTIES ND THEOREM ON FUZZY SU-TRIDENT DISTNE Prveen Prksh* M Geeth
More informationSystems I. Logic Design I. Topics Digital logic Logic gates Simple combinational logic circuits
Systems I Logic Design I Topics Digitl logic Logic gtes Simple comintionl logic circuits Simple C sttement.. C = + ; Wht pieces of hrdwre do you think you might need? Storge - for vlues,, C Computtion
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 informationInternet Routing. Reminder: Routing. CPSC Network Programming
PS 360 - Network Progrmming Internet Routing Mihele Weigle eprtment of omputer Siene lemson University mweigle@s.lemson.eu pril, 00 http://www.s.lemson.eu/~mweigle/ourses/ps360 Reminer: Routing Internet
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 informationWidth 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 informationRegister Allocation III. Interference Graph Allocators. Computing the Interference Graph (in MiniJava compiler)
Register Alloation III Announements Reommen have interferene graph onstrution working by Monay Last leture Register alloation aross funtion alls Toay Register alloation options Interferene Graph Alloators
More informationA dual of the rectangle-segmentation problem for binary matrices
A dul of the rectngle-segmenttion prolem for inry mtrices Thoms Klinowski Astrct We consider the prolem to decompose inry mtrix into smll numer of inry mtrices whose -entries form rectngle. We show tht
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 informationWORKSHOP 8B TENSION COUPON
WORKSHOP 8B TENSION COUPON WS8B-2 Workshop Ojetives Prtie reting n eiting geometry Prtie mesh seeing n iso meshing tehniques. WS8B-3 Suggeste Exerise Steps 1. Crete new tse. 2. Crete geometry moel of the
More information1.5 Extrema and the Mean Value Theorem
.5 Extrem nd the Men Vlue Theorem.5. Mximum nd Minimum Vlues Definition.5. (Glol Mximum). Let f : D! R e function with domin D. Then f hs n glol mximum vlue t point c, iff(c) f(x) for ll x D. The vlue
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 informationShared 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 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 informationLists in Lisp and Scheme
Lists in Lisp nd Scheme Lists in Lisp nd Scheme Lists re Lisp s fundmentl dt structures, ut there re others Arrys, chrcters, strings, etc. Common Lisp hs moved on from eing merely LISt Processor However,
More informationCS 241. Fall 2017 Midterm Review Solutions. October 24, Bits and Bytes 1. 3 MIPS Assembler 6. 4 Regular Languages 7.
CS 241 Fll 2017 Midterm Review Solutions Octoer 24, 2017 Contents 1 Bits nd Bytes 1 2 MIPS Assemly Lnguge Progrmming 2 3 MIPS Assemler 6 4 Regulr Lnguges 7 5 Scnning 9 1 Bits nd Bytes 1. Give two s complement
More informationA 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 informationA decision support system prototype for fuzzy multiple objective optimization
EUSFLAT - LFA A eision support system prototype for fuzzy multiple ojetive optimiztion Fengjie Wu Jie Lu n Gungqun Zhng Fulty of Informtion Tehnology University of Tehnology Syney Austrli E-mil: {fengjiewjieluzhngg}@it.uts.eu.u
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 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 informationRegister Allocation III. Interference Graph Allocators. Coalescing. Granularity of Allocation (Renumber step in Briggs) Chaitin
Register Alloation III Last time Register alloation aross funtion alls Toay Register alloation options Interferene Graph Alloators Chaitin Briggs CS553 Leture Register Alloation III 1 CS553 Leture Register
More informationLecture 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 information1.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 informationLecture Overview. Knowledge-based systems in Bioinformatics, 1MB602. Procedural abstraction. The sum procedure. Integration as a procedure
Lecture Overview Knowledge-bsed systems in Bioinformtics, MB6 Scheme lecture Procedurl bstrction Higher order procedures Procedures s rguments Procedures s returned vlues Locl vribles Dt bstrction Compound
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 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 information