Correctness of bubblesort Bubblesort is a popular, but inefficient, sorting algorithm. It works by repeatedly swapping adjacent elements that are out of order. BUBBLESORT.A/ 1 for i D 1 to A:length 1 2 for j D A:length downto i C 1 3 if Aj < Aj 1 4 exchange Aj with Aj 1 a. Let A0 denote the output of BUBBLESORT.A/. To prove that BUBBLESORT is correct, we need to prove that it terminates and that A0 1 A0 2 A0 n ; (2.3) where n D A:length. In order to show that BUBBLESORT actually sorts, what else do we need to prove? The next two parts will prove inequality (2.3). b. State precisely a loop invariant for the for loop in lines 24, and prove that this loop invariant holds. Your proof should use the structure of the loop invariant proof presented in this chapter. c. Using the termination condition of the loop invariant proved in part (b), state a loop invariant for the for loop in lines 14 that will allow you to prove inequality (2.3). Your proof should use the structure of the loop invariant proof presented in this chapter. d. What is the worst-case running time of bubblesort? How does it compare to the running time of insertion sort?
Thursday, March 17, 2016 Chapter 6 Learning and Performance Management - We can learn in three ways: classroom setting • • real world experiences • reading and examining others (takes a VERY long time) - classical conditioning - modifying behavior by pairing a conditioned stimulus with an unconditioned stimulus to elicit an unconditioned response • Pavlov’s Dog Experiment - he would ring a bell and offer a dog a treat which would cause the dog’s mouth to produce saliva; after awhile, he was able to make the dog produce saliva just by ringing the bell • positive only front-end - operant conditioning - modifying behavior through the use pf positive or negative consequences following speciﬁc behavior • positive and negative back-end - reinforcement • strategy to cultivate desirable behavior by either bestowing positive consequences or withholding negative consequences - “Law of Effect” - A leads to B - punishment • strategy to discourage undesirable behavior by either bestowing negative consequences or withholding positive consequences • extinction - strategy to weaken behavior by attaching no consequences to it - Social Learning Theory • learning occurs by observing others and modeling their behavior - Cognitive Theories • group of theories; “The whole is greater than the sum of the parts.” 1 Thursday, March 17, 2016 - Goal-Setting At Work • the process of establishing desires results that guide and direct behavior - Goal-Setting Functions • increase work motivation and task performance • reduce role stress associated with conﬂicting or confusing situations • improve accuracy and validity of performance evaluation - improve performance evaluation - MBO (Management By Objectives) - a goal- setting program based on interaction and negotiation between employees and managers • articulates WHAT to do • determines HOW to do it - Performance Appraisal • criticism • how to overcome it • positive feedback - Absenteeism • tardy policies “Organizations get the performance they reward..not the performance they say they want.” who should get the reward - if anyone what/how much should the reward be - Correcting Poor Performance • identify primary cause • determine problems’ source • develop corrective plan of action - Kelley’s Attribution Theory • explains how individuals pinpoint the causes of their own and others’ behaviors 2 Thursday, March 17, 2016 - consensus - informational cue indicating the extent to which peers in the same situation behave in a similar fashion - distinctiveness - informational cue indicating the degree to which an individual behaves the same way in other situations - consistency - frequency of behavior over time - Mentoring • work relationship that encourages development and career enhancement for people moving through the career cycle 3