ELEMENTARY SORTING ALGORITHMS

Size: px
Start display at page:

Download "ELEMENTARY SORTING ALGORITHMS"

Transcription

1 BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING ELEMENTARY SORTING ALGORITHMS Feb. 20, 2017 Acknowledgement: The course sldes are adapted from the sldes prepared by R. Sedgewck and K. Wayne of Prnceton Unversty.

2 ELEMENTARY SORTING ALGORITHMS Sortng revew Rules of the game Selecton sort Inserton sort Shellsort

3 ELEMENTARY SORTING ALGORITHMS Sortng revew Rules of the game Selecton sort Inserton sort Shellsort

4 Sortng problem Ex. Student records n a unversty. Chen 3 A Blar Rohde 2 A Forbes Gazs 4 B Brown tem Fura 1 A Brown Kanaga 3 B Brown Andrews 3 A Lttle key Battle 4 C Whtman Sort. Rearrange array of N tems nto ascendng order. Andrews 3 A Lttle Battle 4 C Whtman Chen 3 A Blar Fura 1 A Brown Gazs 4 B Brown Kanaga 3 B Brown Rohde 2 A Forbes 4

5 Sample sort clent Goal. Sort any type of data. Ex 1. Sort random real numbers n ascendng order. seems artfcal, but stay tuned for an applcaton publc class Experment { publc statc vod man(strng[] args) { nt N = Integer.parseInt(args[0]); Double[] a = new Double[N]; for (nt = 0; < N; ++) a[] = StdRandom.unform(); Inserton.sort(a); for (nt = 0; < N; ++) StdOut.prntln(a[]); } } % java Experment

6 Sample sort clent Goal. Sort any type of data. Ex 2. Sort strngs from fle n alphabetcal order. publc class StrngSorter { publc statc vod man(strng[] args) { Strng[] a = In.readStrngs(args[0]); Inserton.sort(a); for (nt = 0; < a.length; ++) StdOut.prntln(a[]); } } % more words3.txt bed bug dad yet zoo... all bad yes % java StrngSorter words3.txt all bad bed bug dad... yes yet zoo 6

7 Sample sort clent Goal. Sort any type of data. Ex 3. Sort the fles n a gven drectory by flename. mport java.o.fle; publc class FleSorter { publc statc vod man(strng[] args) { Fle drectory = new Fle(args[0]); Fle[] fles = drectory.lstfles(); Inserton.sort(fles); for (nt = 0; < fles.length; ++) StdOut.prntln(fles[].getName()); } } % java FleSorter. Inserton.class Inserton.java InsertonX.class InsertonX.java Selecton.class Selecton.java Shell.class Shell.java ShellX.class ShellX.java 7

8 Callbacks Goal. Sort any type of data. Q. How can sort() know how to compare data of type Double, Strng, and java.o.fle wthout any nformaton about the type of an tem's key? Callback = reference to executable code. Clent passes array of objects to sort() functon. The sort() functon calls back object's compareto() method as needed. Implementng callbacks. Java: nterfaces. C: functon ponters. C++: class-type functors. C#: delegates. Python, Perl, ML, Javascrpt: frst-class functons. 8

9 Callbacks: roadmap clent mport java.o.fle; publc class FleSorter { publc statc vod man(strng[] args) { Fle drectory = new Fle(args[0]); Fle[] fles = drectory.lstfles(); Inserton.sort(fles); for (nt = 0; < fles.length; ++) StdOut.prntln(fles[].getName()); } } object mplementaton publc class Fle mplements Comparable<Fle> {... publc nt compareto(fle b) {... return -1;... return +1;... return 0; } } Comparable nterface (bult n to Java) publc nterface Comparable<Item> { publc nt compareto(item that); } key pont: no dependence on Fle data type sort mplementaton publc statc vod sort(comparable[] a) { nt N = a.length; for (nt = 0; < N; ++) for (nt j = ; j > 0; j--) f (a[j].compareto(a[j-1]) < 0) exch(a, j, j-1); else break; } 9

10 Total order A total order s a bnary relaton that satsfes Antsymmetry: f v w and w v, then v = w. Transtvty: f v w and w x, then v x. Totalty: ether v w or w v or both. Ex. Standard order for natural and real numbers. Alphabetcal order for strngs. Chronologcal order for dates.... an ntranstve relaton 10

11 Comparable API Implement compareto() so that v.compareto(w) Is a total order. Returns a negatve nteger, zero, or postve nteger f v s less than, equal to, or greater than w, respectvely. Throws an excepton f ncompatble types (or ether s null). v w v w v w less than (return -1) equal to (return 0) greater than (return +1) Bult-n comparable types. Integer, Double, Strng, Date, Fle,... User-defned comparable types. Implement the Comparable nterface. 11

12 Implementng the Comparable nterface Date data type. Smplfed verson of java.utl.date. publc class Date mplements Comparable<Date> { prvate fnal nt month, day, year; publc Date(nt m, nt d, nt y) { month = m; day = d; year = y; } only compare dates to other dates } publc nt compareto(date that) { f (ths.year < that.year ) return -1; f (ths.year > that.year ) return +1; f (ths.month < that.month) return -1; f (ths.month > that.month) return +1; f (ths.day < that.day ) return -1; f (ths.day > that.day ) return +1; return 0; } 12

13 Two useful sortng abstractons Helper functons. Refer to data through compares and exchanges. Less. Is tem v less than w? prvate statc boolean less(comparable v, Comparable w) { return v.compareto(w) < 0; } Exchange. Swap tem n array a[] at ndex wth the one at ndex j. prvate statc vod exch(comparable[] a, nt, nt j) { Comparable swap = a[]; a[] = a[j]; a[j] = swap; } 13

14 ELEMENTARY SORTING ALGORITHMS Sortng revew Rules of the game Selecton sort Inserton sort Shellsort

15 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. remanng entres 15

16 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn remanng entres 16

17 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn remanng entres 17

18 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. n fnal order remanng entres 18

19 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 19

20 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 20

21 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. n fnal order remanng entres 21

22 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 22

23 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 23

24 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. n fnal order remanng entres 24

25 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 25

26 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 26

27 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. n fnal order remanng entres 27

28 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 28

29 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 29

30 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. n fnal order remanng entres 30

31 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 31

32 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 32

33 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. n fnal order remanng entres 33

34 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 34

35 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 35

36 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. n fnal order remanng entres 36

37 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 37

38 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 38

39 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. n fnal order remanng entres 39

40 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 40

41 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. mn n fnal order remanng entres 41

42 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. n fnal order 42

43 Selecton sort In teraton, fnd ndex mn of smallest remanng entry. Swap a[] and a[mn]. sorted 43

44 Selecton sort: Java mplementaton publc class Selecton { publc statc vod sort(comparable[] a) { nt N = a.length; for (nt = 0; < N; ++) { nt mn = ; for (nt j = +1; j < N; j++) f (less(a[j], a[mn])) mn = j; exch(a,, mn); } } prvate statc boolean less(comparable v, Comparable w) { /* as before */ } } prvate statc vod exch(comparable[] a, nt, nt j) { /* as before */ } 44

45 Selecton sort: mathematcal analyss Proposton. Selecton sort uses (N 1) + (N 2) ~ N 2 / 2 compares and N exchanges. a[] mn S O R T E X A M P L E 0 6 S O R T E X A M P L E 1 4 A O R T E X S M P L E 2 10 A E R T O X S M P L E 3 9 A E E T O X S M P L R 4 7 A E E L O X S M P T R 5 7 A E E L M X S O P T R 6 8 A E E L M O S X P T R 7 10 A E E L M O P X S T R 8 8 A E E L M O P R S T X 9 9 A E E L M O P R S T X A E E L M O P R S T X entres n black are examned to fnd the mnmum entres n red are a[mn] entres n gray are n fnal poston A E E L M O P R S T X Trace of selecton sort (array contents just after each exchange) Runnng tme nsenstve to nput. Quadratc tme, even f nput array s sorted. Data movement s mnmal. Lnear number of exchanges. 45

46 Selecton sort: anmatons 20 random tems algorthm poston n fnal order not n fnal order 46

47 Selecton sort: anmatons 20 partally-sorted tems algorthm poston n fnal order not n fnal order 47

48 ELEMENTARY SORTING ALGORITHMS Sortng revew Rules of the game Selecton sort Inserton sort Shellsort

49 Inserton sort In teraton, swap a[] wth each larger entry to ts left. 49

50 Inserton sort In teraton, swap a[] wth each larger entry to ts left. not yet seen 50

51 Selecton sort In teraton, swap a[] wth each larger entry to ts left. j n ascendng order not yet seen 51

52 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 52

53 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j n ascendng order not yet seen 53

54 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 54

55 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 55

56 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 56

57 Inserton sort In teraton, swap a[] wth each larger entry to ts left. n ascendng order not yet seen 57

58 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 58

59 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 59

60 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 60

61 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 61

62 Inserton sort In teraton, swap a[] wth each larger entry to ts left. n ascendng order not yet seen 62

63 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 63

64 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 64

65 Inserton sort In teraton, swap a[] wth each larger entry to ts left. n ascendng order not yet seen 65

66 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 66

67 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 67

68 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 68

69 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 69

70 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 70

71 Inserton sort In teraton, swap a[] wth each larger entry to ts left. n ascendng order not yet seen 71

72 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 72

73 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 73

74 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 74

75 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 75

76 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 76

77 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 77

78 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 78

79 Inserton sort In teraton, swap a[] wth each larger entry to ts left. n ascendng order not yet seen 79

80 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 80

81 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j not yet seen 81

82 Inserton sort In teraton, swap a[] wth each larger entry to ts left. n ascendng order not yet seen 82

83 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j 83

84 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j 84

85 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j 85

86 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j 86

87 Inserton sort In teraton, swap a[] wth each larger entry to ts left. j 87

88 Inserton sort In teraton, swap a[] wth each larger entry to ts left. sorted 88

89 Inserton sort: Java mplementaton publc class Inserton { publc statc vod sort(comparable[] a) { nt N = a.length; for (nt = 0; < N; ++) for (nt j = ; j > 0; j--) f (less(a[j], a[j-1])) exch(a, j, j-1); else break; } prvate statc boolean less(comparable v, Comparable w) { /* as before */ } } prvate statc vod exch(comparable[] a, nt, nt j) { /* as before */ } 89

90 Inserton sort: mathematcal analyss Proposton. To sort a randomly-ordered array wth dstnct keys, nserton sort uses ~ ¼ N 2 compares and ~ ¼ N 2 exchanges on average. Pf. Expect each entry to move halfway back. a[] j S O R T E X A M P L E 1 0 O S R T E X A M P L E 2 1 O R S T E X A M P L E 3 3 O R S T E X A M P L E 4 0 E O R S T X A M P L E 5 5 E O R S T X A M P L E 6 0 A E O R S T X M P L E 7 2 A E M O R S T X P L E 8 4 A E M O P R S T X L E 9 2 A E L M O P R S T X E 10 2 A E E L M O P R S T X entres n gray do not move entry n red s a[j] entres n black moved one poston rght for nserton A E E L M O P R S T X Trace of nserton sort (array contents just after each nserton) 90

91 Inserton sort: anmaton 40 random tems algorthm poston n order not yet seen 91

92 Inserton sort: best and worst case Best case. If the array s n ascendng order, nserton sort makes N - 1 compares and 0 exchanges. A E E L M O P R S T X Worst case. If the array s n descendng order (and no duplcates), nserton sort makes ~ ½ N 2 compares and ~ ½ N 2 exchanges. X T S R P O M L E E A 92

93 Inserton sort: anmaton 40 reverse-sorted tems algorthm poston n order not yet seen 93

94 Inserton sort: partally-sorted arrays Def. An nverson s a par of keys that are out of order. A E E L M O T R X P S T-R T-P T-S R-P X-P X-S (6 nversons) Def. An array s partally sorted f the number of nversons s c N. Ex 1. A subarray of sze 10 appended to a sorted subarray of sze N. Ex 2. An array of sze N wth only 10 entres out of place. Proposton. For partally-sorted arrays, nserton sort runs n lnear tme. Pf. Number of exchanges equals the number of nversons. number of compares = exchanges + (N 1) 94

95 Inserton sort: anmaton 40 partally-sorted tems algorthm poston n order not yet seen 95

96 ELEMENTARY SORTING ALGORITHMS Sortng revew Rules of the game Selecton sort Inserton sort Shellsort

97 Shellsort overvew Idea. Move entres more than one poston at a tme by h-sortng the array. an h-sorted array s h nterleaved sorted subsequences h = 4 L E E A M H L E P S O L T S X R L M P T E H S S E L O X A E L R Shellsort. [Shell 1959] h-sort the array for decreasng seq. of values of h. nput 13-sort 4-sort 1-sort S H E L L S O R T E X A M P L E P H E L L S O R T E X A M S L E L E E A M H L E P S O L T S X R A E E E H L L L M O P R S S T X 97

98 h-sortng How to h-sort an array? Inserton sort, wth strde length h. 3-sortng an array M O L E E X A S P R T E O L M E X A S P R T E E L M O X A S P R T E E L M O X A S P R T A E L E O X M S P R T A E L E O X M S P R T A E L E O P M S X R T A E L E O P M S X R T A E L E O P M S X R T A E L E O P M S X R T Why nserton sort? Bg ncrements small subarray. Small ncrements nearly n order. [stay tuned] 98

99 Shellsort example: ncrements 7, 3, 1 nput S O R T E X A M P L E 7-sort S O R T E X A M P L E M O R T E X A S P L E M O R T E X A S P L E M O L T E X A S P R E M O L E E X A S P R T 3-sort M O L E E X A S P R T E O L M E X A S P R T E E L M O X A S P R T E E L M O X A S P R T A E L E O X M S P R T A E L E O X M S P R T A E L E O P M S X R T A E L E O P M S X R T A E L E O P M S X R T 1-sort A E L E O P M S X R T A E L E O P M S X R T A E L E O P M S X R T A E E L O P M S X R T A E E L O P M S X R T A E E L O P M S X R T A E E L M O P S X R T A E E L M O P S X R T A E E L M O P S X R T A E E L M O P R S X T A E E L M O P R S T X result A E E L M O P R S T X 99

100 Shellsort: ntuton Proposton. A g-sorted array remans g-sorted after h-sortng t. 7-sort M O R T E X A S P L E M O R T E X A S P L E M O L T E X A S P R E M O L E E X A S P R T M O L E E X A S P R T 3-sort M O L E E X A S P R T E O L M E X A S P R T E E L M O X A S P R T E E L M O X A S P R T A E L E O X M S P R T A E L E O X M S P R T A E L E O P M S X R T A E L E O P M S X R T A E L E O P M S X R T A E L E O P M S X R T stll 7-sorted 100

101 Shellsort: whch ncrement sequence to use? Powers of two. 1, 2, 4, 8, 16, 32,... No. Powers of two mnus one. 1, 3, 7, 15, 31, 63,... Maybe. 3x , 4, 13, 40, 121, 364,... OK. Easy to compute. mergng of (9 4 ) (9 2 ) + 1 and 4 (3 2 ) + 1 Sedgewck. 1, 5, 19, 41, 109, 209, 505, 929, 2161, 3905,... Good. Tough to beat n emprcal studes. = Interested n learnng more? See Secton 6.8 of Algs, 3 rd edton or Volume 3 of Knuth for detals. Do a JP on the topc. 101

102 Shellsort: Java mplementaton publc class Shell { publc statc vod sort(comparable[] a) { nt N = a.length; 3x+1 ncrement sequence nt h = 1; whle (h < N/3) h = 3*h + 1; // 1, 4, 13, 40, 121, 364, 1093,... whle (h >= 1) { // h-sort the array. for (nt = h; < N; ++) { for (nt j = ; j >= h && less(a[j], a[j-h]); j -= h) exch(a, j, j-h); } nserton sort move to next ncrement } } h = h/3; } prvate statc boolean less(comparable v, Comparable w) { /* as before */ } prvate statc boolean vod(comparable[] a, nt, nt j) { /* as before */ } 102

103 Shellsort: vsual trace nput 40-sorted 13-sorted 4-sorted result 103

104 Shellsort: anmaton 50 random tems algorthm poston h-sorted current subsequence other elements 104

105 Shellsort: anmaton 50 partally-sorted tems algorthm poston h-sorted current subsequence other elements 105

106 Shellsort: analyss Proposton. The worst-case number of compares used by shellsort wth the 3x+1 ncrements s O(N 3/2 ). Property. The number of compares used by shellsort wth the 3x+1 ncrements s at most by a small multple of N tmes the # of ncrements used. N compares N N lg N measured n thousands Remark. Accurate model has not yet been dscovered (!) 106

107 Why are we nterested n shellsort? Example of smple dea leadng to substantal performance gans. Useful n practce. Fast unless array sze s huge. Tny, fxed footprnt for code (used n embedded systems). Hardware sort prototype. Smple algorthm, nontrval performance, nterestng questons. Asymptotc growth rate? Best sequence of ncrements? Average-case performance? open problem: fnd a better ncrement sequence Lesson. Some good algorthms are stll watng dscovery. 107

MERGESORT BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING. Mergesort

MERGESORT BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING. Mergesort BBM 202 - ALGORITHMS DEPT. OF COMPUTER ENGINEERING Mergesort Basc plan. Dvde array nto two halves. Recursvely sort each half. Merge two halves. MERGESORT nput sort left half sort rght half merge results

More information

MERGESORT BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING ERKUT ERDEM. Mergesort. Feb. 27, 2014

MERGESORT BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING ERKUT ERDEM. Mergesort. Feb. 27, 2014 ergesort BB 202 - ALGOITHS Basc plan. Dvde array nto two halves. ecursvely sort each half. erge two halves. DPT. OF COPUT NGINING KUT D GSOT nput G S O T X A P L sort left half G O S T X A P L sort rght

More information

Algorithms. Algorithms. Algorithms 2.2 M ERGESORT. mergesort bottom-up mergesort. sorting complexity divide-and-conquer

Algorithms. Algorithms. Algorithms 2.2 M ERGESORT. mergesort bottom-up mergesort. sorting complexity divide-and-conquer Algorthms Two classc sortng algorthms: mergesort and qucsort R OBERT S EDGEWICK K EVIN W AYNE Crtcal components n the world s computatonal nfrastructure. Full scentfc understandng of ther propertes has

More information

SORTING ALGORITHMS BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING ERKUT ERDEM. Mar. 21, 2013

SORTING ALGORITHMS BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING ERKUT ERDEM. Mar. 21, 2013 BBM 202 - ALGORITHMS DPT. OF COMPUTR NGINRING RKUT RDM SORTING ALGORITHMS Mar. 21, 2013 Acknowledgement: The course slides are adapted from the slides prepared by R. Sedgewick and K. Wayne of Princeton

More information

Sorting Algorithms. !rules of the game!shellsort!mergesort!quicksort!animations. Classic sorting algorithms

Sorting Algorithms. !rules of the game!shellsort!mergesort!quicksort!animations. Classic sorting algorithms Classic sorting algorithms Sorting Algorithms!rules of the game!shellsort!mergesort!quicksort!animations Reference: Algorithms in Java, Chapters 6-8 1 Critical components in the world s computational infrastructure.

More information

CS 350 Algorithms and Complexity

CS 350 Algorithms and Complexity CS 350 Algorthms and Complexty Wnter 2015 Lecture 8: Decrease & Conquer (contnued) Andrew P. Black Department of Computer Scence Portland State Unversty Example: DFS traversal of undrected graph a b c

More information

find (x): given element x, return the canonical element of the set containing x;

find (x): given element x, return the canonical element of the set containing x; COS 43 Sprng, 009 Dsjont Set Unon Problem: Mantan a collecton of dsjont sets. Two operatons: fnd the set contanng a gven element; unte two sets nto one (destructvely). Approach: Canoncal element method:

More information

Problem Set 9 Solutions

Problem Set 9 Solutions Desgn and Analyss of Algorthms May 4, 2015 Massachusetts Insttute of Technology 6.046J/18.410J Profs. Erk Demane, Srn Devadas, and Nancy Lynch Problem Set 9 Solutons Problem Set 9 Solutons Ths problem

More information

Outline and Reading. Dynamic Programming. Dynamic Programming revealed. Computing Fibonacci. The General Dynamic Programming Technique

Outline and Reading. Dynamic Programming. Dynamic Programming revealed. Computing Fibonacci. The General Dynamic Programming Technique Outlne and Readng Dynamc Programmng The General Technque ( 5.3.2) -1 Knapsac Problem ( 5.3.3) Matrx Chan-Product ( 5.3.1) Dynamc Programmng verson 1.4 1 Dynamc Programmng verson 1.4 2 Dynamc Programmng

More information

Exercises. 18 Algorithms

Exercises. 18 Algorithms 18 Algorthms Exercses 0.1. In each of the followng stuatons, ndcate whether f = O(g), or f = Ω(g), or both (n whch case f = Θ(g)). f(n) g(n) (a) n 100 n 200 (b) n 1/2 n 2/3 (c) 100n + log n n + (log n)

More information

Hashing. Alexandra Stefan

Hashing. Alexandra Stefan Hashng Alexandra Stefan 1 Hash tables Tables Drect access table (or key-ndex table): key => ndex Hash table: key => hash value => ndex Man components Hash functon Collson resoluton Dfferent keys mapped

More information

CHAPTER 17 Amortized Analysis

CHAPTER 17 Amortized Analysis CHAPTER 7 Amortzed Analyss In an amortzed analyss, the tme requred to perform a sequence of data structure operatons s averaged over all the operatons performed. It can be used to show that the average

More information

On the Multicriteria Integer Network Flow Problem

On the Multicriteria Integer Network Flow Problem BULGARIAN ACADEMY OF SCIENCES CYBERNETICS AND INFORMATION TECHNOLOGIES Volume 5, No 2 Sofa 2005 On the Multcrtera Integer Network Flow Problem Vassl Vasslev, Marana Nkolova, Maryana Vassleva Insttute of

More information

Math Review. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

Math Review. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University Math Revew CptS 223 dvanced Data Structures Larry Holder School of Electrcal Engneerng and Computer Scence Washngton State Unversty 1 Why do we need math n a data structures course? nalyzng data structures

More information

Calculation of time complexity (3%)

Calculation of time complexity (3%) Problem 1. (30%) Calculaton of tme complexty (3%) Gven n ctes, usng exhaust search to see every result takes O(n!). Calculaton of tme needed to solve the problem (2%) 40 ctes:40! dfferent tours 40 add

More information

JOURNAL OF OBJECT TECHNOLOGY

JOURNAL OF OBJECT TECHNOLOGY JOURNAL OF OBJECT TECHNOLOGY Publshed by ETH Zurch, Char of Software Engneerng JOT, 2010 Vol. 9, No. 2, March - Aprl 2010 The Dscrete Fourer Transform, Part 6: Cross-Correlaton By Douglas Lyon Abstract

More information

Generalized Linear Methods

Generalized Linear Methods Generalzed Lnear Methods 1 Introducton In the Ensemble Methods the general dea s that usng a combnaton of several weak learner one could make a better learner. More formally, assume that we have a set

More information

Speeding up Computation of Scalar Multiplication in Elliptic Curve Cryptosystem

Speeding up Computation of Scalar Multiplication in Elliptic Curve Cryptosystem H.K. Pathak et. al. / (IJCSE) Internatonal Journal on Computer Scence and Engneerng Speedng up Computaton of Scalar Multplcaton n Ellptc Curve Cryptosystem H. K. Pathak Manju Sangh S.o.S n Computer scence

More information

Elementary Sorts 1 / 18

Elementary Sorts 1 / 18 Elementary Sorts 1 / 18 Outline 1 Rules of the Game 2 Selection Sort 3 Insertion Sort 4 Shell Sort 5 Visualizing Sorting Algorithms 6 Comparing Sorting Algorithms 2 / 18 Rules of the Game Sorting is the

More information

For now, let us focus on a specific model of neurons. These are simplified from reality but can achieve remarkable results.

For now, let us focus on a specific model of neurons. These are simplified from reality but can achieve remarkable results. Neural Networks : Dervaton compled by Alvn Wan from Professor Jtendra Malk s lecture Ths type of computaton s called deep learnng and s the most popular method for many problems, such as computer vson

More information

Supplement: Proofs and Technical Details for The Solution Path of the Generalized Lasso

Supplement: Proofs and Technical Details for The Solution Path of the Generalized Lasso Supplement: Proofs and Techncal Detals for The Soluton Path of the Generalzed Lasso Ryan J. Tbshran Jonathan Taylor In ths document we gve supplementary detals to the paper The Soluton Path of the Generalzed

More information

Singular Value Decomposition: Theory and Applications

Singular Value Decomposition: Theory and Applications Sngular Value Decomposton: Theory and Applcatons Danel Khashab Sprng 2015 Last Update: March 2, 2015 1 Introducton A = UDV where columns of U and V are orthonormal and matrx D s dagonal wth postve real

More information

Lecture Notes on Linear Regression

Lecture Notes on Linear Regression Lecture Notes on Lnear Regresson Feng L fl@sdueducn Shandong Unversty, Chna Lnear Regresson Problem In regresson problem, we am at predct a contnuous target value gven an nput feature vector We assume

More information

A 2D Bounded Linear Program (H,c) 2D Linear Programming

A 2D Bounded Linear Program (H,c) 2D Linear Programming A 2D Bounded Lnear Program (H,c) h 3 v h 8 h 5 c h 4 h h 6 h 7 h 2 2D Lnear Programmng C s a polygonal regon, the ntersecton of n halfplanes. (H, c) s nfeasble, as C s empty. Feasble regon C s unbounded

More information

Feature Selection: Part 1

Feature Selection: Part 1 CSE 546: Machne Learnng Lecture 5 Feature Selecton: Part 1 Instructor: Sham Kakade 1 Regresson n the hgh dmensonal settng How do we learn when the number of features d s greater than the sample sze n?

More information

Société de Calcul Mathématique SA

Société de Calcul Mathématique SA Socété de Calcul Mathématque SA Outls d'ade à la décson Tools for decson help Probablstc Studes: Normalzng the Hstograms Bernard Beauzamy December, 202 I. General constructon of the hstogram Any probablstc

More information

SUBSTRING SEARCH BBM ALGORITHMS TODAY DEPT. OF COMPUTER ENGINEERING ERKUT ERDEM. Apr. 29, Substring search applications.

SUBSTRING SEARCH BBM ALGORITHMS TODAY DEPT. OF COMPUTER ENGINEERING ERKUT ERDEM. Apr. 29, Substring search applications. M 22 - LGORITHMS TODY Substrng search DPT. OF OMPUTR NGINRING RKUT RDM rute force Knuth-Morrs-Pratt oyer-moore Rabn-Karp SUSTRING SRH pr. 29, 214 cknowledgement: The course sldes are adapted from the sldes

More information

Homework 9 Solutions. 1. (Exercises from the book, 6 th edition, 6.6, 1-3.) Determine the number of distinct orderings of the letters given:

Homework 9 Solutions. 1. (Exercises from the book, 6 th edition, 6.6, 1-3.) Determine the number of distinct orderings of the letters given: Homework 9 Solutons PROBLEM ONE 1 (Exercses from the book, th edton,, 1-) Determne the number of dstnct orderngs of the letters gven: (a) GUIDE Soluton: 5! (b) SCHOOL Soluton:! (c) SALESPERSONS Soluton:

More information

Example: (13320, 22140) =? Solution #1: The divisors of are 1, 2, 3, 4, 5, 6, 9, 10, 12, 15, 18, 20, 27, 30, 36, 41,

Example: (13320, 22140) =? Solution #1: The divisors of are 1, 2, 3, 4, 5, 6, 9, 10, 12, 15, 18, 20, 27, 30, 36, 41, The greatest common dvsor of two ntegers a and b (not both zero) s the largest nteger whch s a common factor of both a and b. We denote ths number by gcd(a, b), or smply (a, b) when there s no confuson

More information

MMA and GCMMA two methods for nonlinear optimization

MMA and GCMMA two methods for nonlinear optimization MMA and GCMMA two methods for nonlnear optmzaton Krster Svanberg Optmzaton and Systems Theory, KTH, Stockholm, Sweden. krlle@math.kth.se Ths note descrbes the algorthms used n the author s 2007 mplementatons

More information

More metrics on cartesian products

More metrics on cartesian products More metrcs on cartesan products If (X, d ) are metrc spaces for 1 n, then n Secton II4 of the lecture notes we defned three metrcs on X whose underlyng topologes are the product topology The purpose of

More information

A PROBABILITY-DRIVEN SEARCH ALGORITHM FOR SOLVING MULTI-OBJECTIVE OPTIMIZATION PROBLEMS

A PROBABILITY-DRIVEN SEARCH ALGORITHM FOR SOLVING MULTI-OBJECTIVE OPTIMIZATION PROBLEMS HCMC Unversty of Pedagogy Thong Nguyen Huu et al. A PROBABILITY-DRIVEN SEARCH ALGORITHM FOR SOLVING MULTI-OBJECTIVE OPTIMIZATION PROBLEMS Thong Nguyen Huu and Hao Tran Van Department of mathematcs-nformaton,

More information

Appendix B: Resampling Algorithms

Appendix B: Resampling Algorithms 407 Appendx B: Resamplng Algorthms A common problem of all partcle flters s the degeneracy of weghts, whch conssts of the unbounded ncrease of the varance of the mportance weghts ω [ ] of the partcles

More information

Review of Taylor Series. Read Section 1.2

Review of Taylor Series. Read Section 1.2 Revew of Taylor Seres Read Secton 1.2 1 Power Seres A power seres about c s an nfnte seres of the form k = 0 k a ( x c) = a + a ( x c) + a ( x c) + a ( x c) k 2 3 0 1 2 3 + In many cases, c = 0, and the

More information

SUBSTRING SEARCH BBM ALGORITHMS TODAY DEPT. OF COMPUTER ENGINEERING ERKUT ERDEM. Apr. 28, Substring search applications.

SUBSTRING SEARCH BBM ALGORITHMS TODAY DEPT. OF COMPUTER ENGINEERING ERKUT ERDEM. Apr. 28, Substring search applications. M 22 - LGORITHMS TODY DEPT. OF OMPUTER ENGINEERING ERKUT ERDEM Substrng search rute force Knuth-Morrs-Pratt oyer-moore Rabn-Karp SUSTRING SERH pr. 28, 215 cknowledgement:.the$course$sldes$are$adapted$from$the$sldes$prepared$by$r.$sedgewck$

More information

THE SUMMATION NOTATION Ʃ

THE SUMMATION NOTATION Ʃ Sngle Subscrpt otaton THE SUMMATIO OTATIO Ʃ Most of the calculatons we perform n statstcs are repettve operatons on lsts of numbers. For example, we compute the sum of a set of numbers, or the sum of the

More information

ECE559VV Project Report

ECE559VV Project Report ECE559VV Project Report (Supplementary Notes Loc Xuan Bu I. MAX SUM-RATE SCHEDULING: THE UPLINK CASE We have seen (n the presentaton that, for downlnk (broadcast channels, the strategy maxmzng the sum-rate

More information

Graphs and Trees: cycles detection and stream segmentation. Lorenzo Cioni Dipartimento di Informatica Largo Pontecorvo 3 Pisa

Graphs and Trees: cycles detection and stream segmentation. Lorenzo Cioni Dipartimento di Informatica Largo Pontecorvo 3 Pisa Graphs and Trees: cycles detecton and stream segmentaton Lorenzo Con Dpartmento d Informatca Largo Pontecorvo 3 Psa lcon@d.unp.t Man topcs of the talk Two algorthms: segmentaton of a stream of data applcaton:

More information

A Simple Inventory System

A Simple Inventory System A Smple Inventory System Lawrence M. Leems and Stephen K. Park, Dscrete-Event Smulaton: A Frst Course, Prentce Hall, 2006 Hu Chen Computer Scence Vrgna State Unversty Petersburg, Vrgna February 8, 2017

More information

Multilayer Perceptron (MLP)

Multilayer Perceptron (MLP) Multlayer Perceptron (MLP) Seungjn Cho Department of Computer Scence and Engneerng Pohang Unversty of Scence and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjn@postech.ac.kr 1 / 20 Outlne

More information

Lecture 4: Constant Time SVD Approximation

Lecture 4: Constant Time SVD Approximation Spectral Algorthms and Representatons eb. 17, Mar. 3 and 8, 005 Lecture 4: Constant Tme SVD Approxmaton Lecturer: Santosh Vempala Scrbe: Jangzhuo Chen Ths topc conssts of three lectures 0/17, 03/03, 03/08),

More information

Edge Isoperimetric Inequalities

Edge Isoperimetric Inequalities November 7, 2005 Ross M. Rchardson Edge Isopermetrc Inequaltes 1 Four Questons Recall that n the last lecture we looked at the problem of sopermetrc nequaltes n the hypercube, Q n. Our noton of boundary

More information

TOPICS MULTIPLIERLESS FILTER DESIGN ELEMENTARY SCHOOL ALGORITHM MULTIPLICATION

TOPICS MULTIPLIERLESS FILTER DESIGN ELEMENTARY SCHOOL ALGORITHM MULTIPLICATION 1 2 MULTIPLIERLESS FILTER DESIGN Realzaton of flters wthout full-fledged multplers Some sldes based on support materal by W. Wolf for hs book Modern VLSI Desgn, 3 rd edton. Partly based on followng papers:

More information

General theory of fuzzy connectedness segmentations: reconciliation of two tracks of FC theory

General theory of fuzzy connectedness segmentations: reconciliation of two tracks of FC theory General theory of fuzzy connectedness segmentatons: reconclaton of two tracks of FC theory Krzysztof Chrs Ceselsk Department of Mathematcs, West Vrgna Unversty and MIPG, Department of Radology, Unversty

More information

Common loop optimizations. Example to improve locality. Why Dependence Analysis. Data Dependence in Loops. Goal is to find best schedule:

Common loop optimizations. Example to improve locality. Why Dependence Analysis. Data Dependence in Loops. Goal is to find best schedule: 15-745 Lecture 6 Data Dependence n Loops Copyrght Seth Goldsten, 2008 Based on sldes from Allen&Kennedy Lecture 6 15-745 2005-8 1 Common loop optmzatons Hostng of loop-nvarant computatons pre-compute before

More information

Min Cut, Fast Cut, Polynomial Identities

Min Cut, Fast Cut, Polynomial Identities Randomzed Algorthms, Summer 016 Mn Cut, Fast Cut, Polynomal Identtes Instructor: Thomas Kesselhem and Kurt Mehlhorn 1 Mn Cuts n Graphs Lecture (5 pages) Throughout ths secton, G = (V, E) s a mult-graph.

More information

U.C. Berkeley CS294: Spectral Methods and Expanders Handout 8 Luca Trevisan February 17, 2016

U.C. Berkeley CS294: Spectral Methods and Expanders Handout 8 Luca Trevisan February 17, 2016 U.C. Berkeley CS94: Spectral Methods and Expanders Handout 8 Luca Trevsan February 7, 06 Lecture 8: Spectral Algorthms Wrap-up In whch we talk about even more generalzatons of Cheeger s nequaltes, and

More information

18-660: Numerical Methods for Engineering Design and Optimization

18-660: Numerical Methods for Engineering Design and Optimization 8-66: Numercal Methods for Engneerng Desgn and Optmzaton n L Department of EE arnege Mellon Unversty Pttsburgh, PA 53 Slde Overve lassfcaton Support vector machne Regularzaton Slde lassfcaton Predct categorcal

More information

Maximizing the number of nonnegative subsets

Maximizing the number of nonnegative subsets Maxmzng the number of nonnegatve subsets Noga Alon Hao Huang December 1, 213 Abstract Gven a set of n real numbers, f the sum of elements of every subset of sze larger than k s negatve, what s the maxmum

More information

Numerical Heat and Mass Transfer

Numerical Heat and Mass Transfer Master degree n Mechancal Engneerng Numercal Heat and Mass Transfer 06-Fnte-Dfference Method (One-dmensonal, steady state heat conducton) Fausto Arpno f.arpno@uncas.t Introducton Why we use models and

More information

Chapter 3 Describing Data Using Numerical Measures

Chapter 3 Describing Data Using Numerical Measures Chapter 3 Student Lecture Notes 3-1 Chapter 3 Descrbng Data Usng Numercal Measures Fall 2006 Fundamentals of Busness Statstcs 1 Chapter Goals To establsh the usefulness of summary measures of data. The

More information

CS 770G - Parallel Algorithms in Scientific Computing

CS 770G - Parallel Algorithms in Scientific Computing References CS 770G - Parallel Algorthms n Scentfc Computng Parallel Sortng Introducton to Parallel Computng Kumar, Grama, Gupta, Karyps, Benjamn Cummngs. A porton of the notes comes from Prof. J. Demmel

More information

Introduction. - The Second Lyapunov Method. - The First Lyapunov Method

Introduction. - The Second Lyapunov Method. - The First Lyapunov Method Stablty Analyss A. Khak Sedgh Control Systems Group Faculty of Electrcal and Computer Engneerng K. N. Toos Unversty of Technology February 2009 1 Introducton Stablty s the most promnent characterstc of

More information

Foundations of Arithmetic

Foundations of Arithmetic Foundatons of Arthmetc Notaton We shall denote the sum and product of numbers n the usual notaton as a 2 + a 2 + a 3 + + a = a, a 1 a 2 a 3 a = a The notaton a b means a dvdes b,.e. ac = b where c s an

More information

Lecture 14: Nov. 11 & 13

Lecture 14: Nov. 11 & 13 CIS 2168 Data Structures Fall 2014 Lecturer: Anwar Mamat Lecture 14: Nov. 11 & 13 Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 14.1 Sorting

More information

Introduction to Algorithms

Introduction to Algorithms Introducton to Algorthms 6.046J/8.40J Lecture 7 Prof. Potr Indyk Data Structures Role of data structures: Encapsulate data Support certan operatons (e.g., INSERT, DELETE, SEARCH) Our focus: effcency of

More information

Algorithms. Algorithms 2.2 MERGESORT. mergesort bottom-up mergesort sorting complexity divide-and-conquer ROBERT SEDGEWICK KEVIN WAYNE

Algorithms. Algorithms 2.2 MERGESORT. mergesort bottom-up mergesort sorting complexity divide-and-conquer ROBERT SEDGEWICK KEVIN WAYNE Algorithms ROBERT SEDGEWICK KEVIN WAYNE 2.2 MERGESORT Algorithms F O U R T H E D I T I O N mergesort bottom-up mergesort sorting complexity divide-and-conquer ROBERT SEDGEWICK KEVIN WAYNE http://algs4.cs.princeton.edu

More information

Stanford University CS359G: Graph Partitioning and Expanders Handout 4 Luca Trevisan January 13, 2011

Stanford University CS359G: Graph Partitioning and Expanders Handout 4 Luca Trevisan January 13, 2011 Stanford Unversty CS359G: Graph Parttonng and Expanders Handout 4 Luca Trevsan January 3, 0 Lecture 4 In whch we prove the dffcult drecton of Cheeger s nequalty. As n the past lectures, consder an undrected

More information

10-701/ Machine Learning, Fall 2005 Homework 3

10-701/ Machine Learning, Fall 2005 Homework 3 10-701/15-781 Machne Learnng, Fall 2005 Homework 3 Out: 10/20/05 Due: begnnng of the class 11/01/05 Instructons Contact questons-10701@autonlaborg for queston Problem 1 Regresson and Cross-valdaton [40

More information

Dynamic Programming. Preview. Dynamic Programming. Dynamic Programming. Dynamic Programming (Example: Fibonacci Sequence)

Dynamic Programming. Preview. Dynamic Programming. Dynamic Programming. Dynamic Programming (Example: Fibonacci Sequence) /24/27 Prevew Fbonacc Sequence Longest Common Subsequence Dynamc programmng s a method for solvng complex problems by breakng them down nto smpler sub-problems. It s applcable to problems exhbtng the propertes

More information

a b a In case b 0, a being divisible by b is the same as to say that

a b a In case b 0, a being divisible by b is the same as to say that Secton 6.2 Dvsblty among the ntegers An nteger a ε s dvsble by b ε f there s an nteger c ε such that a = bc. Note that s dvsble by any nteger b, snce = b. On the other hand, a s dvsble by only f a = :

More information

MLE and Bayesian Estimation. Jie Tang Department of Computer Science & Technology Tsinghua University 2012

MLE and Bayesian Estimation. Jie Tang Department of Computer Science & Technology Tsinghua University 2012 MLE and Bayesan Estmaton Je Tang Department of Computer Scence & Technology Tsnghua Unversty 01 1 Lnear Regresson? As the frst step, we need to decde how we re gong to represent the functon f. One example:

More information

Module 9. Lecture 6. Duality in Assignment Problems

Module 9. Lecture 6. Duality in Assignment Problems Module 9 1 Lecture 6 Dualty n Assgnment Problems In ths lecture we attempt to answer few other mportant questons posed n earler lecture for (AP) and see how some of them can be explaned through the concept

More information

Learning Theory: Lecture Notes

Learning Theory: Lecture Notes Learnng Theory: Lecture Notes Lecturer: Kamalka Chaudhur Scrbe: Qush Wang October 27, 2012 1 The Agnostc PAC Model Recall that one of the constrants of the PAC model s that the data dstrbuton has to be

More information

Yong Joon Ryang. 1. Introduction Consider the multicommodity transportation problem with convex quadratic cost function. 1 2 (x x0 ) T Q(x x 0 )

Yong Joon Ryang. 1. Introduction Consider the multicommodity transportation problem with convex quadratic cost function. 1 2 (x x0 ) T Q(x x 0 ) Kangweon-Kyungk Math. Jour. 4 1996), No. 1, pp. 7 16 AN ITERATIVE ROW-ACTION METHOD FOR MULTICOMMODITY TRANSPORTATION PROBLEMS Yong Joon Ryang Abstract. The optmzaton problems wth quadratc constrants often

More information

Finding Dense Subgraphs in G(n, 1/2)

Finding Dense Subgraphs in G(n, 1/2) Fndng Dense Subgraphs n Gn, 1/ Atsh Das Sarma 1, Amt Deshpande, and Rav Kannan 1 Georga Insttute of Technology,atsh@cc.gatech.edu Mcrosoft Research-Bangalore,amtdesh,annan@mcrosoft.com Abstract. Fndng

More information

5 The Rational Canonical Form

5 The Rational Canonical Form 5 The Ratonal Canoncal Form Here p s a monc rreducble factor of the mnmum polynomal m T and s not necessarly of degree one Let F p denote the feld constructed earler n the course, consstng of all matrces

More information

Problem Do any of the following determine homomorphisms from GL n (C) to GL n (C)?

Problem Do any of the following determine homomorphisms from GL n (C) to GL n (C)? Homework 8 solutons. Problem 16.1. Whch of the followng defne homomomorphsms from C\{0} to C\{0}? Answer. a) f 1 : z z Yes, f 1 s a homomorphsm. We have that z s the complex conjugate of z. If z 1,z 2

More information

On the Interval Zoro Symmetric Single-step Procedure for Simultaneous Finding of Polynomial Zeros

On the Interval Zoro Symmetric Single-step Procedure for Simultaneous Finding of Polynomial Zeros Appled Mathematcal Scences, Vol. 5, 2011, no. 75, 3693-3706 On the Interval Zoro Symmetrc Sngle-step Procedure for Smultaneous Fndng of Polynomal Zeros S. F. M. Rusl, M. Mons, M. A. Hassan and W. J. Leong

More information

Algorithm for Equal Distribution of Identical Elements on One Dimensional Field

Algorithm for Equal Distribution of Identical Elements on One Dimensional Field Algorthm for Equal Dstrbuton of Identcal Elements on One Dmensonal Feld Mate Boban, Alen Lovrenčć Unversty of Zagreb, Faculty of Organzaton and Informatcs, Varaždn, Croata {mboban,alovrenc}@fo.hr Mchael

More information

Problem Solving in Math (Math 43900) Fall 2013

Problem Solving in Math (Math 43900) Fall 2013 Problem Solvng n Math (Math 43900) Fall 2013 Week four (September 17) solutons Instructor: Davd Galvn 1. Let a and b be two nteger for whch a b s dvsble by 3. Prove that a 3 b 3 s dvsble by 9. Soluton:

More information

Perron Vectors of an Irreducible Nonnegative Interval Matrix

Perron Vectors of an Irreducible Nonnegative Interval Matrix Perron Vectors of an Irreducble Nonnegatve Interval Matrx Jr Rohn August 4 2005 Abstract As s well known an rreducble nonnegatve matrx possesses a unquely determned Perron vector. As the man result of

More information

Implementation and Detection

Implementation and Detection 1 December 18 2014 Implementaton and Detecton Htosh Matsushma Department of Economcs Unversty of Tokyo 2 Ths paper consders mplementaton of scf: Mechansm Desgn wth Unqueness CP attempts to mplement scf

More information

n α j x j = 0 j=1 has a nontrivial solution. Here A is the n k matrix whose jth column is the vector for all t j=0

n α j x j = 0 j=1 has a nontrivial solution. Here A is the n k matrix whose jth column is the vector for all t j=0 MODULE 2 Topcs: Lnear ndependence, bass and dmenson We have seen that f n a set of vectors one vector s a lnear combnaton of the remanng vectors n the set then the span of the set s unchanged f that vector

More information

4.1, 4.2: Analysis of Algorithms

4.1, 4.2: Analysis of Algorithms Overview 4.1, 4.2: Analysis of Algorithms Analysis of algorithms: framework for comparing algorithms and predicting performance. Scientific method.! Observe some feature of the universe.! Hypothesize a

More information

Two Methods to Release a New Real-time Task

Two Methods to Release a New Real-time Task Two Methods to Release a New Real-tme Task Abstract Guangmng Qan 1, Xanghua Chen 2 College of Mathematcs and Computer Scence Hunan Normal Unversty Changsha, 410081, Chna qqyy@hunnu.edu.cn Gang Yao 3 Sebel

More information

2.3 Nilpotent endomorphisms

2.3 Nilpotent endomorphisms s a block dagonal matrx, wth A Mat dm U (C) In fact, we can assume that B = B 1 B k, wth B an ordered bass of U, and that A = [f U ] B, where f U : U U s the restrcton of f to U 40 23 Nlpotent endomorphsms

More information

U.C. Berkeley CS294: Beyond Worst-Case Analysis Luca Trevisan September 5, 2017

U.C. Berkeley CS294: Beyond Worst-Case Analysis Luca Trevisan September 5, 2017 U.C. Berkeley CS94: Beyond Worst-Case Analyss Handout 4s Luca Trevsan September 5, 07 Summary of Lecture 4 In whch we ntroduce semdefnte programmng and apply t to Max Cut. Semdefnte Programmng Recall that

More information

Chapter 8 SCALAR QUANTIZATION

Chapter 8 SCALAR QUANTIZATION Outlne Chapter 8 SCALAR QUANTIZATION Yeuan-Kuen Lee [ CU, CSIE ] 8.1 Overvew 8. Introducton 8.4 Unform Quantzer 8.5 Adaptve Quantzaton 8.6 Nonunform Quantzaton 8.7 Entropy-Coded Quantzaton Ch 8 Scalar

More information

Chapter 5. Solution of System of Linear Equations. Module No. 6. Solution of Inconsistent and Ill Conditioned Systems

Chapter 5. Solution of System of Linear Equations. Module No. 6. Solution of Inconsistent and Ill Conditioned Systems Numercal Analyss by Dr. Anta Pal Assstant Professor Department of Mathematcs Natonal Insttute of Technology Durgapur Durgapur-713209 emal: anta.bue@gmal.com 1 . Chapter 5 Soluton of System of Lnear Equatons

More information

Affine transformations and convexity

Affine transformations and convexity Affne transformatons and convexty The purpose of ths document s to prove some basc propertes of affne transformatons nvolvng convex sets. Here are a few onlne references for background nformaton: http://math.ucr.edu/

More information

Complex Numbers Alpha, Round 1 Test #123

Complex Numbers Alpha, Round 1 Test #123 Complex Numbers Alpha, Round Test #3. Wrte your 6-dgt ID# n the I.D. NUMBER grd, left-justfed, and bubble. Check that each column has only one number darkened.. In the EXAM NO. grd, wrte the 3-dgt Test

More information

Hyper-Sums of Powers of Integers and the Akiyama-Tanigawa Matrix

Hyper-Sums of Powers of Integers and the Akiyama-Tanigawa Matrix 6 Journal of Integer Sequences, Vol 8 (00), Artcle 0 Hyper-Sums of Powers of Integers and the Ayama-Tangawa Matrx Yoshnar Inaba Toba Senor Hgh School Nshujo, Mnam-u Kyoto 60-89 Japan nava@yoto-benejp Abstract

More information

Physics 141. Lecture 14. Frank L. H. Wolfs Department of Physics and Astronomy, University of Rochester, Lecture 14, Page 1

Physics 141. Lecture 14. Frank L. H. Wolfs Department of Physics and Astronomy, University of Rochester, Lecture 14, Page 1 Physcs 141. Lecture 14. Frank L. H. Wolfs Department of Physcs and Astronomy, Unversty of Rochester, Lecture 14, Page 1 Physcs 141. Lecture 14. Course Informaton: Lab report # 3. Exam # 2. Mult-Partcle

More information

EEE 241: Linear Systems

EEE 241: Linear Systems EEE : Lnear Systems Summary #: Backpropagaton BACKPROPAGATION The perceptron rule as well as the Wdrow Hoff learnng were desgned to tran sngle layer networks. They suffer from the same dsadvantage: they

More information

Richard Socher, Henning Peters Elements of Statistical Learning I E[X] = arg min. E[(X b) 2 ]

Richard Socher, Henning Peters Elements of Statistical Learning I E[X] = arg min. E[(X b) 2 ] 1 Prolem (10P) Show that f X s a random varale, then E[X] = arg mn E[(X ) 2 ] Thus a good predcton for X s E[X] f the squared dfference s used as the metrc. The followng rules are used n the proof: 1.

More information

A Robust Method for Calculating the Correlation Coefficient

A Robust Method for Calculating the Correlation Coefficient A Robust Method for Calculatng the Correlaton Coeffcent E.B. Nven and C. V. Deutsch Relatonshps between prmary and secondary data are frequently quantfed usng the correlaton coeffcent; however, the tradtonal

More information

princeton univ. F 13 cos 521: Advanced Algorithm Design Lecture 3: Large deviations bounds and applications Lecturer: Sanjeev Arora

princeton univ. F 13 cos 521: Advanced Algorithm Design Lecture 3: Large deviations bounds and applications Lecturer: Sanjeev Arora prnceton unv. F 13 cos 521: Advanced Algorthm Desgn Lecture 3: Large devatons bounds and applcatons Lecturer: Sanjeev Arora Scrbe: Today s topc s devaton bounds: what s the probablty that a random varable

More information

Finding Primitive Roots Pseudo-Deterministically

Finding Primitive Roots Pseudo-Deterministically Electronc Colloquum on Computatonal Complexty, Report No 207 (205) Fndng Prmtve Roots Pseudo-Determnstcally Ofer Grossman December 22, 205 Abstract Pseudo-determnstc algorthms are randomzed search algorthms

More information

THE VIBRATIONS OF MOLECULES II THE CARBON DIOXIDE MOLECULE Student Instructions

THE VIBRATIONS OF MOLECULES II THE CARBON DIOXIDE MOLECULE Student Instructions THE VIBRATIONS OF MOLECULES II THE CARBON DIOXIDE MOLECULE Student Instructons by George Hardgrove Chemstry Department St. Olaf College Northfeld, MN 55057 hardgrov@lars.acc.stolaf.edu Copyrght George

More information

The Minimum Universal Cost Flow in an Infeasible Flow Network

The Minimum Universal Cost Flow in an Infeasible Flow Network Journal of Scences, Islamc Republc of Iran 17(2): 175-180 (2006) Unversty of Tehran, ISSN 1016-1104 http://jscencesutacr The Mnmum Unversal Cost Flow n an Infeasble Flow Network H Saleh Fathabad * M Bagheran

More information

Support Vector Machines

Support Vector Machines CS 2750: Machne Learnng Support Vector Machnes Prof. Adrana Kovashka Unversty of Pttsburgh February 17, 2016 Announcement Homework 2 deadlne s now 2/29 We ll have covered everythng you need today or at

More information

On the Best Case of Heapsort

On the Best Case of Heapsort JOURNAL OF ALGORITHMS 20, 20527 996 ARTICLE NO. 00 On the Best Case of Heapsort B. Bollobas Department of Pure Mathematcs, Unersty of Cambrdge, Cambrdge CB2 TN, Unted Kngdom T. I. Fenner Department of

More information

Week 5: Neural Networks

Week 5: Neural Networks Week 5: Neural Networks Instructor: Sergey Levne Neural Networks Summary In the prevous lecture, we saw how we can construct neural networks by extendng logstc regresson. Neural networks consst of multple

More information

COMPLEX NUMBERS AND QUADRATIC EQUATIONS

COMPLEX NUMBERS AND QUADRATIC EQUATIONS COMPLEX NUMBERS AND QUADRATIC EQUATIONS INTRODUCTION We know that x 0 for all x R e the square of a real number (whether postve, negatve or ero) s non-negatve Hence the equatons x, x, x + 7 0 etc are not

More information

STAT 3008 Applied Regression Analysis

STAT 3008 Applied Regression Analysis STAT 3008 Appled Regresson Analyss Tutoral : Smple Lnear Regresson LAI Chun He Department of Statstcs, The Chnese Unversty of Hong Kong 1 Model Assumpton To quantfy the relatonshp between two factors,

More information

Math 217 Fall 2013 Homework 2 Solutions

Math 217 Fall 2013 Homework 2 Solutions Math 17 Fall 013 Homework Solutons Due Thursday Sept. 6, 013 5pm Ths homework conssts of 6 problems of 5 ponts each. The total s 30. You need to fully justfy your answer prove that your functon ndeed has

More information

Some Consequences. Example of Extended Euclidean Algorithm. The Fundamental Theorem of Arithmetic, II. Characterizing the GCD and LCM

Some Consequences. Example of Extended Euclidean Algorithm. The Fundamental Theorem of Arithmetic, II. Characterizing the GCD and LCM Example of Extended Eucldean Algorthm Recall that gcd(84, 33) = gcd(33, 18) = gcd(18, 15) = gcd(15, 3) = gcd(3, 0) = 3 We work backwards to wrte 3 as a lnear combnaton of 84 and 33: 3 = 18 15 [Now 3 s

More information

1. Estimation, Approximation and Errors Percentages Polynomials and Formulas Identities and Factorization 52

1. Estimation, Approximation and Errors Percentages Polynomials and Formulas Identities and Factorization 52 ontents ommonly Used Formulas. Estmaton, pproxmaton and Errors. Percentages. Polynomals and Formulas 8. Identtes and Factorzaton. Equatons and Inequaltes 66 6. Rate and Rato 8 7. Laws of Integral Indces

More information

Computing Correlated Equilibria in Multi-Player Games

Computing Correlated Equilibria in Multi-Player Games Computng Correlated Equlbra n Mult-Player Games Chrstos H. Papadmtrou Presented by Zhanxang Huang December 7th, 2005 1 The Author Dr. Chrstos H. Papadmtrou CS professor at UC Berkley (taught at Harvard,

More information