Central Algorithmic Techniques. Iterative Algorithms

Size: px
Start display at page:

Download "Central Algorithmic Techniques. Iterative Algorithms"

Transcription

1 Central Algorithmic Techniques Iterative Algorithms

2 Code Representation of an Algorithm class InsertionSortAlgorithm extends SortAlgorithm { void sort(int a[]) throws Exception { for (int i = 1; i < a.length; i++) { int j = i; int B = a[i]; while ((j > 0) && (a[j-1] > B)) { a[j] = a[j-1]; j--; } a[j] = B; }} COSC 3101, PROF. J. ELDER 2 Pros and Cons?

3 Code Representation of an Algorithm Pros: Runs on computers Precise and succinct Cons: I am not a computer I need a higher level of intuition. Prone to bugs Language dependent We will focus on a more natural, intuitive and powerful method for developing, analyzing and proving correctness of iterative algorithms. This method will be based on loop invariants. COSC 3101, PROF. J. ELDER 3

4 Iterative Algorithms Take one step at a time towards the final destination loop (done) take step end loop COSC 3101, PROF. J. ELDER 4

5 Loop Invariants A good way to structure many programs: Store the key information you currently know in some data representation. In the main loop, take a step forward towards destination by making a simple change to this data. COSC 3101, PROF. J. ELDER 5

6 The Getting to School Problem COSC 3101, PROF. J. ELDER 6

7 Problem Specification Pre-condition: location of home and school Post-condition: Traveled from home to school COSC 3101, PROF. J. ELDER 7

8 General Principle Do not worry about the entire computation. Take one step at a time! COSC 3101, PROF. J. ELDER 8

9 A Measure of Progress 75 km to school 79 km to school COSC 3101, PROF. J. ELDER 9

10 Safe Locations Algorithm specifies from which locations it knows how to step. COSC 3101, PROF. J. ELDER 10

11 Loop Invariant The computation is presently in a safe location. May or may not be true. COSC 3101, PROF. J. ELDER 11

12 Defining Algorithm From every safe location, define one step towards school. COSC 3101, PROF. J. ELDER 12

13 Take a step What is required of this step? COSC 3101, PROF. J. ELDER 13

14 Maintain Loop Invariant If the computation is in a safe location, it does not step into an unsafe one. Can we be assured that the computation will always be in a safe location? No. What if it is not initially true? COSC 3101, PROF. J. ELDER 14

15 Establishing Loop Invariant From the Pre-Conditions on the input instance we must establish the loop invariant. COSC 3101, PROF. J. ELDER 15

16 Maintain Loop Invariant Suppose that We start in a safe location (pre-condition) If we are in a safe location, we always step to another safe location (loop invariant) Can we be assured that the computation will always be in a safe location? By what principle? COSC 3101, PROF. J. ELDER 16

17 Maintain Loop Invariant By Induction the computation will always be in a safe location. S(0) isi, ( ) isi, ( ) Si ( + 1) COSC 3101, PROF. J. ELDER 17

18 Ending The Algorithm Define Exit Condition Exit Termination: With sufficient progress, the exit condition will be met. 0 km Exit When we exit, we know exit condition is true loop invariant is true from these we must establish the post conditions. Exit COSC 3101, PROF. J. ELDER 18

19 Let s Recap COSC 3101, PROF. J. ELDER 19

20 Designing an Algorithm Define Problem Define Loop Invariants Define Measure of Progress 79 km to school Define Step Define Exit Condition Maintain Loop Inv Exit Exit Make Progress Initial Conditions Ending Exit 79 km 75 km km 0 km Exit Exit COSC 3101, PROF. J. ELDER 20

21 Simple Example Insertion Sort Algorithm

22 Code Representation of an Algorithm class InsertionSortAlgorithm extends SortAlgorithm { void sort(int a[]) throws Exception { for (int i = 1; i < a.length; i++) { int j = i; int B = a[i]; while ((j > 0) && (a[j-1] > B)) { a[j] = a[j-1]; j--; } a[j] = B; }} COSC 3101, PROF. J. ELDER 22

23 Higher Level Abstract View Representation of an Algorithm 5 km 9 km COSC 3101, PROF. J. ELDER 23

24 Problem Specification Pre-condition: The input is a list of n values with the same value possibly repeated. Post-condition: The output is a list consisting of the same n values in non-decreasing order ,23,25,30,31,52,62,79,88, COSC 3101, PROF. J. ELDER 24

25 Define Loop Invariant Some subset of the elements are sorted The remaining elements are off to the side ,23,25,30,31,52,62,79,88,98 23,31,52, COSC 3101, PROF. J. ELDER 25

26 Defining Measure of Progress 23,31,52, elements to school COSC 3101, PROF. J. ELDER 26

27 Define Step Select arbitrary element from side. Insert it where it belongs. 23,31,52, ,31,52,62, COSC 3101, PROF. J. ELDER 27

28 Making progress while maintaining the loop invariant 79 km 75 km Exit 23,31,52, elements to school 23,31,52,62, COSC 3101, PROF. J. ELDER 28 Sorted sublist 5 elements to school

29 Beginning & km 0 km Exit Exit Ending n elements to school 14,23,25,30,31,52,62,79,88,98 0 elements to school 14,23,25,30,31,52,62,79,88,98 COSC 3101, PROF. J. ELDER 29

30 Running Time Inserting an element into a list of size i takes θ(i) time. Total = n = θ(n 2 ) 23,31,52, COSC 3101, PROF. J. ELDER 30 23,31,52,62,

31 Ok: I know you knew Insertion Sort But hopefully you are beginning to appreciate the value of loop invariants for describing algorithms The loop invariant is an example of a more general thing called an assertion. COSC 3101, PROF. J. ELDER 31

32 Assertions in Algorithms

33 Purpose of Assertions Useful for thinking about algorithms developing describing proving correctness COSC 3101, PROF. J. ELDER 33

34 Definition of Assertions An assertion is a statement about the current state of the data structure that is either true or false. e.g., the amount in your bank account is not negative. COSC 3101, PROF. J. ELDER 34

35 Definition of Assertions It is made at some particular point during the execution of an algorithm. If it is false, then something has gone wrong in the logic of the algorithm. COSC 3101, PROF. J. ELDER 35

36 Definition of Assertions An assertion is not a task for the algorithm to perform. It is only a comment that is added for the benefit of the reader. COSC 3101, PROF. J. ELDER 36

37 Specifying a Computational Problem Example of Assertions Preconditions: Any assumptions that must be true about the input instance. Postconditions: The statement of what must be true when the algorithm/program returns. COSC 3101, PROF. J. ELDER 37

38 Definition of Correctness <PreCond> & <code> <PostCond> If the input meets the preconditions, then the output must meet the postconditions. If the input does not meet the preconditions, then nothing is required. COSC 3101, PROF. J. ELDER 38

39 <assertion 0 > if( <condition 1 > ) then else code <1,true> code <1,false> end if <assertion 1 > <assertion r-1 > if( <condition r > ) then else code <r,true> code <r,false> end if <assertion r > An Example: A Sequence of Assertions <assertion 0 > any <conditions> code COSC 3101, PROF. J. ELDER 39 Definition of Correctness <assertion r > How is this proved? Must check 2 r different settings of <conditions> paths through the code. Is there a faster way?

40 <assertion 0 > if( <condition 1 > ) then An Example: A Sequence of Assertions else code <1,true> code <1,false> end if <assertion 1 > <assertion r-1 > if( <condition r > ) then else code <r,true> code <r,false> end if Step 1 <assertion 0 > <condition 1 > code <1,true> <assertion 1 > <assertion 0 > <condition 1 > code <1,false> <assertion 1 > <assertion r > COSC 3101, PROF. J. ELDER 40

41 <assertion 0 > if( <condition 1 > ) then An Example: A Sequence of Assertions else code <1,true> code <1,false> end if <assertion 1 > <assertion r-1 > if( <condition r > ) then else code <r,true> code <r,false> end if Step 2 <assertion 1 > <condition 2 > code <2,true> <assertion 2 > <assertion 1 > <condition 2 > code <2,false> <assertion 2 > <assertion r > COSC 3101, PROF. J. ELDER 41

42 <assertion 0 > if( <condition 1 > ) then An Example: A Sequence of Assertions else code <1,true> code <1,false> end if <assertion 1 > <assertion r-1 > if( <condition r > ) then else code <r,true> code <r,false> end if Step r <assertion r-1 > <condition r > code <r,true> <assertion r > <assertion r-1 > <condition r > code <r,false> <assertion r > <assertion r > COSC 3101, PROF. J. ELDER 42

43 <assertion 0 > A Sequence of Assertions if( <condition 1 > ) then else code <1,true> code <1,false> end if <assertion 1 > <assertion r-1 > if( <condition r > ) then else code <r,true> code <r,false> end if We have reduced the number of cases r that must be considered from 2 to r. Step r <assertion r-1 > <condition r > code <r,true> <assertion r > <assertion r-1 > <condition r > code <r,false> <assertion r > <assertion r > COSC 3101, PROF. J. ELDER 43

44 <precond> codea loop <loop-invariant> exit when <exit Cond> codeb endloop codec <postcond> Another Example: A Loop Type of Algorithm: Iterative Type of Assertion: Loop Invariants COSC 3101, PROF. J. ELDER 44

45 <precond> codea loop <loop-invariant> exit when <exit Cond> codeb endloop codec <postcond> Iterative Algorithms Loop Invariants Definition of Correctness? COSC 3101, PROF. J. ELDER 45

46 <precond> codea loop <loop-invariant> exit when <exit Cond> codeb endloop codec <postcond> Iterative Algorithms Loop Invariants <precond> any <conditions> code Definition of Correctness How is this proved? <postcond> COSC 3101, PROF. J. ELDER 46

47 <precond> codea loop <loop-invariant> exit when <exit Cond> codeb endloop codec <postcond> <precond> any <conditions> code The computation may go around the loop an arbitrary number of times. Is there a faster way? COSC 3101, PROF. J. ELDER 47 Iterative Algorithms Loop Invariants Definition of Correctness <postcond>

48 <precond> codea loop <loop-invariant> exit when <exit Cond> codeb endloop codec <postcond> Iterative Algorithms Loop Invariants <precond> codea Step 0 <loop-invariant COSC 3101, PROF. J. ELDER 48

49 <precond> codea loop <loop-invariant> exit when <exit Cond> codeb endloop codec <postcond> Iterative Algorithms Loop Invariants <loop-invariant> <exit Cond> codeb Step 1 <loop-invariant COSC 3101, PROF. J. ELDER 49

50 <precond> codea loop <loop-invariant> exit when <exit Cond> codeb endloop codec <postcond> Iterative Algorithms Loop Invariants <loop-invariant> <exit Cond> codeb Step 2 <loop-invariant COSC 3101, PROF. J. ELDER 50

51 <precond> codea loop <loop-invariant> exit when <exit Cond> codeb endloop codec <postcond> Iterative Algorithms Loop Invariants <loop-invariant> <exit Cond> codeb Step 3 <loop-invariant COSC 3101, PROF. J. ELDER 51

52 <precond> codea loop <loop-invariant> exit when <exit Cond> codeb endloop codec <postcond> COSC 3101, PROF. J. ELDER 52 Iterative Algorithms Loop Invariants <loop-invariant> <exit Cond> codeb Step i <loop-invariant All these steps are the same and therefore only need be done once!

53 <precond> codea loop <loop-invariant> exit when <exit Cond> codeb endloop codec <postcond> Iterative Algorithms Loop Invariants <loop-invariant> <exit Cond> codec Last Step <postcond> COSC 3101, PROF. J. ELDER 53

54 Partial Correctness Establishing Loop Invariant <precond> codea <loop-invariant> Maintaining Loop Invariant Exit Clean up loose ends Exit <loop-invariant> <exit Cond> codeb <loop-invariant> <exit Cond> codec Proves that IF the program terminates then it works <PreCond> & <code> <PostCond> COSC 3101, PROF. J. ELDER 54 <loop-invariant> <postcond>

55 Algorithm Termination Measure of progress km 0 km Exit 79 km 75 km COSC 3101, PROF. J. ELDER 55

56 Algorithm Correctness Partial Correctness + Termination Correctness COSC 3101, PROF. J. ELDER 56

57 Designing Loop Invariants Coming up with the loop invariant is the hardest part of designing an algorithm. It requires practice, perseverance, and insight. Yet from it the rest of the algorithm follows easily COSC 3101, PROF. J. ELDER 57

58 Don t start coding You must design a working algorithm first. COSC 3101, PROF. J. ELDER 58

59 Exemplification: Try solving the problem on small input examples. COSC 3101, PROF. J. ELDER 59

60 Start with Small Steps What basic steps might you follow to make some kind of progress towards the answer? Describe or draw a picture of what the data structure might look like after a number of these steps. COSC 3101, PROF. J. ELDER 60

61 Picture from the Middle Leap into the middle of the algorithm. What would you like your data structure to look like when you are half done? COSC 3101, PROF. J. ELDER 61

62 Ask for 100% Pretend that a genie has granted your wish. You are now in the middle of your computation and your dream loop invariant is true. COSC 3101, PROF. J. ELDER 62

63 Ask for 100% Maintain the Loop Invariant: From here, are you able to take some computational steps that will make progress while maintaining the loop invariant? COSC 3101, PROF. J. ELDER 63

64 Ask for 100% If you can maintain the loop invariant, great. If not, Too Weak: If your loop invariant is too weak, then the genie has not provided you with everything you need to move on. Too Strong: If your loop invariant is too strong, then you will not be able to establish it initially or maintain it. COSC 3101, PROF. J. ELDER 64

65 Differentiating between Iterations x=x+2 Meaningful as code False as a mathematical statement x = x i = value at the beginning of the iteration x = x i+1 = new value after going around the loop one more time. x'' = x'+2 Meaningful as a mathematical statement COSC 3101, PROF. J. ELDER 65

66 Loop Invariants for Iterative Algorithms Three Search Examples

67 Define Problem: Binary Search PreConditions Key 25 Sorted List PostConditions Find key in list (if there) COSC 3101, PROF. J. ELDER 67

68 Define Loop Invariant Maintain a sublist. If the key is contained in the original list, then the key is contained in the sublist. key COSC 3101, PROF. J. ELDER 68

69 Define Step Make Progress Maintain Loop Invariant key COSC 3101, PROF. J. ELDER 69

70 Define Step Cut sublist in half. Determine which half the key would be in. Keep that half. key 25 mid If key mid, then key is in left half. COSC 3101, PROF. J. ELDER 70 If key > mid, then key is in right half.

71 Define Step It is faster not to check if the middle element is the key. Simply continue. key If key mid, then key is in left half. COSC 3101, PROF. J. ELDER 71 If key > mid, then key is in right half.

72 Make Progress Exit 79 km 75 km The size of the list becomes smaller km km COSC 3101, PROF. J. ELDER 72

73 Initial Conditions km key n km The sublist is the entire original list. If the key is contained in the original list, then the key is contained in the sublist. COSC 3101, PROF. J. ELDER 73

74 Ending Algorithm Exit key km If the key is contained in the original list, then the key is contained in the sublist. Sublist contains one element. Exit If the key is contained in the original list, then the key is at this location. COSC 3101, PROF. J. ELDER 74

75 If key not in original list If the key is contained in the original list, then the key is contained in the sublist. Loop invariant true, even if the key is not in the list. key If the key is contained in the original list, then the key is at this location. Conclusion still solves the problem. Simply check this one location for the key. COSC 3101, PROF. J. ELDER 75

76 Running Time The sublist is of size n, n / 2, n / 4, n / 8,,1 Each step θ(1) time. Total = θ(log n) key If key mid, then key is in left half. COSC 3101, PROF. J. ELDER 76 If key > mid, then key is in right half.

77 BinarySearch(A[1..n], key) <precondition>: A[1..n] is sorted in non-decreasing order <postcondition>: If key is in A[1..n], algorithm returns its location p = 1, q = n while q > p < loop-invariant>: If key is in A[1..n], then key is in A[p.. q] p + q mid = 2 if key A[ mid ] q = mid else p = mid + 1 end end if key = A[ p] return( p) else return("key not in list") end COSC 3101, PROF. J. ELDER 77

78 Algorithm Definition Completed Define Problem Define Loop Invariants Define Measure of Progress 79 km to school Define Step Define Exit Condition Maintain Loop Inv Exit Exit Make Progress Initial Conditions Ending Exit 79 km 75 km km 0 km Exit Exit COSC 3101, PROF. J. ELDER 78

79 Simple, right? Although the concept is simple, binary search is notoriously easy to get wrong. Why is this? COSC 3101, PROF. J. ELDER 79

80 The Devil in the Details The basic idea behind binary search is easy to grasp. It is then easy to write pseudocode that works for a typical case. Unfortunately, it is equally easy to write pseudocode that fails on the boundary conditions. COSC 3101, PROF. J. ELDER 80

81 The Devil in the Details if key A[ mid ] q = mid else p = mid + 1 end or if key < A[ mid ] q = mid else p = mid + 1 end What condition will break the loop invariant? COSC 3101, PROF. J. ELDER 81

82 The Devil in the Details key 36 mid Code: key A[mid] select right half Bug!! COSC 3101, PROF. J. ELDER 82

83 The Devil in the Details if key A[ mid ] q = mid else p = mid + 1 end if key < A[ mid ] q = mid 1 else p = mid end if key < A[ mid ] q = mid else p = mid + 1 end OK OK Not OK!! COSC 3101, PROF. J. ELDER 83

84 The Devil in the Details mid p+ q = 2 or mid p+ q = 2 key Shouldn t matter, right? Select mid p + q = 2 COSC 3101, PROF. J. ELDER 84

85 The Devil in the Details key 25 mid If key mid, then key is in left half. If key > mid, then key is in right half. COSC 3101, PROF. J. ELDER 85

86 The Devil in the Details key 25 mid If key mid, then key is in left half. COSC 3101, PROF. J. ELDER 86 If key > mid, then key is in right half.

87 The Devil in the Details Exit 79 km 75 km Another bug! key 25 mid No progress toward goal: Loops Forever! If key mid, then key is in left half. COSC 3101, PROF. J. ELDER 87 If key > mid, then key is in right half.

88 The Devil in the Details p + q mid = 2 if key A[ mid ] q = mid else p = mid + 1 end p + q mid = 2 if key < A[ mid ] q = mid 1 else p = mid end p + q mid = 2 if key A[ mid ] q = mid else p = mid + 1 end OK OK Not OK!! COSC 3101, PROF. J. ELDER 88

89 End of Lecture 4 March 16, 2009

90 Announcements Typo on Assignment 1: The last problem is worth 16 marks, not 30 marks. Check out the York programming contests. The first contest of the Winter term will take place this Friday March 20, 15:00-17:00 in CSEB COSC 3101, PROF. J. ELDER 90

91 How Many Possible Algorithms? p + q mid = 2 if key A[ mid ] q = mid else p = mid + 1 end p + q o r mid =? 2 or if key < A[ mid ]? or q = mid 1 else end p = mid COSC 3101, PROF. J. ELDER 91

92 Alternative Algorithm: Less Efficient but More Clear BinarySearch(A[1..n], key) <precondition>: A[1..n] is sorted in non-decreasing order <postcondition>: If key is in A[1..n], algorithm returns its location p = 1, q = n while q > p < loop-invariant>: If key is in A[1..n], then key is in A[p..q] p + q mid = 2 if key = A[ mid ] return(mid) elseif key < A[ mid ] q = mid 1 else p = mid + 1 end end if key = A[ p] return( p) else end return("key not in list" ) COSC 3101, PROF. J. ELDER 92 Still Θ(log n), but with slightly larger constant.

93 Moral Use the loop invariant method to think about algorithms. Be careful with your definitions. Be sure that the loop invariant is always maintained. Be sure progress is always made. Having checked the typical cases, pay particular attention to boundary conditions and the end game. Sometimes it is worth paying a little in efficiency for clear, correct code. COSC 3101, PROF. J. ELDER 93

94 Loop Invariants for Iterative Algorithms A Second Search Example: The Binary Search Tree

95 Define Problem: Binary Search Tree PreConditions Key 25 A binary search tree PostConditions Find key in BST (if there). COSC 3101, PROF. J. ELDER 95

96 Binary Search Tree All nodes in left subtree Any node All nodes in right subtree COSC 3101, PROF. J. ELDER

97 Maintain a sub-tree. Define Loop Invariant If the key is contained in the original tree, then the key is contained in the sub-tree. key COSC 3101, PROF. J. ELDER 97

98 Define Step Cut sub-tree in half. Determine which half the key would be in. Keep that half. key If key < root, then key is in left half. If key = root, then key is found If key > root, then key is in right half. COSC 3101, PROF. J. ELDER 98

99 Card Trick A volunteer, please. COSC 3101, PROF. J. ELDER 99

100 Loop Invariants for Iterative Algorithms A Third Search Example: A Card Trick

101 Pick a Card Done COSC 3101, PROF. J. ELDER 101

102 Loop Invariant: The selected card is one of these. COSC 3101, PROF. J. ELDER 102

103 Which column? left COSC 3101, PROF. J. ELDER 103

104 Loop Invariant: The selected card is one of these. COSC 3101, PROF. J. ELDER 104

105 Selected column is placed in the middle COSC 3101, PROF. J. ELDER 105

106 I will rearrange the cards COSC 3101, PROF. J. ELDER 106

107 Relax Loop Invariant: I will remember the same about each column. COSC 3101, PROF. J. ELDER 107

108 Which column? right COSC 3101, PROF. J. ELDER 108

109 Loop Invariant: The selected card is one of these. COSC 3101, PROF. J. ELDER 109

110 Selected column is placed in the middle COSC 3101, PROF. J. ELDER 110

111 I will rearrange the cards COSC 3101, PROF. J. ELDER 111

112 Which column? left COSC 3101, PROF. J. ELDER 112

113 Loop Invariant: The selected card is one of these. COSC 3101, PROF. J. ELDER 113

114 Selected column is placed in the middle COSC 3101, PROF. J. ELDER 114

115 Here is your card. Wow! COSC 3101, PROF. J. ELDER 115

116 Ternary Search Loop Invariant: selected card in central subset of cards i 1 Size of subset = n / 3 where n = total number of cards i = iteration index How many iterations are required to guarantee success? COSC 3101, PROF. J. ELDER 116

117 Loop Invariants for Iterative Algorithms A Fourth Example: Partitioning (Not a search problem: can be used for sorting, e.g., Quicksort)

118 The Partitioning Problem Input: x=52 Output: < Problem: Partition a list into a set of small values and a set of large values. COSC 3101, PROF. J. ELDER 118

119 Precise Specification Precondit ion: Ap [... r] is an arbitrary list of values. x= Ar [ ] is the pivot. p r Postcondition: A is rearranged such that A[ p... q 1] A[ q] = x < A[ q r] for some q. p q r COSC 3101, PROF. J. ELDER 119

120 Loop Invariant 3 subsets are maintained One containing values less than or equal to the pivot One containing values greater than the pivot One containing values yet to be processed COSC 3101, PROF. J. ELDER 120

121 Maintaining Loop Invariant Consider element at location j If greater than pivot, incorporate into > set by incrementing j. If less than or equal to pivot, incorporate into set by swapping with element at location i+1 and incrementing both i and j. Measure of progress: size of unprocessed set. COSC 3101, PROF. J. ELDER 121

122 Maintaining Loop Invariant COSC 3101, PROF. J. ELDER 122

123 Establishing Loop Invariant COSC 3101, PROF. J. ELDER 123

124 Establishing Postcondition = j on exit Exhaustive on exit COSC 3101, PROF. J. ELDER 124

125 Establishing Postcondition COSC 3101, PROF. J. ELDER 125

126 An Example COSC 3101, PROF. J. ELDER 126

127 Running Time Each iteration takes θ(1) time Total = θ(n) or COSC 3101, PROF. J. ELDER 127

128 Algorithm Definition Completed Define Problem Define Loop Invariants Define Measure of Progress 79 km to school Define Step Define Exit Condition Maintain Loop Inv Exit Exit Make Progress Initial Conditions Ending Exit 79 km 75 km km 0 km Exit Exit COSC 3101, PROF. J. ELDER 128

129 More Examples of Iterative Algorithms Using Constraints on Input to Achieve Linear- Time Sorting

130 Recall: InsertionSort nn ( + 1) n 2 Worst case (reverse order): tj = j : j = 1 T( n) θ( n ) j = 2 2 COSC 3101, PROF. J. ELDER 130

131 Recall: MergeSort COSC 3101, PROF. J. ELDER 131 Tn ( ) θ( nlog n)

132 Comparison Sorts InsertionSort and MergeSort are examples of (stable) Comparison Sort algorithms. QuickSort is another example we will study shortly. Comparison Sort algorithms sort the input by successive comparison of pairs of input elements. Comparison Sort algorithms are very general: they make no assumptions about the values of the input elements. COSC 3101, PROF. J. ELDER 132

133 Comparison Sorts 2 InsertionSort is θ( n ). MergeSort is θ( nlog n). Can we do better? COSC 3101, PROF. J. ELDER 133

134 Comparison Sort: Decision Trees Example: Sorting a 3-element array A[1..3] COSC 3101, PROF. J. ELDER 134

135 Comparison Sort Worst-case time is equal to the height of the binary decision tree. The height of the tree is the log of the number of leaves. The leaves of the tree represent all possible permutations of the input. How many are there? ( ) log n! Ω( nlog n) Thus MergeSort is asymptotically optimal. COSC 3101, PROF. J. ELDER 135

136 Linear Sorts? Comparison sorts are very general, but are Ω( nlog n) Faster sorting may be possible if we can constrain the nature of the input. COSC 3101, PROF. J. ELDER 136

137 Example 1. Counting Sort Counting Sort applies when the elements to be sorted come from a finite (and preferably small) set. For example, the elements to be sorted are integers in the range [0 k-1], for some fixed integer k. We can then create an array V[0 k-1] and use it to count the number of elements with each value [0 k-1]. Then each input element can be placed in exactly the right place in the output array in constant time. COSC 3101, PROF. J. ELDER 137

138 Counting Sort Input: Output: Input: N records with integer keys between [0 3]. Output: Stable sorted keys. Algorithm: Count frequency of each key value to determine transition locations Go through the records in order putting them where they go. COSC 3101, PROF. J. ELDER 138

139 CountingSort Input: Output: Index: Stable sort: If two keys are the same, their order does not change. Thus the 4 th record in input with digit 1 must be the 4 th record in output with digit 1. It belongs at output index 8, because 8 records go before it ie, 5 records with a smaller digit & 3 records with the same digit Count These! COSC 3101, PROF. J. ELDER 139

140 Input: Output: CountingSort Index: Value v: # of records with digit v: N records. Time to count? Θ(N) COSC 3101, PROF. J. ELDER 140

141 Input: Output: CountingSort Index: Value v: # of records with digit v: # of records with digit < v: N records, k different values. Time to count? Θ(k) COSC 3101, PROF. J. ELDER 141

142 CountingSort Input: Output: Index: Value v: # of records with digit < v: = location of first record with digit v COSC 3101, PROF. J. ELDER 142

143 CountingSort Input: Output: Index: 0? Value v: Location of first record with digit v Algorithm: Go through the records in order putting them where they go. COSC 3101, PROF. J. ELDER 143

144 Loop Invariant The first i-1 keys have been placed in the correct locations in the output array The auxiliary data structure v indicates the location at which to place the i th key for each possible key value from [1..k-1]. COSC 3101, PROF. J. ELDER 144

145 CountingSort Input: Output: Index: Value v: Location of next record with digit v Algorithm: Go through the records in order putting them where they go. COSC 3101, PROF. J. ELDER 145

146 CountingSort Input: Output: 0 1 Index: Value v: Location of next record with digit v Algorithm: Go through the records in order putting them where they go. COSC 3101, PROF. J. ELDER 146

147 CountingSort Input: Output: Index: Value v: Location of next record with digit v Algorithm: Go through the records in order putting them where they go. COSC 3101, PROF. J. ELDER 147

148 CountingSort Input: Output: Index: Value v: Location of next record with digit v Algorithm: Go through the records in order putting them where they go. COSC 3101, PROF. J. ELDER 148

149 CountingSort Input: Output: Index: Value v: Location of next record with digit v Algorithm: Go through the records in order putting them where they go. COSC 3101, PROF. J. ELDER 149

150 CountingSort Input: Output: Index: Value v: Location of next record with digit v Algorithm: Go through the records in order putting them where they go. COSC 3101, PROF. J. ELDER 150

151 CountingSort Input: Output: Index: Value v: Location of next record with digit v Algorithm: Go through the records in order putting them where they go. COSC 3101, PROF. J. ELDER 151

152 CountingSort Input: Output: Index: Value v: Location of next record with digit v Algorithm: Go through the records in order putting them where they go. COSC 3101, PROF. J. ELDER 152

153 CountingSort Input: Output: Index: Value v: Location of next record with digit v Algorithm: Go through the records in order putting them where they go. COSC 3101, PROF. J. ELDER 153

154 CountingSort Input: Output: Index: Value v: Location of next record with digit v Algorithm: Go through the records in order putting them where they go. COSC 3101, PROF. J. ELDER 154

155 CountingSort Input: Output: Index: Value v: Location of next record with digit v Algorithm: Go through the records in order putting them where they go. COSC 3101, PROF. J. ELDER 155

156 CountingSort Input: Output: Index: Value v: Location of next record with digit v Algorithm: Go through the records in order putting them where they go. COSC 3101, PROF. J. ELDER 156

157 CountingSort Input: Output: Index: Value v: Location of next record with digit v Algorithm: Go through the records in order putting them where they go. COSC 3101, PROF. J. ELDER 157

158 CountingSort Input: Output: Index: Value v: Location of next record with digit v Time Total = Θ(N) Θ(N+k) COSC 3101, PROF. J. ELDER 158

159 Input: A of stack of N punch cards. Each card contains d digits. Each digit between [0 k-1] Output: Sorted cards. Digit Sort: Select one digit Example 2. RadixSort Separate cards into k piles based on selected digit (e.g., Counting Sort). Stable sort: If two cards are the same for that digit, their order does not change COSC 3101, PROF. J. ELDER 159

160 RadixSort Sort wrt which digit first? The most significant Sort wrt which digit Second? The next most significant All meaning in first sort lost. COSC 3101, PROF. J. ELDER 160

161 RadixSort Sort wrt which digit first? The least significant Sort wrt which digit Second? The next least significant COSC 3101, PROF. J. ELDER 161

162 RadixSort Sort wrt which digit first? The least significant Sort wrt which digit Second? The next least significant COSC 3101, PROF. J. ELDER 162 Is sorted wrt least sig. 2 digits.

163 RadixSort i+1 Is sorted wrt first i digits. Sort wrt i+1st digit COSC 3101, PROF. J. ELDER 163 Is sorted wrt first i+1 digits. These are in the correct order because sorted wrt high order digit

164 RadixSort i+1 Is sorted wrt first i digits. Sort wrt i+1st digit COSC 3101, PROF. J. ELDER 164 Is sorted wrt first i+1 digits. These are in the correct order because was sorted & stable sort left sorted

165 Loop Invariant The keys have been correctly stable-sorted with respect to the i-1 least-significant digits. COSC 3101, PROF. J. ELDER 165

166 Running Time Running time is Θ ( d( n + k)) Where d = # of digits in each number n = # of elements to be sorted k = # of possible values for each digit COSC 3101, PROF. J. ELDER 166

167 Example 3. Bucket Sort Applicable if input is constrained to finite interval, e.g., [0 1). If input is random and uniformly distributed, expected run time is Θ(n). COSC 3101, PROF. J. ELDER 167

168 Bucket Sort COSC 3101, PROF. J. ELDER 168

169 Loop Invariants Loop 1 The first i-1 keys have been correctly placed into buckets of width 1/n. Loop 2 The keys within each of the first i-1 buckets have been correctly stable-sorted. COSC 3101, PROF. J. ELDER 169

170 PseudoCode Expected Running Time Θ(1) Θ(1) Θ( n) Θ( n) n COSC 3101, PROF. J. ELDER 170

171 Examples of Iterative Algorithms Binary Search Partitioning Insertion Sort Counting Sort Radix Sort Bucket Sort Which can be made stable? Which sort in place? How about MergeSort? COSC 3101, PROF. J. ELDER 171

172 End of Iterative Algorithms

More Examples and Applications on AVL Tree

More Examples and Applications on AVL Tree CSCI2100 Tutorial 11 Jianwen Zhao Department of Computer Science and Engineering The Chinese University of Hong Kong Adapted from the slides of the previous offerings of the course Recall in lectures we

More information

Chapter 3 Software Packages to Install How to Set Up Python Eclipse How to Set Up Eclipse... 42

Chapter 3 Software Packages to Install How to Set Up Python Eclipse How to Set Up Eclipse... 42 Table of Contents Preface..... 21 About the Authors... 23 Acknowledgments... 24 How This Book is Organized... 24 Who Should Buy This Book?... 24 Where to Find Answers to Review Questions and Exercises...

More information

Review Questions in Introductory Knowledge... 37

Review Questions in Introductory Knowledge... 37 Table of Contents Preface..... 17 About the Authors... 19 How This Book is Organized... 20 Who Should Buy This Book?... 20 Where to Find Answers to Review Questions and Exercises... 20 How to Report Errata...

More information

Unit 2 Boundary Value Testing, Equivalence Class Testing, Decision Table-Based Testing. ST 8 th Sem, A Div Prof. Mouna M.

Unit 2 Boundary Value Testing, Equivalence Class Testing, Decision Table-Based Testing. ST 8 th Sem, A Div Prof. Mouna M. Unit 2 Boundary Value Testing, Equivalence Class Testing, Decision Table-Based Testing ST 8 th Sem, A Div 2017-18 Prof. Mouna M. Naravani 19-02-2018 Dept. of CSE, BLDEACET, Vijarapur 2 Boundary Value Testing

More information

BIOL 458 BIOMETRY Lab 7 Multi-Factor ANOVA

BIOL 458 BIOMETRY Lab 7 Multi-Factor ANOVA BIOL 458 BIOMETRY Lab 7 Multi-Factor ANOVA PART 1: Introduction to Factorial ANOVA ingle factor or One - Way Analysis of Variance can be used to test the null hypothesis that k or more treatment or group

More information

Functionalist theories of content

Functionalist theories of content Functionalist theories of content PHIL 93507 April 22, 2012 Let s assume that there is a certain stable dependence relation between the physical internal states of subjects and the phenomenal characters

More information

One-Way Independent ANOVA

One-Way Independent ANOVA One-Way Independent ANOVA Analysis of Variance (ANOVA) is a common and robust statistical test that you can use to compare the mean scores collected from different conditions or groups in an experiment.

More information

VISA to (W)hole Personal Leadership

VISA to (W)hole Personal Leadership VISA to (W)hole Personal Leadership This questionnaire uses VISA to help you explore your leadership style preference, and will provide you with your personal VISA leadership profile. Structure Action

More information

The Logic of Data Analysis Using Statistical Techniques M. E. Swisher, 2016

The Logic of Data Analysis Using Statistical Techniques M. E. Swisher, 2016 The Logic of Data Analysis Using Statistical Techniques M. E. Swisher, 2016 This course does not cover how to perform statistical tests on SPSS or any other computer program. There are several courses

More information

Solutions for Chapter 2 Intelligent Agents

Solutions for Chapter 2 Intelligent Agents Solutions for Chapter 2 Intelligent Agents 2.1 This question tests the student s understanding of environments, rational actions, and performance measures. Any sequential environment in which rewards may

More information

Computational Tree Logic and Model Checking A simple introduction. F. Raimondi

Computational Tree Logic and Model Checking A simple introduction. F. Raimondi Computational Tree Logic and Model Checking A simple introduction F. Raimondi I am Franco Raimondi, f.raimondi@cs.ucl.ac.uk Slides, coursework, coursework solutions can be found online: http://www.cs.ucl.ac.uk/staff/f.raimondi/

More information

UNIVERSITY of PENNSYLVANIA CIS 520: Machine Learning Final, Fall 2014

UNIVERSITY of PENNSYLVANIA CIS 520: Machine Learning Final, Fall 2014 UNIVERSITY of PENNSYLVANIA CIS 520: Machine Learning Final, Fall 2014 Exam policy: This exam allows two one-page, two-sided cheat sheets (i.e. 4 sides); No other materials. Time: 2 hours. Be sure to write

More information

Optimization and Experimentation. The rest of the story

Optimization and Experimentation. The rest of the story Quality Digest Daily, May 2, 2016 Manuscript 294 Optimization and Experimentation The rest of the story Experimental designs that result in orthogonal data structures allow us to get the most out of both

More information

Objectives. Quantifying the quality of hypothesis tests. Type I and II errors. Power of a test. Cautions about significance tests

Objectives. Quantifying the quality of hypothesis tests. Type I and II errors. Power of a test. Cautions about significance tests Objectives Quantifying the quality of hypothesis tests Type I and II errors Power of a test Cautions about significance tests Designing Experiments based on power Evaluating a testing procedure The testing

More information

Controlling Worries and Habits

Controlling Worries and Habits THINK GOOD FEEL GOOD Controlling Worries and Habits We often have obsessional thoughts that go round and round in our heads. Sometimes these thoughts keep happening and are about worrying things like germs,

More information

UNIVERSITY of PENNSYLVANIA CIS 520: Machine Learning Midterm, 2016

UNIVERSITY of PENNSYLVANIA CIS 520: Machine Learning Midterm, 2016 UNIVERSITY of PENNSYLVANIA CIS 520: Machine Learning Midterm, 2016 Exam policy: This exam allows one one-page, two-sided cheat sheet; No other materials. Time: 80 minutes. Be sure to write your name and

More information

Evolutionary Programming

Evolutionary Programming Evolutionary Programming Searching Problem Spaces William Power April 24, 2016 1 Evolutionary Programming Can we solve problems by mi:micing the evolutionary process? Evolutionary programming is a methodology

More information

USING STATCRUNCH TO CONSTRUCT CONFIDENCE INTERVALS and CALCULATE SAMPLE SIZE

USING STATCRUNCH TO CONSTRUCT CONFIDENCE INTERVALS and CALCULATE SAMPLE SIZE USING STATCRUNCH TO CONSTRUCT CONFIDENCE INTERVALS and CALCULATE SAMPLE SIZE Using StatCrunch for confidence intervals (CI s) is super easy. As you can see in the assignments, I cover 9.2 before 9.1 because

More information

Obstacle- something that obstructs or hinders progress or action.

Obstacle- something that obstructs or hinders progress or action. Obstacle- something that obstructs or hinders progress or action. Notice that there are two main ways that an obstacle gets in the way of progress. The first is that an obstacle may obstruct progress.

More information

Bouncing Ball Lab. Name

Bouncing Ball Lab. Name Bouncing Ball Lab Name Scientists use an organized set of steps when they solve problems or perform investigations. This organized set of steps is called the Scientific Method. There are many versions

More information

Review: Logistic regression, Gaussian naïve Bayes, linear regression, and their connections

Review: Logistic regression, Gaussian naïve Bayes, linear regression, and their connections Review: Logistic regression, Gaussian naïve Bayes, linear regression, and their connections New: Bias-variance decomposition, biasvariance tradeoff, overfitting, regularization, and feature selection Yi

More information

HYPERSOMNIA NEW PATIENT QUESTIONNAIRE please fax back to us at : Current Medications:

HYPERSOMNIA NEW PATIENT QUESTIONNAIRE please fax back to us at : Current Medications: HYPERSOMNIA NEW PATIENT QUESTIONNAIRE please fax back to us at 404-712-8145: Name: Date: Date of Birth: Sex: M F (circle) Height: Weight: Current Medications: At what age did your sleepiness begin? years

More information

MITOCW ocw f99-lec20_300k

MITOCW ocw f99-lec20_300k MITOCW ocw-18.06-f99-lec20_300k OK, this is lecture twenty. And this is the final lecture on determinants. And it's about the applications. So we worked hard in the last two lectures to get a formula for

More information

Good Communication Starts at Home

Good Communication Starts at Home Good Communication Starts at Home It is important to remember the primary and most valuable thing you can do for your deaf or hard of hearing baby at home is to communicate at every available opportunity,

More information

FORENSIC HYPNOSIS WITH THE DEAF AND HEARING IMPAIRED

FORENSIC HYPNOSIS WITH THE DEAF AND HEARING IMPAIRED FORENSIC HYPNOSIS WITH THE DEAF AND HEARING IMPAIRED By: Inspector Marx Howell, BS (ret.) Unfortunately, I had not given much thought to the use of hypnosis with a deaf or hearing impaired individual until

More information

INTRODUCTION TO MACHINE LEARNING. Decision tree learning

INTRODUCTION TO MACHINE LEARNING. Decision tree learning INTRODUCTION TO MACHINE LEARNING Decision tree learning Task of classification Automatically assign class to observations with features Observation: vector of features, with a class Automatically assign

More information

Problem Set 2: Computer Psychiatrist

Problem Set 2: Computer Psychiatrist Due Friday, March 3 Computer Science (1)21b (Spring Term, 2017) Structure and Interpretation of Computer Programs Problem Set 2: Computer Psychiatrist Reading Assignment: Chapter 2, Sections 2.1, 2.2.

More information

Efficiency and design optimization

Efficiency and design optimization Efficiency and design optimization Tuesday, Lecture 2 Jeanette Mumford University of Wisconsin - Madison Thanks to Tom Liu for letting me use some of his slides! What determines your statistical power?

More information

AFSP SURVIVOR OUTREACH PROGRAM VOLUNTEER TRAINING HANDOUT

AFSP SURVIVOR OUTREACH PROGRAM VOLUNTEER TRAINING HANDOUT AFSP SURVIVOR OUTREACH PROGRAM VOLUNTEER TRAINING HANDOUT Goals of the AFSP Survivor Outreach Program Suggested Answers To Frequently Asked Questions on Visits Roadblocks to Communication During Visits

More information

Section 4 - Dealing with Anxious Thinking

Section 4 - Dealing with Anxious Thinking Section 4 - Dealing with Anxious Thinking How do we challenge our unhelpful thoughts? Anxiety may decrease if we closely examine how realistic and true our unhelpful/negative thoughts are. We may find

More information

Lecture II: Difference in Difference and Regression Discontinuity

Lecture II: Difference in Difference and Regression Discontinuity Review Lecture II: Difference in Difference and Regression Discontinuity it From Lecture I Causality is difficult to Show from cross sectional observational studies What caused what? X caused Y, Y caused

More information

Why Tests Don t Pass

Why Tests Don t Pass Douglas Hoffman Software Quality Methods, LLC. 24646 Heather Heights Place Saratoga, CA 95070 USA doug.hoffman@acm.org Summary Most testers think of tests passing or failing. Either they found a bug or

More information

Study on Gender in Physics

Study on Gender in Physics Listening Practice Study on Gender in Physics AUDIO - open this URL to listen to the audio: https://goo.gl/7xmlgh Questions 1-10 Choose the correct letter, A, B C. Study on Gender in Physics 1 The students

More information

Paper Airplanes & Scientific Methods

Paper Airplanes & Scientific Methods Paper Airplanes & Scientific Methods Scientific Inquiry refers to the many different ways in which scientists investigate the world. Scientific investigations are done to answer questions and solve problems.

More information

Chapter 7: Descriptive Statistics

Chapter 7: Descriptive Statistics Chapter Overview Chapter 7 provides an introduction to basic strategies for describing groups statistically. Statistical concepts around normal distributions are discussed. The statistical procedures of

More information

Epilepsy and Neuropsychology

Epilepsy and Neuropsychology Epilepsy and Neuropsychology Dr. Sare Akdag, RPsych Neuropsychology Service, BC Children s Hospital Clinical Assistant Professor, Dept of Paediatrics, UBC November 24, 2008 BC Epilepsy Society Lecture

More information

MITOCW conditional_probability

MITOCW conditional_probability MITOCW conditional_probability You've tested positive for a rare and deadly cancer that afflicts 1 out of 1000 people, based on a test that is 99% accurate. What are the chances that you actually have

More information

CAN T WE ALL JUST GET ALONG?

CAN T WE ALL JUST GET ALONG? CAN T WE ALL JUST GET ALONG? Using the Myers-Briggs Type Indicator to Improve Workplace Relations Sara Vancil and Janet Dodson, Fall 2013 RMASFAA Preferences Can you sign your name? What is a preference?

More information

What Constitutes a Good Contribution to the Literature (Body of Knowledge)?

What Constitutes a Good Contribution to the Literature (Body of Knowledge)? What Constitutes a Good Contribution to the Literature (Body of Knowledge)? Read things that make good contributions to the body of knowledge. The purpose of scientific research is to add to the body of

More information

CSE 258 Lecture 1.5. Web Mining and Recommender Systems. Supervised learning Regression

CSE 258 Lecture 1.5. Web Mining and Recommender Systems. Supervised learning Regression CSE 258 Lecture 1.5 Web Mining and Recommender Systems Supervised learning Regression What is supervised learning? Supervised learning is the process of trying to infer from labeled data the underlying

More information

Lecture 2: Learning and Equilibrium Extensive-Form Games

Lecture 2: Learning and Equilibrium Extensive-Form Games Lecture 2: Learning and Equilibrium Extensive-Form Games III. Nash Equilibrium in Extensive Form Games IV. Self-Confirming Equilibrium and Passive Learning V. Learning Off-path Play D. Fudenberg Marshall

More information

Brief Summary of Liminal thinking Create the change you want by changing the way you think Dave Gray

Brief Summary of Liminal thinking Create the change you want by changing the way you think Dave Gray Brief Summary of Liminal thinking Create the change you want by changing the way you think Dave Gray The word liminal comes from the Latin word limen which means threshold. Liminal thinking is the art

More information

Games for Young Mathematicians Dot Cards

Games for Young Mathematicians Dot Cards ABOUT THE MATH If you watch and listen to how students interact with the dot cards, you can learn a lot about what they know and what they are ready to learn. Once you see what they can do, you can help

More information

Anxiety- Information and a self-help guide

Anxiety- Information and a self-help guide Anxiety- Information and a self-help guide Anxiety Anxiety can be a very normal and healthy response to stressful situations, such as paying bills or sitting an exam. However, it becomes a problem when

More information

Computer Science 101 Project 2: Predator Prey Model

Computer Science 101 Project 2: Predator Prey Model Computer Science 101 Project 2: Predator Prey Model Real-life situations usually are complicated and difficult to model exactly because of the large number of variables present in real systems. Computer

More information

Problem Situation Form for Parents

Problem Situation Form for Parents Problem Situation Form for Parents Please complete a form for each situation you notice causes your child social anxiety. 1. WHAT WAS THE SITUATION? Please describe what happened. Provide enough information

More information

Tips for Youth Group Leaders

Tips for Youth Group Leaders OVERWHELMED Sometimes youth on the Autism Spectrum become so over-whelmed they are unable to function Most situations can be avoided by asking the youth to gauge their own comfort level Because the body

More information

15.301/310, Managerial Psychology Prof. Dan Ariely Recitation 8: T test and ANOVA

15.301/310, Managerial Psychology Prof. Dan Ariely Recitation 8: T test and ANOVA 15.301/310, Managerial Psychology Prof. Dan Ariely Recitation 8: T test and ANOVA Statistics does all kinds of stuff to describe data Talk about baseball, other useful stuff We can calculate the probability.

More information

The Scientific Method

The Scientific Method Course "Empirical Evaluation in Informatics" The Scientific Method Prof. Dr. Lutz Prechelt Freie Universität Berlin, Institut für Informatik http://www.inf.fu-berlin.de/inst/ag-se/ Science and insight

More information

The Five Types of Fear

The Five Types of Fear Five Energy Dynamics in Action The Five Types of Fear "I learned that courage was not the absence of fear, but the triumph over it. The brave man is not he who does not feel afraid, but he who conquers

More information

Exposure Therapy. in Low Intensity CBT. Marie Chellingsworth, Dr Paul Farrand & Gemma Wilson. Marie Chellingsworth, Dr Paul Farrand & Gemma Wilson

Exposure Therapy. in Low Intensity CBT. Marie Chellingsworth, Dr Paul Farrand & Gemma Wilson. Marie Chellingsworth, Dr Paul Farrand & Gemma Wilson Exposure Therapy in Low Intensity CBT Marie Chellingsworth, Dr Paul Farrand & Gemma Wilson CONTENTS Part 1 What is Exposure Therapy? Exposure Therapy Stages Part 2 Doing Exposure Therapy The Four Rules

More information

Experimental Design Notes

Experimental Design Notes Experimental Design Notes 1 Introduction We have previously discussed how microeconomic systems can be implemented as economic experiments. I have also provided some slides as a sample of how a particular

More information

The GCD of m Linear Forms in n Variables Ben Klein

The GCD of m Linear Forms in n Variables Ben Klein The GCD of m Linear Forms in n Variables Ben Klein Davidson, North Carolina, USA beklein@davidson.edu Harold Reiter Department of Mathematics, University of North Carolina Charlotte, Charlotte, NC 28223,

More information

Defect Removal Metrics. SE 350 Software Process & Product Quality 1

Defect Removal Metrics. SE 350 Software Process & Product Quality 1 Defect Removal Metrics 1 Objectives Understand some basic defect metrics and the concepts behind them Defect density metrics Defect detection and removal effectiveness etc. Look at the uses and limitations

More information

Lecture 2: Foundations of Concept Learning

Lecture 2: Foundations of Concept Learning Lecture 2: Foundations of Concept Learning Cognitive Systems - Machine Learning Part I: Basic Approaches to Concept Learning Version Space, Candidate Elimination, Inductive Bias last change October 18,

More information

DTI C TheUniversityof Georgia

DTI C TheUniversityof Georgia DTI C TheUniversityof Georgia i E L. EGCTE Franklin College of Arts and Sciences OEC 3 1 1992 1 Department of Psychology U December 22, 1992 - A Susan E. Chipman Office of Naval Research 800 North Quincy

More information

Artificial Intelligence Lecture 7

Artificial Intelligence Lecture 7 Artificial Intelligence Lecture 7 Lecture plan AI in general (ch. 1) Search based AI (ch. 4) search, games, planning, optimization Agents (ch. 8) applied AI techniques in robots, software agents,... Knowledge

More information

Measurement and meaningfulness in Decision Modeling

Measurement and meaningfulness in Decision Modeling Measurement and meaningfulness in Decision Modeling Brice Mayag University Paris Dauphine LAMSADE FRANCE Chapter 2 Brice Mayag (LAMSADE) Measurement theory and meaningfulness Chapter 2 1 / 47 Outline 1

More information

AGENT-BASED SYSTEMS. What is an agent? ROBOTICS AND AUTONOMOUS SYSTEMS. Today. that environment in order to meet its delegated objectives.

AGENT-BASED SYSTEMS. What is an agent? ROBOTICS AND AUTONOMOUS SYSTEMS. Today. that environment in order to meet its delegated objectives. ROBOTICS AND AUTONOMOUS SYSTEMS Simon Parsons Department of Computer Science University of Liverpool LECTURE 16 comp329-2013-parsons-lect16 2/44 Today We will start on the second part of the course Autonomous

More information

classmates to the scene of a (fictional) crime. They will explore methods for identifying differences in fingerprints.

classmates to the scene of a (fictional) crime. They will explore methods for identifying differences in fingerprints. whodunnit? (1 Hour) Addresses NGSS Level of Difficulty: 2 Grade Range: 3-5 OVERVIEW In this activity, students will help solve a crime by attempting to match fingerprints from their classmates to the scene

More information

Connexion of Item Response Theory to Decision Making in Chess. Presented by Tamal Biswas Research Advised by Dr. Kenneth Regan

Connexion of Item Response Theory to Decision Making in Chess. Presented by Tamal Biswas Research Advised by Dr. Kenneth Regan Connexion of Item Response Theory to Decision Making in Chess Presented by Tamal Biswas Research Advised by Dr. Kenneth Regan Acknowledgement A few Slides have been taken from the following presentation

More information

My Review of John Barban s Venus Factor (2015 Update and Bonus)

My Review of John Barban s Venus Factor (2015 Update and Bonus) My Review of John Barban s Venus Factor (2015 Update and Bonus) December 26, 2013 by Erin B. White 202 Comments (Edit) This article was originally posted at EBWEIGHTLOSS.com Venus Factor is a diet program

More information

TAPPING THE K. E. G. S.

TAPPING THE K. E. G. S. January, 2019 TAPPING THE K. E. G. S. K O M P U T E R E N T H U S I A S T S O F G R E A T E R S E A T T L E Prez Says: Happy New Year to everyone! I hope that you had a wonderful time over the holidays

More information

Appendix: Instructions for Treatment Index B (Human Opponents, With Recommendations)

Appendix: Instructions for Treatment Index B (Human Opponents, With Recommendations) Appendix: Instructions for Treatment Index B (Human Opponents, With Recommendations) This is an experiment in the economics of strategic decision making. Various agencies have provided funds for this research.

More information

Problem Solving Agents

Problem Solving Agents Problem Solving Agents CSL 302 ARTIFICIAL INTELLIGENCE SPRING 2014 Goal Based Agents Representation Mechanisms (propositional/first order/probabilistic logic) Learning Models Search (blind and informed)

More information

11 tips for real estate agents with ADHD

11 tips for real estate agents with ADHD 11 tips for real estate agents with ADHD Delegation, delegation, delegation are the three most important words BYRETT HARMON FOR INMAN.COM It s time that I come clean with a personal confession. I have

More information

MAKING PEACE & MOVING ON

MAKING PEACE & MOVING ON JULY Week 2. Spiritual Practice MAKING PEACE & MOVING ON Transition Material and Tradition Elements for this Block. Ecclesiastes 3:1: There s a season for everything and a time for every matter under the

More information

STEP Support Programme. Assignment 6

STEP Support Programme. Assignment 6 STEP Support Programme Assignment 6 Warm-up 1 (i) Find the value of (1 + 1 2 )(1 + 1 4 )(1 + 1 6 )(1 + 1 8 ) (1 1 2 )(1 1 4 )(1 1 6 )(1 1 8 ). Find the value (in terms of n) of (1 + 1 2 )(1 + 1 4 )(1 +

More information

Feeling. Thinking. My Result: My Result: My Result: My Result:

Feeling. Thinking. My Result: My Result: My Result: My Result: Source of Energy [P]erception of Info [J]udgment of Info External Lifestyle Where You Process How You Inform How You Make How Others See Your Decision-Making Extraverted intuitive Feeling Judging Introvert

More information

Maximum Likelihood ofevolutionary Trees is Hard p.1

Maximum Likelihood ofevolutionary Trees is Hard p.1 Maximum Likelihood of Evolutionary Trees is Hard Benny Chor School of Computer Science Tel-Aviv University Joint work with Tamir Tuller Maximum Likelihood ofevolutionary Trees is Hard p.1 Challenging Basic

More information

Einführung in Agda. Peter Thiemann. Albert-Ludwigs-Universität Freiburg. University of Freiburg, Germany

Einführung in Agda.   Peter Thiemann. Albert-Ludwigs-Universität Freiburg. University of Freiburg, Germany Einführung in Agda https://tinyurl.com/bobkonf17-agda Albert-Ludwigs-Universität Freiburg Peter Thiemann University of Freiburg, Germany thiemann@informatik.uni-freiburg.de 23 Feb 2018 Programs that work

More information

TO ESCAPE YOUR FATE YOU CAN CAUSE THINGS TO HAPPEN

TO ESCAPE YOUR FATE YOU CAN CAUSE THINGS TO HAPPEN TO ESCAPE YOUR FATE YOU CAN CAUSE THINGS TO HAPPEN You can free your will from the purpose behind the actions you take and those concepts are the very basis of your existence. What you imagine will always

More information

Unit 3: EXPLORING YOUR LIMITING BELIEFS

Unit 3: EXPLORING YOUR LIMITING BELIEFS Unit 3: EXPLORING YOUR LIMITING BELIEFS Beliefs and Emotions Bring to mind a negative belief you hold about money. Perhaps it is I don t believe I can win with money or Money is hard to come by. While

More information

Lesson 9: Two Factor ANOVAS

Lesson 9: Two Factor ANOVAS Published on Agron 513 (https://courses.agron.iastate.edu/agron513) Home > Lesson 9 Lesson 9: Two Factor ANOVAS Developed by: Ron Mowers, Marin Harbur, and Ken Moore Completion Time: 1 week Introduction

More information

Processing of Logical Functions in the Human Brain

Processing of Logical Functions in the Human Brain Processing of Logical Functions in the Human Brain GRMELA ALEŠ AGCES Ltd. AGCES, Levského 3221/1, Praha 4 CZECH REPUBLIC N. E. MASTORAKIS Military Institutions of University Education, Hellenic Naval Academy,

More information

One-Way ANOVAs t-test two statistically significant Type I error alpha null hypothesis dependant variable Independent variable three levels;

One-Way ANOVAs t-test two statistically significant Type I error alpha null hypothesis dependant variable Independent variable three levels; 1 One-Way ANOVAs We have already discussed the t-test. The t-test is used for comparing the means of two groups to determine if there is a statistically significant difference between them. The t-test

More information

The Fox and the Crow

The Fox and the Crow The Fox and the Crow Roman Karl Seminar in Artificial Intelligence, November 2012 The fox and the crow is an old Greek fable. There are two characters, where both have a different behavior, which is caused

More information

CHAPTER 3 DATA ANALYSIS: DESCRIBING DATA

CHAPTER 3 DATA ANALYSIS: DESCRIBING DATA Data Analysis: Describing Data CHAPTER 3 DATA ANALYSIS: DESCRIBING DATA In the analysis process, the researcher tries to evaluate the data collected both from written documents and from other sources such

More information

Position Paper: How Certain is Recommended Trust-Information?

Position Paper: How Certain is Recommended Trust-Information? Position Paper: How Certain is Recommended Trust-Information? Uwe Roth University of Luxembourg FSTC Campus Kirchberg 6, rue Richard Coudenhove-Kalergi L-1359 Luxembourg uwe.roth@uni.lu ABSTRACT Nowadays

More information

MS&E 226: Small Data

MS&E 226: Small Data MS&E 226: Small Data Lecture 10: Introduction to inference (v2) Ramesh Johari ramesh.johari@stanford.edu 1 / 17 What is inference? 2 / 17 Where did our data come from? Recall our sample is: Y, the vector

More information

AUTOMATED DEBUGGING. Session Leader: Zongxu Mu

AUTOMATED DEBUGGING. Session Leader: Zongxu Mu AUTOMATED DEBUGGING Session Leader: Zongxu Mu THE FIRST COMPUTER BUG Source: https://plus.google.com/107048744275438760860/posts/twfceqadsld 10/22/2013 Automated Debugging - Zongxu Mu 2 A RANDOM COMPUTER

More information

Chapter 13. Experiments and Observational Studies

Chapter 13. Experiments and Observational Studies Chapter 13 Experiments and Observational Studies 1 /36 Homework Read Chpt 13 Do p312 1, 7, 9, 11, 17, 20, 25, 27, 29, 33, 40, 41 2 /36 Observational Studies In an observational study, researchers do not

More information

Pearson Edexcel International GCSE in Mathematics (Specification A) (9-1) Exemplar student answers with examiner comments

Pearson Edexcel International GCSE in Mathematics (Specification A) (9-1) Exemplar student answers with examiner comments Pearson Edexcel International GCSE in Mathematics (Specification A) (9-1) Exemplar student answers with examiner comments 1 Contents About this booklet... 3 How to use this booklet.... 3 Guide on the use

More information

Sociology 593 Exam 2 March 28, 2003

Sociology 593 Exam 2 March 28, 2003 Sociology 59 Exam March 8, 00 I. True-False. (0 points) Indicate whether the following statements are true or false. If false, briefly explain why.. WHITE is coded = white, 0 = nonwhite. X is a continuous

More information

Bayesian Tailored Testing and the Influence

Bayesian Tailored Testing and the Influence Bayesian Tailored Testing and the Influence of Item Bank Characteristics Carl J. Jensema Gallaudet College Owen s (1969) Bayesian tailored testing method is introduced along with a brief review of its

More information

A Guide to Algorithm Design: Paradigms, Methods, and Complexity Analysis

A Guide to Algorithm Design: Paradigms, Methods, and Complexity Analysis A Guide to Algorithm Design: Paradigms, Methods, and Complexity Analysis Anne Benoit, Yves Robert, Frédéric Vivien To cite this version: Anne Benoit, Yves Robert, Frédéric Vivien. A Guide to Algorithm

More information

SECTION TWO SHORT ANSWER QUESTIONS

SECTION TWO SHORT ANSWER QUESTIONS SECTION TWO SHORT ANSWER QUESTIONS Q1. Assume that we have developed advanced methods of artificial fertilization that allow us to create embryos from the combined genetic material of either two sperm

More information

Statistical sciences. Schools of thought. Resources for the course. Bayesian Methods - Introduction

Statistical sciences. Schools of thought. Resources for the course. Bayesian Methods - Introduction Bayesian Methods - Introduction Dr. David Lucy d.lucy@lancaster.ac.uk Lancaster University Bayesian methods p.1/38 Resources for the course All resources for this course can be found at: http://www.maths.lancs.ac.uk/

More information

Self-Esteem Discussion Points

Self-Esteem Discussion Points Self-Esteem Discussion Points 1. 2. 3. 4. 5. What does self-esteem mean? liking yourself being proud of things you ve done knowing how you re special and unique knowing you re a good person knowing you

More information

THOUGHTS, ATTITUDES, HABITS AND BEHAVIORS

THOUGHTS, ATTITUDES, HABITS AND BEHAVIORS THOUGHTS, ATTITUDES, HABITS AND BEHAVIORS Ellen Freedman, CLM Law Practice Management Coordinator Pennsylvania Bar Association I ve been thinking a lot lately about how we think, what we think, and what

More information

1 What is an Agent? CHAPTER 2: INTELLIGENT AGENTS

1 What is an Agent? CHAPTER 2: INTELLIGENT AGENTS 1 What is an Agent? CHAPTER 2: INTELLIGENT AGENTS http://www.csc.liv.ac.uk/ mjw/pubs/imas/ The main point about agents is they are autonomous: capable of acting independently, exhibiting control over their

More information

Bayesian and Frequentist Approaches

Bayesian and Frequentist Approaches Bayesian and Frequentist Approaches G. Jogesh Babu Penn State University http://sites.stat.psu.edu/ babu http://astrostatistics.psu.edu All models are wrong But some are useful George E. P. Box (son-in-law

More information

IMPRINT models of training: Update on RADAR modeling

IMPRINT models of training: Update on RADAR modeling IMPRINT models of training: Update on RADAR modeling MURI Annual Meeting September 12, 2008 Carolyn Buck-Gengler Department of Psychology, Institute of Cognitive Science, and Center for Research on Training

More information

Chapter 1. Introduction

Chapter 1. Introduction Chapter 1 Introduction Artificial neural networks are mathematical inventions inspired by observations made in the study of biological systems, though loosely based on the actual biology. An artificial

More information

Guidelines for Setting Goals

Guidelines for Setting Goals S Guidelines for Setting Goals Explore "For when David had served God's purpose in his own generation, he fell asleep (Acts 13:36 NIV). etting and achieving goals help us fulfill our purpose. Deep within

More information

Data mining for Obstructive Sleep Apnea Detection. 18 October 2017 Konstantinos Nikolaidis

Data mining for Obstructive Sleep Apnea Detection. 18 October 2017 Konstantinos Nikolaidis Data mining for Obstructive Sleep Apnea Detection 18 October 2017 Konstantinos Nikolaidis Introduction: What is Obstructive Sleep Apnea? Obstructive Sleep Apnea (OSA) is a relatively common sleep disorder

More information

The Fallacy of Taking Random Supplements

The Fallacy of Taking Random Supplements The Fallacy of Taking Random Supplements Healthview interview with Dr. Paul Eck Healthview: We can see from our conversations that you are totally against people taking random supplements even if people

More information

Some Thoughts on the Principle of Revealed Preference 1

Some Thoughts on the Principle of Revealed Preference 1 Some Thoughts on the Principle of Revealed Preference 1 Ariel Rubinstein School of Economics, Tel Aviv University and Department of Economics, New York University and Yuval Salant Graduate School of Business,

More information

COMP329 Robotics and Autonomous Systems Lecture 15: Agents and Intentions. Dr Terry R. Payne Department of Computer Science

COMP329 Robotics and Autonomous Systems Lecture 15: Agents and Intentions. Dr Terry R. Payne Department of Computer Science COMP329 Robotics and Autonomous Systems Lecture 15: Agents and Intentions Dr Terry R. Payne Department of Computer Science General control architecture Localisation Environment Model Local Map Position

More information

Pooling Subjective Confidence Intervals

Pooling Subjective Confidence Intervals Spring, 1999 1 Administrative Things Pooling Subjective Confidence Intervals Assignment 7 due Friday You should consider only two indices, the S&P and the Nikkei. Sorry for causing the confusion. Reading

More information