Performance: It s harder than you d think to go fast

Size: px
Start display at page:

Download "Performance: It s harder than you d think to go fast"

Transcription

1

2 Performance: It s harder than you d think to go fast Dan S. Wallach and Mack Joyner, Rice University Copyright 2016 Dan Wallach, All Rights Reserved

3 Today s lecture Prime number generation Several different algorithms with different big-o performance Making things run in parallel Using Java8 streams to run things together The pesky real world There s no replacement for measurement

4 Prime numbers who cares? Definition: a prime number is only divisible by itself and 1 Exceptionally useful, particularly in cryptography Modular arithmetic is the basis for most modern cryptography Modular arithmetic requires prime numbers

5 Modular arithmetic Z p We re working in, the integers in [1, p) = 5 (mod 7) = 6 (mod 7) = 0 (mod 7) Forbidden! 2 3 = 6 (mod 7) 2 4 = 1 (mod 7) 6 6 = 1 (mod 7) Note: Z p is closed under multiplication but not addition.

6 Modular arithmetic Z p We re working in, the integers in [1, p) = 5 (mod 7) = 6 (mod 7) = 0 (mod 7) Forbidden! 2 3 = 6 (mod 7) 2 4 = 1 (mod 7) 6 6 = 1 (mod 7) If p wasn t prime, multiplication wouldn t be closed! Note: Z p is closed under multiplication but not addition.

7 Some numbers are generators In Z p, we define a generator g such that g 1,g 2,...,g p 1 covers all the elements in the group. Example, for p=7: g=2 is not a generator, but g=3 is.

8 Discrete logarithms In the regular integers, say I give a big number: q = and ask you to take log 5 q Logarithms, over huge integers, are tractable. But what about? No known efficient solution to the discrete log problem. Modern cryptography depends on this being hard to solve (for large p) Z p

9 Diffie-Hellman (1976) Alice : Bob : Public A!B B!A Alice Bob Eve : : : : : : random a 2 random b 2 Zp Zp generator g 2 g a g b Zp b a ab a b ab computes (g ) = g computes (g ) = g a b ab knows g, g, cannot compute g

10 Diffie-Hellman (1976) Alice : Bob : Public A!B B!A Alice Bob Eve : : : : : : random a 2 random b 2 Zp Zp generator g 2 g a g b Zp b a ab a b ab computes (g ) = g computes (g ) = g a b ab knows g, g, cannot compute g /03/02/technology/ cryptography-pioneers-to-winturing-award.html

11 DLog-based crypto, in practice p tends to be 2048 or 3072 bits Smaller values are too easy to break! Bigger messages? Build hybrids with classical cryptography. Want a smaller p that s still strong? Elliptic curve cryptography! Define multiplication over things that aren t integers. Want to learn more about all this? Olivier Pereira (UCL Belgium) will be teaching a crypto class this spring

12 Over the summer We suggested you implement a Sieve of Eratosthenes Classic, reasonably efficient method to generate lots of prime numbers This won t find 2048-bit prime numbers! But it s worth understanding.

13 Let s start with something simpler We can test a number n for primality: divide by numbers < sqrt(n) public static boolean isprime(int n) { if (n < 1) { return false; } else if (n == 1 n == 2) { return true; if ((n & 1) == 0) { return false; } int max = (int) ceil(sqrt(n)); for (int i = 3; i <= max; i += 2) { if (n % i == 0) { return false; return true;

14 Let s start with something simpler We can test a number n for primality: divide by numbers < sqrt(n) public static boolean isprime(int n) { if (n < 1) { return false; } else if (n == 1 n == 2) { return true; if ((n & 1) == 0) { return false; Special cases for 1 and 2. } int max = (int) ceil(sqrt(n)); for (int i = 3; i <= max; i += 2) { if (n % i == 0) { return false; return true;

15 Let s start with something simpler We can test a number n for primality: divide by numbers < sqrt(n) public static boolean isprime(int n) { if (n < 1) { return false; } else if (n == 1 n == 2) { return true; if ((n & 1) == 0) { return false; Is n even? Then it s not prime. } int max = (int) ceil(sqrt(n)); for (int i = 3; i <= max; i += 2) { if (n % i == 0) { return false; return true;

16 Let s start with something simpler We can test a number n for primality: divide by numbers < sqrt(n) public static boolean isprime(int n) { if (n < 1) { return false; } else if (n == 1 n == 2) { return true; if ((n & 1) == 0) { return false; } int max = (int) ceil(sqrt(n)); for (int i = 3; i <= max; i += 2) { if (n % i == 0) { return false; return true; Any composite n: must have a factor sqrt(n)

17 Let s start with something simpler We can test a number n for primality: divide by numbers < sqrt(n) public static boolean isprime(int n) { if (n < 1) { return false; } else if (n == 1 n == 2) { return true; if ((n & 1) == 0) { return false; } int max = (int) ceil(sqrt(n)); for (int i = 3; i <= max; i += 2) { if (n % i == 0) { return false; return true; If n is divisible by i (no remainder), then it s not prime.

18 Want all the prime numbers < n? Simple O(n sqrt n) algorithm: public static IList<Integer> primessimple(int maxprime) { if (maxprime < 2) { return List.of(1); // better than nothing, I suppose } return rangeint(1, maxprime).filter(primes::isprime); You can see this, and everything else in edu.rice.util.primes Eight versions there (one more written yesterday )

19 Can we do better? Let s take an outer product and find all the composite numbers < n Anything missing must be a prime! public static IList<Integer> primesfasterstillnolists(int maxprime) { if (maxprime < 2) return List.of(1); // better than nothing, I suppose int maxfactor = (int) ceil(sqrt(maxprime)); boolean[] notprimes = new boolean[maxprime + 1]; // start off false for (int i = 2; i <= maxfactor; i++) { for (int j = 2; j <= maxprime; j++) { int product = i * j; if (product > maxprime) { break; // breaks the j-loop, continues the i-loop notprimes[product] = true; return rangeint(2, maxprime).filter(i ->!notprimes[i]).add(1); } Runtime: O(n log n)

20 Can we do better? Let s take an outer product and find all the composite numbers < n Anything missing must be a prime! public static IList<Integer> primesfasterstillnolists(int maxprime) { if (maxprime < 2) return List.of(1); // better than nothing, I suppose int maxfactor = (int) ceil(sqrt(maxprime)); boolean[] notprimes = new boolean[maxprime + 1]; // start off false for (int i = 2; i <= maxfactor; i++) { for (int j = 2; j <= maxprime; j++) { int product = i * j; if (product > maxprime) { break; // breaks the j-loop, continues the i-loop notprimes[product] = true; return rangeint(2, maxprime).filter(i ->!notprimes[i]).add(1); } Array of boolean: where we track all the composites we ve found so far. Runtime: O(n log n)

21 Can we do better? Let s take an outer product and find all the composite numbers < n Anything missing must be a prime! public static IList<Integer> primesfasterstillnolists(int maxprime) { if (maxprime < 2) return List.of(1); // better than nothing, I suppose int maxfactor = (int) ceil(sqrt(maxprime)); boolean[] notprimes = new boolean[maxprime + 1]; // start off false for (int i = 2; i <= maxfactor; i++) { for (int j = 2; j <= maxprime; j++) { int product = i * j; if (product > maxprime) { break; // breaks the j-loop, continues the i-loop notprimes[product] = true; return rangeint(2, maxprime).filter(i ->!notprimes[i]).add(1); } Once the product is bigger than n, we can stop looking. (This is where the speedup comes from.) Runtime: O(n log n)

22 Can we do better? Let s take an outer product and find all the composite numbers < n Anything missing must be a prime! public static IList<Integer> primesfasterstillnolists(int maxprime) { if (maxprime < 2) return List.of(1); // better than nothing, I suppose int maxfactor = (int) ceil(sqrt(maxprime)); boolean[] notprimes = new boolean[maxprime + 1]; // start off false for (int i = 2; i <= maxfactor; i++) { for (int j = 2; j <= maxprime; j++) { int product = i * j; if (product > maxprime) { break; // breaks the j-loop, continues the i-loop notprimes[product] = true; return rangeint(2, maxprime).filter(i ->!notprimes[i]).add(1); } Anything we missed must be prime. Runtime: O(n log n)

23 But Eratosthenes is faster still! Eratosthenes: Incrementally find primes, knock out their multiples public static IList<Integer> primeseratosthenes(int maxprime) { if (maxprime < 2) { return List.of(1); // better than nothing, I suppose boolean[] notprime = new boolean[maxprime + 1]; // these start off initialized to false int maxfactor = (int) ceil(sqrt(maxprime)); // special case for 2, then standard case afterward for (int i = 4; i <= maxprime; i += 2) { notprime[i] = true; for (int i = 3; i <= maxfactor; i++) { if (!notprime[i]) { int skip = 2 * i; // optimization: odd + odd = even, so we can avoid half of the work for (int j = i * i; j <= maxprime; j += skip) { notprime[j] = true; return rangeint(1, maxprime).filter(i ->!notprime[i]); } Runtime: O(n log log n) (i.e., barely slower than linear time!)

24 But Eratosthenes is faster still! Eratosthenes: Incrementally find primes, knock out their multiples public static IList<Integer> primeseratosthenes(int maxprime) { if (maxprime < 2) { return List.of(1); // better than nothing, I suppose } boolean[] notprime = new boolean[maxprime + 1]; // these start off initialized to false int maxfactor = (int) ceil(sqrt(maxprime)); // special case for 2, then standard case afterward for (int i = 4; i <= maxprime; i += 2) { notprime[i] = true; for (int i = 3; i <= maxfactor; i++) { if (!notprime[i]) { int skip = 2 * i; // optimization: odd + odd = even, so we can avoid half of the work for (int j = i * i; j <= maxprime; j += skip) { notprime[j] = true; return rangeint(1, maxprime).filter(i ->!notprime[i]); Array of boolean: where we track all the composites we ve found so far. Runtime: O(n log log n) (i.e., barely slower than linear time!)

25 But Eratosthenes is faster still! Eratosthenes: Incrementally find primes, knock out their multiples public static IList<Integer> primeseratosthenes(int maxprime) { if (maxprime < 2) { return List.of(1); // better than nothing, I suppose boolean[] notprime = new boolean[maxprime + 1]; // these start off initialized to false int maxfactor = (int) ceil(sqrt(maxprime)); // special case for 2, then standard case afterward for (int i = 4; i <= maxprime; i += 2) { notprime[i] = true; } for (int i = 3; i <= maxfactor; i++) { if (!notprime[i]) { int skip = 2 * i; // optimization: odd + odd = even, so we can avoid half of the work for (int j = i * i; j <= maxprime; j += skip) { notprime[j] = true; return rangeint(1, maxprime).filter(i ->!notprime[i]); Runtime: O(n log log n) (i.e., barely slower than linear time!) Any composite n: must have a factor sqrt(n)

26 But Eratosthenes is faster still! Eratosthenes: Incrementally find primes, knock out their multiples public static IList<Integer> primeseratosthenes(int maxprime) { if (maxprime < 2) { return List.of(1); // better than nothing, I suppose boolean[] notprime = new boolean[maxprime + 1]; // these start off initialized to false int maxfactor = (int) ceil(sqrt(maxprime)); // special case for 2, then standard case afterward for (int i = 4; i <= maxprime; i += 2) { notprime[i] = true; for (int i = 3; i <= maxfactor; i++) { if (!notprime[i]) { int skip = 2 * i; // optimization: odd + odd = even, so we can avoid half of the work for (int j = i * i; j <= maxprime; j += skip) { } notprime[j] = true; return rangeint(1, maxprime).filter(i ->!notprime[i]); Runtime: O(n log log n) (i.e., barely slower than linear time!) i is prime, its multiples are not.

27 But Eratosthenes is faster still! Eratosthenes: Incrementally find primes, knock out their multiples public static IList<Integer> primeseratosthenes(int maxprime) { if (maxprime < 2) { return List.of(1); // better than nothing, I suppose boolean[] notprime = new boolean[maxprime + 1]; // these start off initialized to false int maxfactor = (int) ceil(sqrt(maxprime)); // special case for 2, then standard case afterward for (int i = 4; i <= maxprime; i += 2) { notprime[i] = true; for (int i = 3; i <= maxfactor; i++) { if (!notprime[i]) { int skip = 2 * i; // optimization: odd + odd = even, so we can avoid half of the work for (int j = i * i; j <= maxprime; j += skip) { notprime[j] = true; } return rangeint(1, maxprime).filter(i ->!notprime[i]); Anything we missed must be prime. Runtime: O(n log log n) (i.e., barely slower than linear time!)

28 Runtime performance? 1000 O(n sqrt n) O(n log n) O(n log log n) Nanoseconds per prime E+02 1.E+03 1.E+04 1.E+05 1.E+06 1.E+07 Problem size (maximum prime)

29 Runtime performance? 1000 O(n sqrt n) O(n log n) As n grows, it looks like we re amortizing some one-time startup costs. O(n log log n) Nanoseconds per prime E+02 1.E+03 1.E+04 1.E+05 1.E+06 1.E+07 Problem size (maximum prime)

30 Runtime performance? 1000 O(n sqrt n) O(n log n) O(n log log n) Nanoseconds per prime 100 Straight lines on log-log graphs imply monomial functions (y = ax k ), so you re looking at sqrt(n) dominating for large n E+02 1.E+03 1.E+04 1.E+05 1.E+06 1.E+07 Problem size (maximum prime)

31 Runtime performance? 1000 O(n sqrt n) O(n log n) O(n log log n) Nanoseconds per prime 100 Eratosthenes for the win! 10 1.E+02 1.E+03 1.E+04 1.E+05 1.E+06 1.E+07 Problem size (maximum prime)

32 Big-O vs. real-world performance When n is small, big-o performance is meaningless Code clarity, debugging, features, modularity, etc. is more important! When n is massive, big-o eventually dominates But big-o misses a lot of how modern computers work Should you worry about constant factors? Do you really need to understand the CPU memory hierarchy? Do you really need to understand the garbage collector? Do you really need to understand how to write parallel code?

33 Java Streams: an easy way to write parallel code

34 Java8 streams Here s our O(n sqrt n) prime number tester with streams: public static IList<Integer> primessimpleparallel(int maxprime) { if (maxprime < 2) { return List.of(1); // better than nothing, I suppose return Adapters.streamToList( IntStream.rangeClosed(2, maxprime).parallel().filter(primes::isprime).boxed()) // boxed() to get from IntStream to Stream.add(1); }

35 Java8 streams Here s our O(n sqrt n) prime number tester with streams: public static IList<Integer> primessimpleparallel(int maxprime) { } if (maxprime < 2) { return List.of(1); // better than nothing, I suppose return Adapters.streamToList( IntStream.rangeClosed(2, maxprime).add(1);.parallel().filter(primes::isprime).boxed()) // boxed() to get from IntStream to Stream Make a stream of integers (like our LazyList.rangeInt)

36 Java8 streams Here s our O(n sqrt n) prime number tester with streams: public static IList<Integer> primessimpleparallel(int maxprime) { } if (maxprime < 2) { return List.of(1); // better than nothing, I suppose return Adapters.streamToList( IntStream.rangeClosed(2, maxprime).add(1);.parallel().filter(primes::isprime).boxed()) // boxed() to get from IntStream to Stream Make it parallel! The filter will run on every core of your computer simultaneously.

37 Java8 streams Here s our O(n sqrt n) prime number tester with streams: public static IList<Integer> primessimpleparallel(int maxprime) { } if (maxprime < 2) { return List.of(1); // better than nothing, I suppose return Adapters.streamToList( IntStream.rangeClosed(2, maxprime).add(1);.parallel().filter(primes::isprime).boxed()) // boxed() to get from IntStream to Stream Convert back to an IList (edu.rice.stream.adapters)

38 Prof. Wallach s 6-core desktop

39 Performance results O(n sqrt n) O(n sqrt n) PARALLEL 1000 O(n log n) O(n log log n) Nanoseconds per prime E+02 1.E+03 1.E+04 1.E+05 1.E+06 1.E+07 Problem size (maximum prime)

40 Performance results O(n sqrt n) O(n sqrt n) PARALLEL 1000 O(n log n) O(n log log n) Nanoseconds per prime 100 For small problem sizes, initial overhead is pretty large. (But should we care?) E+02 1.E+03 1.E+04 1.E+05 1.E+06 1.E+07 Problem size (maximum prime)

41 Performance results O(n sqrt n) O(n sqrt n) PARALLEL 1000 O(n log n) O(n log log n) Nanoseconds per prime 100 Parallelism (as much as 12x on a 6-core MacPro) can be a huge winner E+02 1.E+03 1.E+04 1.E+05 1.E+06 1.E+07 Problem size (maximum prime)

42 Performance results O(n sqrt n) O(n sqrt n) PARALLEL 1000 O(n log n) O(n log log n) Nanoseconds per prime Big-O still wins out in the end! 1 1.E+02 1.E+03 1.E+04 1.E+05 1.E+06 1.E+07 Problem size (maximum prime)

43 Four O(n log n) implementations 1000 Nanoseconds per prime 100 O(n log n) O(n log n) PARALLEL O(n log n) NO LISTS O(n log n) PARA NOLST 10 1.E+02 1.E+03 1.E+04 1.E+05 1.E+06 1.E+07 Problem size (maximum prime)

44 Four O(n log n) implementations 1000 n log n (LazyList) n log n (parallel stream) Parallelism helps a lot, but you may still be able to do a lot better. Nanoseconds per prime 100 O(n log n) O(n log n) PARALLEL O(n log n) NO LISTS O(n log n) PARA NOLST 10 1.E+02 1.E+03 1.E+04 1.E+05 1.E+06 1.E+07 Problem size (maximum prime)

45 Four O(n log n) implementations 1000 Nanoseconds per prime 100 n log n (array of boolean) O(n log n) n log n (array of boolean + parallel) O(n log n) PARALLEL O(n log n) NO LISTS O(n log n) PARA NOLST 10 1.E+02 1.E+03 1.E+04 1.E+05 1.E+06 1.E+07 Problem size (maximum prime) Parallel version only wins on huge problem sizes. (Hmmm.)

46 Parallelism is tricky O(n sqrt n) implementations: each number tested independently Embarrassingly parallel: no shared data, just filter a range Easy to scale, run on many cores Functional programming high performance! O(n log n) implementations: shared array of booleans Memory contention: the cores have to fight with each other for writes Speedup is limited when the problem cannot be partitioned

47 Nine different implementations! O(n^2 log n) O(n log^2 n) O(n log n) O(n log n) PARALLEL O(n log n) NO LISTS Nanoseconds per prime O(n log n) PARA NOLST O(n sqrt n) O(n sqrt n) PARALLEL O(n log log n) E+02 1.E+03 1.E+04 1.E+05 1.E+06 1.E+07 Problem size (max prime)

48 Nine different implementations! O(n^2 log n) O(n log^2 n) O(n log n) O(n log n) PARALLEL Really bad algorithms never win O(n log n) NO LISTS Nanoseconds per prime O(n log n) PARA NOLST O(n sqrt n) O(n sqrt n) PARALLEL O(n log log n) E+02 1.E+03 1.E+04 1.E+05 1.E+06 1.E+07 Problem size (max prime)

49 Nine different implementations! O(n^2 log n) O(n log^2 n) O(n log n) O(n log n) PARALLEL O(n log n) NO LISTS O(n log n) PARA NOLST O(n sqrt n) O(n sqrt n) PARALLEL Nanoseconds per prime O(n log log n) Eratosthenes squeaks a win for large n E+02 1.E+03 1.E+04 1.E+05 1.E+06 1.E+07 Problem size (max prime)

50 Nine different implementations! O(n^2 log n) O(n log^2 n) O(n log n) O(n log n) PARALLEL O(n log n) NO LISTS Nanoseconds per prime O(n log n) PARA NOLST O(n sqrt n) O(n sqrt n) PARALLEL O(n log log n) 10 O(n sqrt n) was the simplest possible implementation, and easily parallelized. 1 1.E+02 1.E+03 1.E+04 1.E+05 1.E+06 1.E+07 Problem size (max prime)

51 Digression: measuring performance These tests report fastest of ten runs Smooth out your computer s transient behaviors. Garbage collector JIT compiler Unrelated tasks on the same computer Better to take the mean? Median? Nanosecond-accurate clocks? Not necessarily, but when you divide by n, you get good accuracy. Complete prime-number benchmark run: three minutes Should we test for bigger n? Depends on the real-world problem!

52 How not to win at benchmarking Vendors can never resist the urge to cheat Why? Because it sells! The best benchmark is your real program If a vendor can make it faster, then you win! Real benchmarks have real teeth SPEC requires reporting compiler flags, etc.

53 Benefits of performance testing Understand your problem better Big-O analysis hides how your code really runs Tiny benchmarks help confirm your intuitions Break your code with harder and harder cases Surprise! Prof. Wallach s lazy list functions weren t always lazy Discovered when testing these prime number generators last spring The inefficient O(n 2 log n) version s flatmap broke lazy concat Prof. Wallach converted that into a unit test. Never again!

54 Mutation? The Sieve of Eratosthenes has the best scalar performance Parallelization is possible, not easy: Project1_parallel_algorithms_Torben.pdf The purely functional O(n sqrt n) is trivial to parallelize Might even be a good fit for running on a GPU (>100x performance) Hard to guess, in advance, what s really going to win

55 Pragmatic thoughts When you ve got nine implementations, you can compare them Performance and correctness! Use the simple version to unit test the fancy version Small unit tests won t find bugs that only occur at scale Parallelism only pays off for large n Also important: task granularity (tiny tasks don t parallelize as well) Why? What if your task is so fast that you re just waiting on memory?

56 Want more where this came from? Rice Comp322: Fundamentals of Parallel Programming Rice Comp422: Parallel Programming

57 Coming up Week14/Monday: Intro Computer Security (fun!) No class Wednesday or Friday (YouTube videos will be linked on Piazza) We promise there will be an exam question on the videos Week 15/Monday: Intro Android (fun!) Week 15/Wednesday: Life after Comp215 Alternative libraries to edu.rice.* (including Java8 streams) Alternative programming languages Week 15/Friday: Final exam review

Primality Testing! 1

Primality Testing! 1 Primality Testing! 1 Goals of Assignment! Writing software as part of a large team" Living and breathing what COS 217 is about" Abstraction, separation of interfaces and implementations, modularity" Also,

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 7 January 30, 2012 CPSC 467b, Lecture 7 1/44 Public-key cryptography RSA Factoring Assumption Computing with Big Numbers Fast Exponentiation

More information

Activity Guide - Public Key Cryptography

Activity Guide - Public Key Cryptography Unit 2 Lesson 19 Name(s) Period Date Activity Guide - Public Key Cryptography Introduction This activity is similar to the cups and beans encryption we did in a previous lesson. However, instead of using

More information

Control Structures. Code can be purely arithmetic assignments. At some point we will need some kind of control or decision making process to occur

Control Structures. Code can be purely arithmetic assignments. At some point we will need some kind of control or decision making process to occur Control Structures Code can be purely arithmetic assignments At some point we will need some kind of control or decision making process to occur C uses the if keyword as part of it s control structure

More information

Comp215: More lists. Dan S. Wallach (Rice University) Copyright 2015, Dan S. Wallach. All rights reserved.

Comp215: More lists. Dan S. Wallach (Rice University) Copyright 2015, Dan S. Wallach. All rights reserved. Comp215: More lists Dan S. Wallach (Rice University) Copyright 2015, Dan S. Wallach. All rights reserved. What s a good list interface We now have two different kinds of lists: lazy and eager. (We ll talk

More information

COSC 2P91. Introduction Part Deux. Week 1b. Brock University. Brock University (Week 1b) Introduction Part Deux 1 / 14

COSC 2P91. Introduction Part Deux. Week 1b. Brock University. Brock University (Week 1b) Introduction Part Deux 1 / 14 COSC 2P91 Introduction Part Deux Week 1b Brock University Brock University (Week 1b) Introduction Part Deux 1 / 14 Source Files Like most other compiled languages, we ll be dealing with a few different

More information

CS 360 Programming Languages Interpreters

CS 360 Programming Languages Interpreters CS 360 Programming Languages Interpreters Implementing PLs Most of the course is learning fundamental concepts for using and understanding PLs. Syntax vs. semantics vs. idioms. Powerful constructs like

More information

Divisibility Rules and Their Explanations

Divisibility Rules and Their Explanations Divisibility Rules and Their Explanations Increase Your Number Sense These divisibility rules apply to determining the divisibility of a positive integer (1, 2, 3, ) by another positive integer or 0 (although

More information

These are notes for the third lecture; if statements and loops.

These are notes for the third lecture; if statements and loops. These are notes for the third lecture; if statements and loops. 1 Yeah, this is going to be the second slide in a lot of lectures. 2 - Dominant language for desktop application development - Most modern

More information

Lecture Notes, CSE 232, Fall 2014 Semester

Lecture Notes, CSE 232, Fall 2014 Semester Lecture Notes, CSE 232, Fall 2014 Semester Dr. Brett Olsen Week 11 - Number Theory Number theory is the study of the integers. The most basic concept in number theory is divisibility. We say that b divides

More information

Comp215: Structured Data Semantics

Comp215: Structured Data Semantics Comp215: Structured Data Semantics Dan S. Wallach (Rice University) Copyright! 2015, Dan S. Wallach. All rights reserved. Here s a JSON structure for a newspaper "authors": [ "name": "Alice Action", "email":

More information

! Addition! Multiplication! Bigger Example - RSA cryptography

! Addition! Multiplication! Bigger Example - RSA cryptography ! Addition! Multiplication! Bigger Example - RSA cryptography Modular Arithmetic Modular Exponentiation Primality Testing (Fermat s little theorem) Probabilistic algorithm Euclid s Algorithm for gcd (greatest

More information

TA hours and labs start today. First lab is out and due next Wednesday, 1/31. Getting started lab is also out

TA hours and labs start today. First lab is out and due next Wednesday, 1/31. Getting started lab is also out Announcements TA hours and labs start today. First lab is out and due next Wednesday, 1/31. Getting started lab is also out Get you setup for project/lab work. We ll check it with the first lab. Stars

More information

Matching & more list functions

Matching & more list functions Matching & more list functions Dan S. Wallach and Mack Joyner, Rice University Copyright 2016 Dan Wallach, All Rights Reserved When you do the same thing over and over If statements start to get ugly If

More information

n! = 1 * 2 * 3 * 4 * * (n-1) * n

n! = 1 * 2 * 3 * 4 * * (n-1) * n The Beauty and Joy of Computing 1 Lab Exercise 9: Problem self-similarity and recursion Objectives By completing this lab exercise, you should learn to Recognize simple self-similar problems which are

More information

Python for Analytics. Python Fundamentals RSI Chapters 1 and 2

Python for Analytics. Python Fundamentals RSI Chapters 1 and 2 Python for Analytics Python Fundamentals RSI Chapters 1 and 2 Learning Objectives Theory: You should be able to explain... General programming terms like source code, interpreter, compiler, object code,

More information

Copy: IF THE PROGRAM or OUTPUT is Copied, then both will have grade zero.

Copy: IF THE PROGRAM or OUTPUT is Copied, then both will have grade zero. THIS IS HOMEWORK FOR PART-1 OF C/C++ COURSE Instructor: Prof Yahia Halabi Submit: Before exam-1 period [one week from 24/02/2013] Groups: Allowed to work in groups, but at the end, everyone should submit

More information

Parallel Quadratic Number Field Sieve

Parallel Quadratic Number Field Sieve Parallel Quadratic Number Field Sieve Daniel Ron December 20, 2011 Abstract The Quadratic Number Field Sieve (QS) provides a fast and easy to implement method to factor a number. QS works by setting up

More information

Intro. Speed V Growth

Intro. Speed V Growth Intro Good code is two things. It's elegant, and it's fast. In other words, we got a need for speed. We want to find out what's fast, what's slow, and what we can optimize. First, we'll take a tour of

More information

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch Purpose: We will take a look at programming this week using a language called Scratch. Scratch is a programming language that was developed

More information

Garbage Collection (1)

Garbage Collection (1) Coming up: Today: Finish unit 6 (garbage collection) start ArrayList and other library objects Wednesday: Complete ArrayList, basics of error handling Friday complete error handling Next week: Recursion

More information

COMPSCI 230 Discrete Math Prime Numbers January 24, / 15

COMPSCI 230 Discrete Math Prime Numbers January 24, / 15 COMPSCI 230 Discrete Math January 24, 2017 COMPSCI 230 Discrete Math Prime Numbers January 24, 2017 1 / 15 Outline 1 Prime Numbers The Sieve of Eratosthenes Python Implementations GCD and Co-Primes COMPSCI

More information

Heaps, stacks, queues

Heaps, stacks, queues Heaps, stacks, queues Dan S. Wallach and Mack Joyner, Rice University Copyright 216 Dan Wallach, All Rights Reserved Where was Prof. Wallach on Tuesday? Two hours of scintillating Congressional testimony:

More information

Structured data. Dan S. Wallach and Mack Joyner, Rice University. Copyright 2016 Dan Wallach, All Rights Reserved

Structured data. Dan S. Wallach and Mack Joyner, Rice University. Copyright 2016 Dan Wallach, All Rights Reserved Structured data Dan S. Wallach and Mack Joyner, Rice University Copyright 2016 Dan Wallach, All Rights Reserved Here s a JSON structure for a newspaper { "authors": [ { "name": "Alice Action", "email":

More information

Thinking Functionally

Thinking Functionally Thinking Functionally Dan S. Wallach and Mack Joyner, Rice University Copyright 2016 Dan S. Wallach, All Rights Reserved Reminder: Fill out our web form! Fill this out ASAP if you haven t already. http://goo.gl/forms/arykwbc0zy

More information

6.001 Notes: Section 17.5

6.001 Notes: Section 17.5 6.001 Notes: Section 17.5 Slide 17.5.1 Now, let's look at one example in which changing the evaluation model allows us to explore a very different kind of computational problem. Our goal is to show how

More information

Lecture 3: Loops. While Loops. While Loops: Powers of Two. While Loops: Newton-Raphson Method

Lecture 3: Loops. While Loops. While Loops: Powers of Two. While Loops: Newton-Raphson Method While Loops Lecture : Loops The while loop is a common repetition structure. Check loop-continuation condition. Execute a sequence of statements. Repeat. while (boolean expression) statement; while loop

More information

The Art and Science of Memory Allocation

The Art and Science of Memory Allocation Logical Diagram The Art and Science of Memory Allocation Don Porter CSE 506 Binary Formats RCU Memory Management Memory Allocators CPU Scheduler User System Calls Kernel Today s Lecture File System Networking

More information

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 10: Asymptotic Complexity and

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 10: Asymptotic Complexity and CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims Lecture 10: Asymptotic Complexity and What Makes a Good Algorithm? Suppose you have two possible algorithms or

More information

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials Fundamentals We build up instructions from three types of materials Constants Expressions Fundamentals Constants are just that, they are values that don t change as our macros are executing Fundamentals

More information

EECS 470 Lecture 7. Branches: Address prediction and recovery (And interrupt recovery too.)

EECS 470 Lecture 7. Branches: Address prediction and recovery (And interrupt recovery too.) EECS 470 Lecture 7 Branches: Address prediction and recovery (And interrupt recovery too.) Warning: Crazy times coming Project handout and group formation today Help me to end class 12 minutes early P3

More information

Public-Key Encryption, Key Exchange, Digital Signatures CMSC 23200/33250, Autumn 2018, Lecture 7

Public-Key Encryption, Key Exchange, Digital Signatures CMSC 23200/33250, Autumn 2018, Lecture 7 Public-Key Encryption, Key Exchange, Digital Signatures CMSC 23200/33250, Autumn 2018, Lecture 7 David Cash University of Chicago Plan 1. Security of RSA 2. Key Exchange, Diffie-Hellman 3. Begin digital

More information

Lecture 2 Algorithms with numbers

Lecture 2 Algorithms with numbers Advanced Algorithms Floriano Zini Free University of Bozen-Bolzano Faculty of Computer Science Academic Year 2013-2014 Lecture 2 Algorithms with numbers 1 RSA Algorithm Why does RSA work? RSA is based

More information

Introduction to Cryptography and Security Mechanisms. Abdul Hameed

Introduction to Cryptography and Security Mechanisms. Abdul Hameed Introduction to Cryptography and Security Mechanisms Abdul Hameed http://informationtechnology.pk Before we start 3 Quiz 1 From a security perspective, rather than an efficiency perspective, which of the

More information

Cryptography III Want to make a billion dollars? Just factor this one number!

Cryptography III Want to make a billion dollars? Just factor this one number! Cryptography III Want to make a billion dollars? Just factor this one number! 3082010a0282010100a3d56cf0bf8418d66f400be31c3f22036ca9f5cf01ef614de2eb9a1cd74a0c344b5a20d5f80df9a23c89 10c354821aa693432a61bd265ca70f309d56535a679d68d7ab89f9d32c47c1182e8a14203c050afd5f1831e5550e8700e008f2

More information

CMSC 341 Lecture 16/17 Hashing, Parts 1 & 2

CMSC 341 Lecture 16/17 Hashing, Parts 1 & 2 CMSC 341 Lecture 16/17 Hashing, Parts 1 & 2 Prof. John Park Based on slides from previous iterations of this course Today s Topics Overview Uses and motivations of hash tables Major concerns with hash

More information

(Refer Slide Time: 1:27)

(Refer Slide Time: 1:27) Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture 1 Introduction to Data Structures and Algorithms Welcome to data

More information

Week - 04 Lecture - 01 Merge Sort. (Refer Slide Time: 00:02)

Week - 04 Lecture - 01 Merge Sort. (Refer Slide Time: 00:02) Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 04 Lecture - 01 Merge Sort (Refer

More information

CS125 : Introduction to Computer Science. Lecture Notes #38 and #39 Quicksort. c 2005, 2003, 2002, 2000 Jason Zych

CS125 : Introduction to Computer Science. Lecture Notes #38 and #39 Quicksort. c 2005, 2003, 2002, 2000 Jason Zych CS125 : Introduction to Computer Science Lecture Notes #38 and #39 Quicksort c 2005, 2003, 2002, 2000 Jason Zych 1 Lectures 38 and 39 : Quicksort Quicksort is the best sorting algorithm known which is

More information

COMP 110/L Lecture 4. Kyle Dewey

COMP 110/L Lecture 4. Kyle Dewey COMP 110/L Lecture 4 Kyle Dewey Outline New types: long and double Reading in with Scanner Performing operations on them How they interact with each other and other types Exponentiation with Math.pow()

More information

Programming Languages. Streams Wrapup, Memoization, Type Systems, and Some Monty Python

Programming Languages. Streams Wrapup, Memoization, Type Systems, and Some Monty Python Programming Languages Streams Wrapup, Memoization, Type Systems, and Some Monty Python Quick Review of Constructing Streams Usually two ways to construct a stream. Method 1: Use a function that takes a(n)

More information

1 / 43. Today. Finish Euclid. Bijection/CRT/Isomorphism. Fermat s Little Theorem. Review for Midterm.

1 / 43. Today. Finish Euclid. Bijection/CRT/Isomorphism. Fermat s Little Theorem. Review for Midterm. 1 / 43 Today Finish Euclid. Bijection/CRT/Isomorphism. Fermat s Little Theorem. Review for Midterm. 2 / 43 Finding an inverse? We showed how to efficiently tell if there is an inverse. Extend euclid to

More information

Section 05: Solutions

Section 05: Solutions Section 05: Solutions 1. Memory and B-Tree (a) Based on your understanding of how computers access and store memory, why might it be faster to access all the elements of an array-based queue than to access

More information

About this exam review

About this exam review Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review

More information

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution. Repetition Structures Introduction to Repetition Structures Chapter 5 Spring 2016, CSUS Chapter 5.1 Introduction to Repetition Structures The Problems with Duplicate Code A repetition structure causes

More information

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2. Class #10: Understanding Primitives and Assignments Software Design I (CS 120): M. Allen, 19 Sep. 18 Java Arithmetic } Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = 2 + 5 / 2; 3.

More information

Cryptography Worksheet

Cryptography Worksheet Cryptography Worksheet People have always been interested in writing secret messages. In ancient times, people had to write secret messages to keep messengers and interceptors from reading their private

More information

Learning to Program with Haiku

Learning to Program with Haiku Learning to Program with Haiku Lesson 4 Written by DarkWyrm All material 2010 DarkWyrm It would be incredibly hard to write anything useful if there weren't ways for our programs to make decisions or to

More information

Lambdas and Generics (Intro)

Lambdas and Generics (Intro) Lambdas and Generics (Intro) Dan S. Wallach and Mack Joiner, Rice University Copyright 2016 Dan S. Wallach, All Rights Reserved New this week in Subversion! week02-lists (check it out!) edu/rice/week2lists/glist.java

More information

Lecture 1: Overview

Lecture 1: Overview 15-150 Lecture 1: Overview Lecture by Stefan Muller May 21, 2018 Welcome to 15-150! Today s lecture was an overview that showed the highlights of everything you re learning this semester, which also meant

More information

Lecture 3: Loops. While Loops. While Loops: Newton-Raphson Method. While Loops: Powers of Two

Lecture 3: Loops. While Loops. While Loops: Newton-Raphson Method. While Loops: Powers of Two While Loops Lecture 3: Loops The while loop is a common repetition structure. Check loop-continuation condition. Execute a sequence of statements. Repeat. while (boolean expression) statement; while loop

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

Practical Numerical Methods in Physics and Astronomy. Lecture 1 Intro & IEEE Variable Types and Arithmetic

Practical Numerical Methods in Physics and Astronomy. Lecture 1 Intro & IEEE Variable Types and Arithmetic Practical Numerical Methods in Physics and Astronomy Lecture 1 Intro & IEEE Variable Types and Arithmetic Pat Scott Department of Physics, McGill University January 16, 2013 Slides available from http://www.physics.mcgill.ca/

More information

Welcome to Comp215: Introduction to Program Design

Welcome to Comp215: Introduction to Program Design Welcome to Comp215: Introduction to Program Design Dan S. Wallach and Mack Joyner, Rice University Copyright 2016 Dan S. Wallach, All Rights Reserved Welcome, welcome! Java (really Java8) Recursion and

More information

Computer Security. 08. Cryptography Part II. Paul Krzyzanowski. Rutgers University. Spring 2018

Computer Security. 08. Cryptography Part II. Paul Krzyzanowski. Rutgers University. Spring 2018 Computer Security 08. Cryptography Part II Paul Krzyzanowski Rutgers University Spring 2018 March 23, 2018 CS 419 2018 Paul Krzyzanowski 1 Block ciphers Block ciphers encrypt a block of plaintext at a

More information

CS61C Machine Structures. Lecture 3 Introduction to the C Programming Language. 1/23/2006 John Wawrzynek. www-inst.eecs.berkeley.

CS61C Machine Structures. Lecture 3 Introduction to the C Programming Language. 1/23/2006 John Wawrzynek. www-inst.eecs.berkeley. CS61C Machine Structures Lecture 3 Introduction to the C Programming Language 1/23/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L03 Introduction to C (1) Administrivia

More information

Introduction to Computer Science Unit 3. Programs

Introduction to Computer Science Unit 3. Programs Introduction to Computer Science Unit 3. Programs This section must be updated to work with repl.it Programs 1 to 4 require you to use the mod, %, operator. 1. Let the user enter an integer. Your program

More information

(Refer Slide Time 3:31)

(Refer Slide Time 3:31) Digital Circuits and Systems Prof. S. Srinivasan Department of Electrical Engineering Indian Institute of Technology Madras Lecture - 5 Logic Simplification In the last lecture we talked about logic functions

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 7 February 5, 2013 CPSC 467b, Lecture 7 1/45 Stream cipher from block cipher Review of OFB and CFB chaining modes Extending chaining

More information

Algorithms and Programming I. Lecture#12 Spring 2015

Algorithms and Programming I. Lecture#12 Spring 2015 Algorithms and Programming I Lecture#12 Spring 2015 Think Python How to Think Like a Computer Scientist By :Allen Downey Installing Python Follow the instructions on installing Python and IDLE on your

More information

Functions and Decomposition

Functions and Decomposition Unit 4 Functions and Decomposition Learning Outcomes Design and implement functions to carry out a particular task. Begin to evaluate when it is necessary to split some work into functions. Locate the

More information

Structure of Programming Languages Lecture 10

Structure of Programming Languages Lecture 10 Structure of Programming Languages Lecture 10 CS 6636 4536 Spring 2017 CS 6636 4536 Lecture 10: Classes... 1/23 Spring 2017 1 / 23 Outline 1 1. Types Type Coercion and Conversion Type Classes, Generics,

More information

CS 137 Part 2. Loops, Functions, Recursion, Arrays. September 22nd, 2017

CS 137 Part 2. Loops, Functions, Recursion, Arrays. September 22nd, 2017 CS 137 Part 2 Loops, Functions, Recursion, Arrays September 22nd, 2017 Loops We will finish this week with looping statements We already discussed one such structure, namely while loops. while (expr) statement

More information

Applied Cryptography and Network Security

Applied Cryptography and Network Security Applied Cryptography and Network Security William Garrison bill@cs.pitt.edu 6311 Sennott Square Lecture #8: RSA Didn t we learn about RSA last time? During the last lecture, we saw what RSA does and learned

More information

15-498: Distributed Systems Project #1: Design and Implementation of a RMI Facility for Java

15-498: Distributed Systems Project #1: Design and Implementation of a RMI Facility for Java 15-498: Distributed Systems Project #1: Design and Implementation of a RMI Facility for Java Dates of Interest Assigned: During class, Friday, January 26, 2007 Due: 11:59PM, Friday, February 13, 2007 Credits

More information

CPE 101. Overview. Programming vs. Cooking. Key Definitions/Concepts B-1

CPE 101. Overview. Programming vs. Cooking. Key Definitions/Concepts B-1 CPE 101 Lecture 2: Problems, Algorithms, and Programs (Slides adapted from a UW course, copyrighted and used by permission) Overview High-level survey Problems, algorithms, and programs Problem solving

More information

Habanero Extreme Scale Software Research Project

Habanero Extreme Scale Software Research Project Habanero Extreme Scale Software Research Project Comp215: Performance Zoran Budimlić (Rice University) To suffer the penalty of too much haste, which is too little speed. - Plato Never sacrifice correctness

More information

Comp215: Trees. Dan S. Wallach (Rice University) Copyright 2015, Dan S. Wallach. All rights reserved.

Comp215: Trees. Dan S. Wallach (Rice University) Copyright 2015, Dan S. Wallach. All rights reserved. Comp215: Trees Dan S. Wallach (Rice University) Copyright 2015, Dan S. Wallach. All rights reserved. Trees Sometimes, a list isn t good enough Array List Binary Tree Hash Table Insert O(1) unordered O(n)

More information

Processor. Lecture #2 Number Rep & Intro to C classic components of all computers Control Datapath Memory Input Output

Processor. Lecture #2 Number Rep & Intro to C classic components of all computers Control Datapath Memory Input Output CS61C L2 Number Representation & Introduction to C (1) insteecsberkeleyedu/~cs61c CS61C : Machine Structures Lecture #2 Number Rep & Intro to C Scott Beamer Instructor 2007-06-26 Review Continued rapid

More information

C++ for Everyone, 2e, Cay Horstmann, Copyright 2012 John Wiley and Sons, Inc. All rights reserved. Using a Debugger WE5.

C++ for Everyone, 2e, Cay Horstmann, Copyright 2012 John Wiley and Sons, Inc. All rights reserved. Using a Debugger WE5. Using a Debugger WE5 W o r k E D E x a m p l e 5.2 Using a Debugger As you have undoubtedly realized by now, computer programs rarely run perfectly the first time. At times, it can be quite frustrating

More information

Course introduction. Advanced Compiler Construction Michel Schinz

Course introduction. Advanced Compiler Construction Michel Schinz Course introduction Advanced Compiler Construction Michel Schinz 2016 02 25 General information Course goals The goal of this course is to teach you: how to compile high-level functional and objectoriented

More information

Notes for Lecture 10

Notes for Lecture 10 COS 533: Advanced Cryptography Lecture 10 (October 16, 2017) Lecturer: Mark Zhandry Princeton University Scribe: Dylan Altschuler Notes for Lecture 10 1 Motivation for Elliptic Curves Diffie-Hellman For

More information

CS 161 Computer Security

CS 161 Computer Security Paxson Spring 2013 CS 161 Computer Security 3/14 Asymmetric cryptography Previously we saw symmetric-key cryptography, where Alice and Bob share a secret key K. However, symmetric-key cryptography can

More information

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e

More information

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics COMP-202 Unit 1: Introduction Announcements Did you miss the first lecture? Come talk to me after class. If you want

More information

Today. Finish Euclid. Bijection/CRT/Isomorphism. Review for Midterm.

Today. Finish Euclid. Bijection/CRT/Isomorphism. Review for Midterm. Today Finish Euclid. Bijection/CRT/Isomorphism. Review for Midterm. Finding an inverse? We showed how to efficiently tell if there is an inverse. Extend euclid to find inverse. Euclid s GCD algorithm.

More information

Algorithmic Analysis and Sorting, Part Two

Algorithmic Analysis and Sorting, Part Two Algorithmic Analysis and Sorting, Part Two Friday Four Square! 4:15PM, Outside Gates An Initial Idea: Selection Sort An Initial Idea: Selection Sort 4 1 2 7 6 An Initial Idea: Selection Sort 4 1 2 7 6

More information

MA 1128: Lecture 02 1/22/2018

MA 1128: Lecture 02 1/22/2018 MA 1128: Lecture 02 1/22/2018 Exponents Scientific Notation 1 Exponents Exponents are used to indicate how many copies of a number are to be multiplied together. For example, I like to deal with the signs

More information

COP 4516: Math for Programming Contest Notes

COP 4516: Math for Programming Contest Notes COP 4516: Math for Programming Contest Notes Euclid's Algorithm Euclid's Algorithm is the efficient way to determine the greatest common divisor between two integers. Given two positive integers a and

More information

CS Network Security. Nasir Memon Polytechnic University Module 7 Public Key Cryptography. RSA.

CS Network Security. Nasir Memon Polytechnic University Module 7 Public Key Cryptography. RSA. CS 393 - Network Security Nasir Memon Polytechnic University Module 7 Public Key Cryptography. RSA. Course Logistics Homework 2 revised. Due next Tuesday midnight. 2/26,28/02 Module 7 - Pubic Key Crypto

More information

Embedded Systems Design Prof. Anupam Basu Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Embedded Systems Design Prof. Anupam Basu Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Embedded Systems Design Prof. Anupam Basu Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 05 Optimization Issues Now I see, that is not been seen there;

More information

CS110D: PROGRAMMING LANGUAGE I

CS110D: PROGRAMMING LANGUAGE I CS110D: PROGRAMMING LANGUAGE I Computer Science department Lecture 5&6: Loops Lecture Contents Why loops?? While loops for loops do while loops Nested control structures Motivation Suppose that you need

More information

Unit 4: Multiplication

Unit 4: Multiplication Math Fundamentals for Statistics I (Math 52) Unit 4: Multiplication By Scott Fallstrom and Brent Pickett The How and Whys Guys This work is licensed under a Creative Commons Attribution- NonCommercial-ShareAlike

More information

Intro to Public Key Cryptography Diffie & Hellman Key Exchange

Intro to Public Key Cryptography Diffie & Hellman Key Exchange Intro to Public Key Cryptography Diffie & Hellman Key Exchange Course Summary Introduction Stream & Block Ciphers Block Ciphers Modes (ECB,CBC,OFB) Advanced Encryption Standard (AES) Message Authentication

More information

COMP 202 Recursion. CONTENTS: Recursion. COMP Recursion 1

COMP 202 Recursion. CONTENTS: Recursion. COMP Recursion 1 COMP 202 Recursion CONTENTS: Recursion COMP 202 - Recursion 1 Recursive Thinking A recursive definition is one which uses the word or concept being defined in the definition itself COMP 202 - Recursion

More information

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning Lecture 1 Contracts 15-122: Principles of Imperative Computation (Spring 2018) Frank Pfenning In these notes we review contracts, which we use to collectively denote function contracts, loop invariants,

More information

Section 05: Solutions

Section 05: Solutions Section 05: Solutions 1. Asymptotic Analysis (a) Applying definitions For each of the following, choose a c and n 0 which show f(n) O(g(n)). Explain why your values of c and n 0 work. (i) f(n) = 5000n

More information

Comp215: Trees. Mack Joyner and Dan S. Wallach (Rice University) Copyright 2016, Dan S. Wallach. All rights reserved.

Comp215: Trees. Mack Joyner and Dan S. Wallach (Rice University) Copyright 2016, Dan S. Wallach. All rights reserved. Comp215: Trees Mack Joyner and Dan S. Wallach (Rice University) Copyright 2016, Dan S. Wallach. All rights reserved. Trees Sometimes, a list isn t good enough Array List Binary Tree Hash Table Insert O(1)

More information

Repetition Structures

Repetition Structures Repetition Structures Chapter 5 Fall 2016, CSUS Introduction to Repetition Structures Chapter 5.1 1 Introduction to Repetition Structures A repetition structure causes a statement or set of statements

More information

Announcements. 1. Forms to return today after class:

Announcements. 1. Forms to return today after class: Announcements Handouts (3) to pick up 1. Forms to return today after class: Pretest (take during class later) Laptop information form (fill out during class later) Academic honesty form (must sign) 2.

More information

CSE 303: Concepts and Tools for Software Development

CSE 303: Concepts and Tools for Software Development CSE 303: Concepts and Tools for Software Development Dan Grossman Spring 2007 Lecture 19 Profiling (gprof); Linking and Libraries Dan Grossman CSE303 Spring 2007, Lecture 19 1 Where are we Already started

More information

CSC258: Computer Organization. Memory Systems

CSC258: Computer Organization. Memory Systems CSC258: Computer Organization Memory Systems 1 Summer Independent Studies I m looking for a few students who will be working on campus this summer. In addition to the paid positions posted earlier, I have

More information

Smalltalk 3/30/15. The Mathematics of Bitcoin Brian Heinold

Smalltalk 3/30/15. The Mathematics of Bitcoin Brian Heinold Smalltalk 3/30/15 The Mathematics of Bitcoin Brian Heinold What is Bitcoin? Created by Satoshi Nakamoto in 2008 What is Bitcoin? Created by Satoshi Nakamoto in 2008 Digital currency (though not the first)

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

(Refer Slide Time: 01.26)

(Refer Slide Time: 01.26) Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture # 22 Why Sorting? Today we are going to be looking at sorting.

More information

Optimising Functional Programming Languages. Max Bolingbroke, Cambridge University CPRG Lectures 2010

Optimising Functional Programming Languages. Max Bolingbroke, Cambridge University CPRG Lectures 2010 Optimising Functional Programming Languages Max Bolingbroke, Cambridge University CPRG Lectures 2010 Objectives Explore optimisation of functional programming languages using the framework of equational

More information

MA/CSSE 473 Day 05. Integer Primality Testing and Factoring Modular Arithmetic intro Euclid s Algorithm

MA/CSSE 473 Day 05. Integer Primality Testing and Factoring Modular Arithmetic intro Euclid s Algorithm MA/CSSE 473 Day 05 Factors and Primes Recursive division algorithm MA/CSSE 473 Day 05 HW 2 due tonight, 3 is due Monday Student Questions Asymptotic Analysis example: summation Review topics I don t plan

More information

Comparing procedure specifications

Comparing procedure specifications Comparing procedure specifications CSE 331 University of Washington Michael Ernst Outline Satisfying a specification; substitutability Stronger and weaker specifications Comparing by hand Comparing via

More information

CME 193: Introduction to Scientific Python Lecture 1: Introduction

CME 193: Introduction to Scientific Python Lecture 1: Introduction CME 193: Introduction to Scientific Python Lecture 1: Introduction Nolan Skochdopole stanford.edu/class/cme193 1: Introduction 1-1 Contents Administration Introduction Basics Variables Control statements

More information

CompSci 94 Making Decisions February 8, Prof. Susan Rodger

CompSci 94 Making Decisions February 8, Prof. Susan Rodger CompSci 94 Making Decisions February 8, 2018 Prof. Susan Rodger CompSci 94 Spring 2018 1 Class Today Asking questions and making decisions Using functions If statements CompSci 94 Spring 2018 2 Review

More information