Computer Science 14. Introduction to Theoretical CS 14

Total Page:16

File Type:pdf, Size:1020Kb

Computer Science 14. Introduction to Theoretical CS 14 COMPUTER SCIENCE COMPUTER SCIENCE SEDGEWICK/WAYNE SEDGEWICK/WAYNE PART II: ALGORITHMS, MACHINES, and THEORY PART II: ALGORITHMS, MACHINES, and THEORY Computer Science 14. Introduction to Theoretical CS 14. Introduction to •Overview Computer •Regular expressions Science Theoretical CS •DFAs An Interdisciplinary Approach •Applications R O B E R T S E D G E W I C K Section 7.2 KEVIN WAYNE •Limitations http://introcs.cs.princeton.edu CS.17.A.Theory.Overview Introduction to theoretical computer science Why study theory? Fundamental questions In theory... • What can a computer do? • Deeper understanding of computation. • What can a computer do with limited resources? • Foundation of all modern computers. • Pure science. • Philosophical implications. General approach • Don't talk about specific machines or problems. NO • Consider minimal abstract machines. YES In practice... • Consider general classes of problems. • Web search: theory of pattern matching. • Sequential circuits: theory of finite state automata. • Compilers: theory of context free grammars. • Cryptography: theory of computational complexity. " In theory there is no • Data compression: theory of information. difference • ... between theory and Surprising outcome. Sweeping and relevant statements about all computers. — Yogi Berra 3 4 Abstract machines COMPUTER SCIENCE SEDGEWICK/WAYNE PART I: PROGRAMMING IN JAVA Abstract machine • Mathematical model of computation. • Each machine defined by specific rules for transforming input to output. • This lecture: Deterministic finite automata (DFAs). Formal language madam im adam a man a plan a canal panama • A set of strings. able i was ere i saw elba evil olive • Each defined by specific rules that characterize it. go hang a salami im a lasagna hog pull up if i pull up • This lecture: Regular expressions (REs). ... Questions for this lecture • Is a given string in the language defined by a given RE, or not? • Can a DFA help answer this question? 5 CS.17.A.Theory.Overview COMPUTER SCIENCE Pattern matching SEDGEWICK/WAYNE PART II: ALGORITHMS, MACHINES, and THEORY Pattern matching problem. Is a given string an element of a given set of strings? Example 1 (from computational biochemistry) An amino acid is represented by one of the characters CAVLIMCRKHDENQSTYFWP. 14. Introduction to TheoreticaalTheoretical CS CS A protein is a string of amino acids. A C2H2-type zinc finger domain signature is •Overview • C followed by 2, 3, or 4 amino acids, followed by •Regular expressions • C followed by 3 amino acids, followed by •DFAs • L, I, V, M, F, Y, W, C, or X followed by 8 amino acids, followed by • H followed by 3, 4, or 5 amino acids, followed by H. •Applications •Limitations Q. Is this protein in the C2H2-type zinc finger domain? CAASCGGPYACGGWAGYHAGWH A. Yes. C H CS.14.B.Theory.REs 3 C 3 Y 8 H 3 8 Pattern matching Pattern matching Example 2 (from commercial computing) Example 3 (from genomics) An e-mail address is • A sequence of letters, followed by A nucleic acid is represented by one of the letters a, c, t, or g. • the character "@", followed by • followed by a nonempty sequence of lowercase letters, followed by the character "." A genome is a string of nucleic acids. • [any number of occurrences of the previous pattern] A Fragile X Syndrome pattern is a genome having an occurrence of gcg, followed • "edu" or "com" (others omitted for brevity). by any number of cgg or agg triplets, followed by ctg. Q. Which of the following are e-mail addresses? A. Note. The number of triplets correlates with Fragile X Syndrome, a common cause of mental retardation. [email protected] ✓ not an e-mail address ✗ Q. Does this genome contain a such a pattern? [email protected] ✓ gcggcgtgtgtgcgagagagtgggtttaaagctggcgcggaggcggctggcgcggaggctg eve@airport ✗ A. Yes. gcgcggaggcggctg Oops, need to fix description [email protected] ✗ gcg start mark ctg end mark Challenge. Develop a precise description of the set of strings that are legal e-mail addresses. sequence of cgg and agg 9 triplets 10 Regular expressions More examples of regular expressions A regular expression (RE) is a notation for specifying a set of strings ( a formal language). The notation is surprisingly expressive. regular expression matches does not match matches does not match operation example RE (IN the set) (NOT in the set) An RE is either .*spb.* raspberry subspace • The empty set concatenation aabaab aabaab every other string contains the trigraph spb crispbread subspecies The empty string • cumulus succubus wildcard .u.u.u. bbb b • A single character or wildcard symbol jugulum tumultuous a* | (a*ba*ba*ba*)* aa aaa bb • An RE enclosed in parentheses union aa | baab every other string multiple of three b’s baab bbbaababbaa baabbbaa The concatenation of two or more REs • aa ab closure ab*a • The union of two or more REs abbba ababa .*0.... 1000234 111111111 aaaab 98701234 403982772 • The closure of an RE a(a|b)aab every other string fifth to last digit is 0 abaab (any number of occurrences) parentheses a aa (ab)*a ...gcgctg... gcgcgg ababababa abbba .*gcg(cgg|agg)*ctg.* ...gcgcggctg... cggcggcggctg fragile X syndrome pattern ...gcgcggaggctg... gcgcaggctg 11 12 Generalized regular expressions Example of describing a pattern with a generalized RE Additional operations further extend the utility of REs. A C2H2-type zinc finger domain signature is operation example RE matches does not match • C followed by 2, 3, or 4 amino acids, followed by abcde ade C followed by 3 amino acids, followed by one or more a(bc)+de • bcde abcbcde • L, I, V, M, F, Y, W, C, or X followed by 8 amino acids, followed lowercase camelCase character class [A-Za-z][a-z]* by Capitalized 4illegal • H followed by 3, 4, or 5 amino acids, followed by 08540-1321 111111111 exactly j [0-9]{5}-[0-9]{4} 19072-5541 166-54-1111 abcb ab between j and k a.{2,4}b abcbcb aaaaaab Q. Give a generalized RE for all such signatures. negation [^aeiou]{6} rhythm decade A. C.{2,4}C...[LIVMFYWCX].{8}H.{3,5}H CAASCGGPYACGGWAGYHAGWH any whitespace char whitespace \s every other character (space, tab, newline...) "Wildcard" matches any of the letters C 3 C 3 Y 8 H 3 H CAVLIMCRKHDENQSTYFWP Note. These operations are all shorthand. RE: (a|b|c|d|e)(a|b|c|d|e)* They are very useful but not essential. shorthand: (a-e)+ 13 14 Example of a real-world RE application: PROSITE Another example of describing a pattern with a generalized RE An e-mail address is • A sequence of letters, followed by • the character "@", followed by • the character "." , followed by a nonempty sequence of lowercase letters, followed by • [any number of occurrences of the previous pattern] • "edu" or "com" (others omitted for brevity). Q. Give a generalized RE for e-mail addresses. A. [a-z]+@([a-z]+\.)+(edu|com) Type an RE here Exercise. Extend to handle [email protected], more suffixes such as .org, and any other extensions you can think of. Next. Determining whether a given string matches a given RE. 15 16 Pop quiz 1 on REs Pop quiz 2 on REs Q. Which of the following strings match the RE a*bb(ab|ba)* ? Q. Give an RE for genes • Characters are a, c, t or g. is in the set it describes • Starts with atg (a start codon). • Length is a multiple of 3. • Ends with tag, taa, or ttg (a stop codon). 1. abb 2. aaba 3. abba 4. bbbaab 5. cbb 6. bbababbab 17 18 COMPUTER SCIENCE COMPUTER SCIENCE SEDGEWICK/WAYNE SEDGEWICK/WAYNE PART I: PROGRAMMING IN JAVA PART II: ALGORITHMS, MACHINES, and THEORY Image sources http://en.wikipedia.org/wiki/Homology_modeling#/media/File:DHRS7B_homology_model.png 14. Introduction to TheoreticaalTheoretical CS CS •Overview •Regular expressions •DFAs •Applications •Limitations CS.14.B.Theory.REs CS.14.C.Theory.DFAs Deterministic finite automata (DFA) Deterministic finite automata details and example A DFA is an abstract machine that solves a pattern matching problem. AA DFADFA isis anan abstractabstract machinemachine withwith aa finitefinite numbernumber states,states, eacheach labeledlabeled YY oror N,N, andand • A string is specified on an input tape (no limit on its length). transitionstransitions betweenbetween states,states, eacheach labeledlabeled withwith aa symbol.symbol. OneOne statestate isis thethe startstart state.state. • The DFA reads each character on input tape once, moving left to right. • •BeginBegin in in the the start start state. state (denoted by an arrow from nowhere). • The DFA lights "YES" if it recognizes the string, "NO" otherwise. • •ReadRead an an input input symbol symbol and and move move to to the the indicated indicated state. state. Each DFA defines a language (the set of strings that it recognizes). • •RepeatRepeat until until the the last last input input symbol symbol has has been been read. read. • •TurnTurn on on the the "YES" "YES" or or "NO" "NO" light light according according to to the the label label on on the the current current state. state. NO NO a a a Does this DFA recognize Y b N b N this string? b YES YES b b a a b b a b b b b a a b b a b b 21 22 Deterministic finite automata details and example Simulating the operation of a DFA public class DFA a 0 a 1 a 2 A DFA is an abstract machine with a finite number states, each labeled Y or N, and symbol table to map { chars a, b, ... to next Y b N b N private int start; transitions between states, each labeled with a symbol. One state is the start state. state 0, 1, ... b private boolean[] action; action[] next[] • Begin in the start state. private ST<Character, Integer>[] next; a b • Read an input symbol and move to the indicated state.
Recommended publications
  • Metaobject Protocols: Why We Want Them and What Else They Can Do
    Metaobject protocols: Why we want them and what else they can do Gregor Kiczales, J.Michael Ashley, Luis Rodriguez, Amin Vahdat, and Daniel G. Bobrow Published in A. Paepcke, editor, Object-Oriented Programming: The CLOS Perspective, pages 101 ¾ 118. The MIT Press, Cambridge, MA, 1993. © Massachusetts Institute of Technology All rights reserved. No part of this book may be reproduced in any form by any electronic or mechanical means (including photocopying, recording, or information storage and retrieval) without permission in writing from the publisher. Metaob ject Proto cols WhyWeWant Them and What Else They Can Do App ears in Object OrientedProgramming: The CLOS Perspective c Copyright 1993 MIT Press Gregor Kiczales, J. Michael Ashley, Luis Ro driguez, Amin Vahdat and Daniel G. Bobrow Original ly conceivedasaneat idea that could help solve problems in the design and implementation of CLOS, the metaobject protocol framework now appears to have applicability to a wide range of problems that come up in high-level languages. This chapter sketches this wider potential, by drawing an analogy to ordinary language design, by presenting some early design principles, and by presenting an overview of three new metaobject protcols we have designed that, respectively, control the semantics of Scheme, the compilation of Scheme, and the static paral lelization of Scheme programs. Intro duction The CLOS Metaob ject Proto col MOP was motivated by the tension b etween, what at the time, seemed liketwo con icting desires. The rst was to have a relatively small but p owerful language for doing ob ject-oriented programming in Lisp. The second was to satisfy what seemed to b e a large numb er of user demands, including: compatibility with previous languages, p erformance compara- ble to or b etter than previous implementations and extensibility to allow further exp erimentation with ob ject-oriented concepts see Chapter 2 for examples of directions in which ob ject-oriented techniques might b e pushed.
    [Show full text]
  • 250P: Computer Systems Architecture Lecture 10: Caches
    250P: Computer Systems Architecture Lecture 10: Caches Anton Burtsev April, 2021 The Cache Hierarchy Core L1 L2 L3 Off-chip memory 2 Accessing the Cache Byte address 101000 Offset 8-byte words 8 words: 3 index bits Direct-mapped cache: each address maps to a unique address Sets Data array 3 The Tag Array Byte address 101000 Tag 8-byte words Compare Direct-mapped cache: each address maps to a unique address Tag array Data array 4 Increasing Line Size Byte address A large cache line size smaller tag array, fewer misses because of spatial locality 10100000 32-byte cache Tag Offset line size or block size Tag array Data array 5 Associativity Byte address Set associativity fewer conflicts; wasted power because multiple data and tags are read 10100000 Tag Way-1 Way-2 Tag array Data array Compare 6 Example • 32 KB 4-way set-associative data cache array with 32 byte line sizes • How many sets? • How many index bits, offset bits, tag bits? • How large is the tag array? 7 Types of Cache Misses • Compulsory misses: happens the first time a memory word is accessed – the misses for an infinite cache • Capacity misses: happens because the program touched many other words before re-touching the same word – the misses for a fully-associative cache • Conflict misses: happens because two words map to the same location in the cache – the misses generated while moving from a fully-associative to a direct-mapped cache • Sidenote: can a fully-associative cache have more misses than a direct-mapped cache of the same size? 8 Reducing Miss Rate • Large block
    [Show full text]
  • CS 61A Streams Summer 2019 1 Streams
    CS 61A Streams Summer 2019 Discussion 10: August 6, 2019 1 Streams In Python, we can use iterators to represent infinite sequences (for example, the generator for all natural numbers). However, Scheme does not support iterators. Let's see what happens when we try to use a Scheme list to represent an infinite sequence of natural numbers: scm> (define (naturals n) (cons n (naturals (+ n 1)))) naturals scm> (naturals 0) Error: maximum recursion depth exceeded Because cons is a regular procedure and both its operands must be evaluted before the pair is constructed, we cannot create an infinite sequence of integers using a Scheme list. Instead, our Scheme interpreter supports streams, which are lazy Scheme lists. The first element is represented explicitly, but the rest of the stream's elements are computed only when needed. Computing a value only when it's needed is also known as lazy evaluation. scm> (define (naturals n) (cons-stream n (naturals (+ n 1)))) naturals scm> (define nat (naturals 0)) nat scm> (car nat) 0 scm> (cdr nat) #[promise (not forced)] scm> (car (cdr-stream nat)) 1 scm> (car (cdr-stream (cdr-stream nat))) 2 We use the special form cons-stream to create a stream: (cons-stream <operand1> <operand2>) cons-stream is a special form because the second operand is not evaluated when evaluating the expression. To evaluate this expression, Scheme does the following: 1. Evaluate the first operand. 2. Construct a promise containing the second operand. 3. Return a pair containing the value of the first operand and the promise. 2 Streams To actually get the rest of the stream, we must call cdr-stream on it to force the promise to be evaluated.
    [Show full text]
  • Chapter 2 Basics of Scanning And
    Chapter 2 Basics of Scanning and Conventional Programming in Java In this chapter, we will introduce you to an initial set of Java features, the equivalent of which you should have seen in your CS-1 class; the separation of problem, representation, algorithm and program – four concepts you have probably seen in your CS-1 class; style rules with which you are probably familiar, and scanning - a general class of problems we see in both computer science and other fields. Each chapter is associated with an animating recorded PowerPoint presentation and a YouTube video created from the presentation. It is meant to be a transcript of the associated presentation that contains little graphics and thus can be read even on a small device. You should refer to the associated material if you feel the need for a different instruction medium. Also associated with each chapter is hyperlinked code examples presented here. References to previously presented code modules are links that can be traversed to remind you of the details. The resources for this chapter are: PowerPoint Presentation YouTube Video Code Examples Algorithms and Representation Four concepts we explicitly or implicitly encounter while programming are problems, representations, algorithms and programs. Programs, of course, are instructions executed by the computer. Problems are what we try to solve when we write programs. Usually we do not go directly from problems to programs. Two intermediate steps are creating algorithms and identifying representations. Algorithms are sequences of steps to solve problems. So are programs. Thus, all programs are algorithms but the reverse is not true.
    [Show full text]
  • BALANCING the Eulisp METAOBJECT PROTOCOL
    LISP AND SYMBOLIC COMPUTATION An International Journal c Kluwer Academic Publishers Manufactured in The Netherlands Balancing the EuLisp Metaob ject Proto col y HARRY BRETTHAUER bretthauergmdde JURGEN KOPP koppgmdde German National Research Center for Computer Science GMD PO Box W Sankt Augustin FRG HARLEY DAVIS davisilogfr ILOG SA avenue Gal lieni Gentil ly France KEITH PLAYFORD kjpmathsbathacuk School of Mathematical Sciences University of Bath Bath BA AY UK Keywords Ob jectoriented Programming Language Design Abstract The challenge for the metaob ject proto col designer is to balance the con icting demands of eciency simplici ty and extensibil ity It is imp ossible to know all desired extensions in advance some of them will require greater functionality while oth ers require greater eciency In addition the proto col itself must b e suciently simple that it can b e fully do cumented and understo o d by those who need to use it This pap er presents the framework of a metaob ject proto col for EuLisp which provides expressiveness by a multileveled proto col and achieves eciency by static semantics for predened metaob jects and mo dularizin g their op erations The EuLisp mo dule system supp orts global optimizations of metaob ject applicati ons The metaob ject system itself is structured into mo dules taking into account the consequences for the compiler It provides introsp ective op erations as well as extension interfaces for various functionaliti es including new inheritance allo cation and slot access semantics While
    [Show full text]
  • Third Party Channels How to Set Them up – Pros and Cons
    Third Party Channels How to Set Them Up – Pros and Cons Steve Milo, Managing Director Vacation Rental Pros, Property Manager Cell: (904) 707.1487 [email protected] Company Summary • Business started in June, 2006 First employee hired in late 2007. • Today Manage 950 properties in North East Florida and South West Florida in resort ocean areas with mostly Saturday arrivals and/or Saturday departures and minimum stays (not urban). • Hub and Spoke Model. Central office is in Ponte Vedra Beach (Accounting, Sales & Marketing). Operations office in St Augustine Beach, Ft. Myers Beach and Orlando (model home). Total company wide - 69 employees (61 full time, 8 part time) • Acquired 3 companies in 2014. The PROS of AirBNB Free to list your properties. 3% fee per booking (they pay cc fee) Customer base is different & sticky – young, urban & foreign. Smaller properties book better than larger properties. Good generator of off-season bookings. Does not require Rate Parity. Can add fees to the rent. All bookings are direct online (no phone calls). You get to review the guest who stayed in your property. The Cons of AirBNB Labor intensive. Time consuming admin. 24 hour response. Not designed for larger property managers. Content & Prices are static (only calendar has data feed). Closed Communication (only through Airbnb). Customers want more hand holding, concierge type service. “Rate Terms” not easy. Only one minimum stay, No minimum age ability. No easy way to add fees (pets, damage waiver, booking fee). Need to add fees into nightly rates. Why Booking.com? Why not Booking.com? Owned by Priceline.
    [Show full text]
  • Abstract Data Types
    Chapter 2 Abstract Data Types The second idea at the core of computer science, along with algorithms, is data. In a modern computer, data consists fundamentally of binary bits, but meaningful data is organized into primitive data types such as integer, real, and boolean and into more complex data structures such as arrays and binary trees. These data types and data structures always come along with associated operations that can be done on the data. For example, the 32-bit int data type is defined both by the fact that a value of type int consists of 32 binary bits but also by the fact that two int values can be added, subtracted, multiplied, compared, and so on. An array is defined both by the fact that it is a sequence of data items of the same basic type, but also by the fact that it is possible to directly access each of the positions in the list based on its numerical index. So the idea of a data type includes a specification of the possible values of that type together with the operations that can be performed on those values. An algorithm is an abstract idea, and a program is an implementation of an algorithm. Similarly, it is useful to be able to work with the abstract idea behind a data type or data structure, without getting bogged down in the implementation details. The abstraction in this case is called an \abstract data type." An abstract data type specifies the values of the type, but not how those values are represented as collections of bits, and it specifies operations on those values in terms of their inputs, outputs, and effects rather than as particular algorithms or program code.
    [Show full text]
  • File I/O Stream Byte Stream
    File I/O In Java, we can read data from files and also write data in files. We do this using streams. Java has many input and output streams that are used to read and write data. Same as a continuous flow of water is called water stream, in the same way input and output flow of data is called stream. Stream Java provides many input and output stream classes which are used to read and write. Streams are of two types. Byte Stream Character Stream Let's look at the two streams one by one. Byte Stream It is used in the input and output of byte. We do this with the help of different Byte stream classes. Two most commonly used Byte stream classes are FileInputStream and FileOutputStream. Some of the Byte stream classes are listed below. Byte Stream Description BufferedInputStream handles buffered input stream BufferedOutputStrea handles buffered output stream m FileInputStream used to read from a file FileOutputStream used to write to a file InputStream Abstract class that describe input stream OutputStream Abstract class that describe output stream Byte Stream Classes are in divided in two groups - InputStream Classes - These classes are subclasses of an abstract class, InputStream and they are used to read bytes from a source(file, memory or console). OutputStream Classes - These classes are subclasses of an abstract class, OutputStream and they are used to write bytes to a destination(file, memory or console). InputStream InputStream class is a base class of all the classes that are used to read bytes from a file, memory or console.
    [Show full text]
  • POINTER (IN C/C++) What Is a Pointer?
    POINTER (IN C/C++) What is a pointer? Variable in a program is something with a name, the value of which can vary. The way the compiler and linker handles this is that it assigns a specific block of memory within the computer to hold the value of that variable. • The left side is the value in memory. • The right side is the address of that memory Dereferencing: • int bar = *foo_ptr; • *foo_ptr = 42; // set foo to 42 which is also effect bar = 42 • To dereference ted, go to memory address of 1776, the value contain in that is 25 which is what we need. Differences between & and * & is the reference operator and can be read as "address of“ * is the dereference operator and can be read as "value pointed by" A variable referenced with & can be dereferenced with *. • Andy = 25; • Ted = &andy; All expressions below are true: • andy == 25 // true • &andy == 1776 // true • ted == 1776 // true • *ted == 25 // true How to declare pointer? • Type + “*” + name of variable. • Example: int * number; • char * c; • • number or c is a variable is called a pointer variable How to use pointer? • int foo; • int *foo_ptr = &foo; • foo_ptr is declared as a pointer to int. We have initialized it to point to foo. • foo occupies some memory. Its location in memory is called its address. &foo is the address of foo Assignment and pointer: • int *foo_pr = 5; // wrong • int foo = 5; • int *foo_pr = &foo; // correct way Change the pointer to the next memory block: • int foo = 5; • int *foo_pr = &foo; • foo_pr ++; Pointer arithmetics • char *mychar; // sizeof 1 byte • short *myshort; // sizeof 2 bytes • long *mylong; // sizeof 4 byts • mychar++; // increase by 1 byte • myshort++; // increase by 2 bytes • mylong++; // increase by 4 bytes Increase pointer is different from increase the dereference • *P++; // unary operation: go to the address of the pointer then increase its address and return a value • (*P)++; // get the value from the address of p then increase the value by 1 Arrays: • int array[] = {45,46,47}; • we can call the first element in the array by saying: *array or array[0].
    [Show full text]
  • Signedness-Agnostic Program Analysis: Precise Integer Bounds for Low-Level Code
    Signedness-Agnostic Program Analysis: Precise Integer Bounds for Low-Level Code Jorge A. Navas, Peter Schachte, Harald Søndergaard, and Peter J. Stuckey Department of Computing and Information Systems, The University of Melbourne, Victoria 3010, Australia Abstract. Many compilers target common back-ends, thereby avoid- ing the need to implement the same analyses for many different source languages. This has led to interest in static analysis of LLVM code. In LLVM (and similar languages) most signedness information associated with variables has been compiled away. Current analyses of LLVM code tend to assume that either all values are signed or all are unsigned (except where the code specifies the signedness). We show how program analysis can simultaneously consider each bit-string to be both signed and un- signed, thus improving precision, and we implement the idea for the spe- cific case of integer bounds analysis. Experimental evaluation shows that this provides higher precision at little extra cost. Our approach turns out to be beneficial even when all signedness information is available, such as when analysing C or Java code. 1 Introduction The “Low Level Virtual Machine” LLVM is rapidly gaining popularity as a target for compilers for a range of programming languages. As a result, the literature on static analysis of LLVM code is growing (for example, see [2, 7, 9, 11, 12]). LLVM IR (Intermediate Representation) carefully specifies the bit- width of all integer values, but in most cases does not specify whether values are signed or unsigned. This is because, for most operations, two’s complement arithmetic (treating the inputs as signed numbers) produces the same bit-vectors as unsigned arithmetic.
    [Show full text]
  • Parallel Optimization of the Set Data Structure
    Parallel optimization of the set data structure Gustav Karlsson Gustav Karlsson Spring 2015 Bachelor’s thesis, 15 hp Supervisor: Jerry Eriksson Examiner: Pedher Johansson Bachelor’s program in computer science, 180 hp Abstract The Set data structure is a powerful and popular programmer’s tool based on set theory. Bulk operations such as addAll provide a sim- ple way of working with big collections of elements but can severely limit the performance of a multi-processor system when invoked on big sets if performed sequentially. Parallel processing is a technique that can significantly shorten the ex- ecution time of otherwise sequentially executed tasks. In this thesis, a new type of set is proposed that uses multiple threads to employ parallel processing for bulk operations. A new set is designed based on a non-blocking hash table with a high level of concurrency. The parallelization of the set makes use of paral- lel Java 8 streams to allow for quick iteration of the source collection elements, resulting in a speedup in processing of bulk operations. Testing the parallel set shows a significant increase in execution speed on bulk operations when operating on more than 10000 elements. Acknowledgements I would like to thank my supervisor Jerry Eriksson at Umea˚ University for helping me keep this work on track. I would also like to thank Pedher Johansson at Umea˚ University for giving me some valuable assistance and feedback. Finally, thank you Judith for your support, patience, and for putting up with my ramblings and rants. Contents 1 Introduction
    [Show full text]
  • Metaclasses: Generative C++
    Metaclasses: Generative C++ Document Number: P0707 R3 Date: 2018-02-11 Reply-to: Herb Sutter ([email protected]) Audience: SG7, EWG Contents 1 Overview .............................................................................................................................................................2 2 Language: Metaclasses .......................................................................................................................................7 3 Library: Example metaclasses .......................................................................................................................... 18 4 Applying metaclasses: Qt moc and C++/WinRT .............................................................................................. 35 5 Alternatives for sourcedefinition transform syntax .................................................................................... 41 6 Alternatives for applying the transform .......................................................................................................... 43 7 FAQs ................................................................................................................................................................. 46 8 Revision history ............................................................................................................................................... 51 Major changes in R3: Switched to function-style declaration syntax per SG7 direction in Albuquerque (old: $class M new: constexpr void M(meta::type target,
    [Show full text]