Introduction to Computer Science, Shimon Schocken, IDC Herzliya. Lecture Recursion. Introduction to Computer Science, Shimon Schocken slide 1

Size: px
Start display at page:

Download "Introduction to Computer Science, Shimon Schocken, IDC Herzliya. Lecture Recursion. Introduction to Computer Science, Shimon Schocken slide 1"

Transcription

1 Iroducio o Compuer Sciece, Shimo Schocke, IDC Herzliya Lecure Recursio Iroducio o Compuer Sciece, Shimo Schocke slide 1 Recursio Recursio: a fudameal algorihmic echique, based o divide ad coquer Recursive fucio: a mahemaical fucio defied i erms of iself. Eample:! (-1)! Recursive mehod: a mehod ha calls iself o smaller subses of he problem space. Eample: lis all he files i a give direcory Recursive daa srucure: a daa srucure whose elemes are defied usig refereces o iself. Eample: he lis "abcd" is he characer 'a followed by he lis "bcd" Learig o hik recursively ad desig recursive programs is a fudameal programmig skill Bu, maserig i akes pracice ad isigh. Recursive image Iroducio o Compuer Sciece, Shimo Schocke slide 2

2 Oulie Recursive algorihms Recursive fucios Facorial Fiboacci Power Recursive procedures File lisig Reverse Permuaios Ieger.oSrig Tower of Haoi Permuaios Fracals Iroducio o Compuer Sciece, Shimo Schocke slide 3 The buildig blocks of a recursive desig Every recursive algorihm is based o hree desig elemes: Reducio: i mus be possible o reduce he origial problem io subproblems ha are simpler isaces of he same problem Base case: A some poi of he reducio we mus arrive o a sub-problem ha ca be solved direcly Assembly: Oce he sub-problems have bee solved, i mus be possible o combie he sub-soluios io a soluio of he origial problem. Merge Sor: a recursive algorihm eample Iroducio o Compuer Sciece, Shimo Schocke slide 4

3 Facorial Ieraive defiiio 1 facorial( ) ( 1) ( 2) K 1 1or 0 oherwise Eample: 5! facorial(5) Ieraive implemeaio class class FacorialDemo1 mai(srig[] args) args) Sysem.ou.pril("5! " facorial(5)); Reurs Reurs he he facorial facorial (!) (!) of of a give give.. log log facorial(log ) ) log log fac fac 1; 1; for for (i (i i1; i1; i<; i<; i) i) fac fac i; i; fac; fac; Eample of a o-recursive soluio Iroducio o Compuer Sciece, Shimo Schocke slide 5 Facorial: a recursive soluio Recursive defiiio 1 facorial( ) facorial( 1) 1or 0 oherwise facorial(5) 5 facorial(4) 5 4 facorial(3) facorial(2) facorial(1) facorial( Recursive implemeaio log log facorial(log ) ) ( ( 1; 1; facorial(-1); Iroducio o Compuer Sciece, Shimo Schocke slide 6

4 Elemes of he recursive approach log log facorial(log ) ) ( ( 1; 1; facorial(-1); Base case Assembly Reducio A oe-lier log log facorial(log ) ) ((1) ((1)? 1 : facorial(-1)); Iroducio o Compuer Sciece, Shimo Schocke slide 7 Ru-ime aaomy 2 Recursive call Reurig a value o he caller facorial(4) 4 facorial(3) facorial (2) facorial(1) facorial( log log facorial(log facorial(log ) ) ( ( 1; 1; facorial(-1); facorial(-1); Base case: 1 Iroducio o Compuer Sciece, Shimo Schocke slide 8

5 Sum The problem saed sum sum (a (a,, b) b)?? sum sum (a (a,, o) o) aa sum sum (a (a,, b) b) sum(a sum(a,,(b (b--1)) 1)) 1 for for b > 0 sum sum (a,b) (a,b) sum(a,b--) i i pseudo pseudo code code Recursive algorihm 11 7 The challege: defiig sum wihou acually summig ayhig. Isead, we reduce he problem io a series of add 1 operaios. sum(a, sum(a, b) b) (b (b a s sum(a,--b) s s sum (8, 3) sum (8, 2) sum (8, 1) sum (8, Iroducio o Compuer Sciece, Shimo Schocke slide 9 I Java Algorihm sum(a, sum(a, b) b) (b (b a s sum(a,--b) s s Implemeaio class class SumDemo SumDemo mai(srig args[]) args[]) Sysem.ou.pril(sum(5,3)); log log sum(log sum(log a,log a,log b) b) (b (b a; a; log log s sum(a,--b); s; s; Iroducio o Compuer Sciece, Shimo Schocke slide 10

6 Fiboacci series Fiboacci series defiiio fib( fib( 1 fib(1) fib(1) 1 fib() fib() fib(-1) fib(-2) for for all all >1 >1 The Fiboacci series: 1, 1, 2, 3, 5, 8, 13,... Recursive implemeaio class class FiboacciDemo mai(srig args[]) args[]) Sysem.ou.pril(fiboacci(5)); Reurs Reurs he he umber umber i i fiboacci fiboacci series series i i fiboacci(i ) ) ( ( < < 1) 1) 1; 1; fiboacci(-1) fiboacci(-2); The recursive implemeaio follows direcly from he recursive defiiio: Base case: 0, 1 Reducio: from o (-1) ad (-2) Assembly: usig Iroducio o Compuer Sciece, Shimo Schocke slide 11 Fiboacci series: Ru-ime aaomy f(4) f(3) f(2) f(2) f(1) f(1) f( f(1) f( Buil-i redudacy: he algorihm repeas he same compuaios (e.g. f(2)) Ruig ime of his algorihm: ~ O(2 ) Q: Ca we do beer? A: A boom-up, ieraive soluio will ru i O() Coclusio: Naïve recursive soluios ca be epesive! Iroducio o Compuer Sciece, Shimo Schocke slide 12

7 Oulie Recursive algorihms Recursive fucios Facorial Fiboacci Power Recursive procedures File lisig Reverse Permuaios Ieger.oSrig Tower of Haoi Permuaios Fracals Iroducio o Compuer Sciece, Shimo Schocke slide 13 Power fucio: recursive implemeaio Recursive defiiio: power(,, 1 Power(,, ) ) power(,, -1) -1) for for all all >0 >0 1 Power(3, 4) 81 8 Ru-ime simulaio Recursive implemeaio: 3 power (3, 3) Compues Compues raised raised o o he he power power of of ) ) ) -1) power(3, 2) Ruig ime of recursive programs: Simply add up he ruig ime of all he recursive calls ) requires 1 recursive calls: ), -1),, 1), Toal ruig ime (1) O(1) O() 3 power(3, 1) power(3, Iroducio o Compuer Sciece, Shimo Schocke slide 14

8 Power fucio: recursive implemeaio, Take 2 Compues Compues raised raised o o he he power power of of Power(3, 5) Ru-ime simulaio ) ) ( ( 1 1 (%2 (%2 /2) /2) -1) -1) Ruig-ime: O(log ) Afer wo recursive calls decreases i a facor of a leas 2 (Eiher or -1 is eve, hus i wo recursive calls he algorihm divides by 2 a leas oce) Thus he oal umber of seps (recursive calls) is a mos 2 log Thus he ruig ime is O(log ). 3 power(3, 4) power(3, 2) power(3, 1) power(3, Iroducio o Compuer Sciece, Shimo Schocke slide 15 Recursive power, ake 2 ) ) ( ( 1; 1; (%2 (%2 /2); /2); ; ; -1); -1); Theorem: For ay ad posiive ieger, he algorihm s 1 Power(5, 4) Ru-ime simulaio power(5, 2) power(5, 1) Proof: By srog iducio o. 5 power(5, Base case: 0 he algorihm s 1. Iducive hypohesis: Assume ha for all k < he algorihm s k Iducive sep: If is eve, he algorihm s /2) /2) By he iducio hypohesis, /2) s ½, hus he algorihm s ( ½ ) ( ½ ) If is odd, he algorihm s -1) By he iducio hypohesis, -1) s -1, hus he algorihm s ( -1 ) Iroducio o Compuer Sciece, Shimo Schocke slide 16

9 Oulie Recursive algorihms Recursive fucios Facorial Fiboacci Power Recursive procedures File lisig Reverse Permuaios Ieger.oSrig Tower of Haoi Permuaios Fracals Iroducio o Compuer Sciece, Shimo Schocke slide 17 Recursive procedures May fucios such as facorial, Fiboacci, ec. have ihere recursive defiiios. Therefore, implemeig hem usig recursive mehods is aural Procedures, however, are desiged o do various higs wihou ig values (i Java, implemeed as mehods) I may cases, procedures ca also be described i recursive erms Eample: files lisig uiliy Iroducio o Compuer Sciece, Shimo Schocke slide 18

10 File lisig Lis Lis all all files files uder uder a a give give direcory direcory privae privae lisfiles(file lisfiles(file direcory) direcory) Creaes Creaes a a array array of of all all file file ames ames Srig[] Srig[] iemnames iemnames direcory.lis(); direcory.lis(); for for (i (i i0 i0 ; ; i<filenames.legh i<filenames.legh ; ; i) i) File File file file ew ew File(direcory, File(direcory, filenames[i]); filenames[i]); (file.isdirecory()) (file.isdirecory()) pridirecorydeails(file); pridirecorydeails(file); lisfiles(file); lisfiles(file); pridirecorydeails(file); pridirecorydeails(file); Pris Pris direcory direcory ame ame ad ad deails deails privae privae pridirecorydeails(file pridirecorydeails(file direcory) direcory) Pris Pris file file ame ame ad ad deails deails privae privae prifiledeails(file prifiledeails(file file) file) Iroducio o Compuer Sciece, Shimo Schocke slide 19 Reverse prireverse() prireverse() pri("eer pri("eer a a umber, umber, or or 0 0 o o ed: ed: ") ") read() read() ( (!! prireverse(); prireverse(); pri(); pri(); Read() prireverse() wrie() 2 '51' 5 Read() prireverse() wrie() 3 '5' 4 Read() prireverse() wrie() User s ipu: 5 User s ipu: 4 User s ipu: 0 Mehod callig is a comple process, maaged behid he scee Whe a mehod calls aoher, he caller s variables ad address are saved Whe he called mehod s, he saved values are re-isaiaed As far as he caller is cocered, everyhig is back o ormal. Iroducio o Compuer Sciece, Shimo Schocke slide 20

11 Ieger.oSrig() The ask: Wrie Wrie a a mehod mehod ha ha akes akes a a o-egaive ieger ieger ad ad oupus oupus is is decimal decimal represeaio usig usig characer characer oupu oupu Eample: Eample: Give Give he he ieger ieger ipu ipu 513, 513, oupu oupu he he srig srig "513" "513" The Uicode values of '0', '1', '2', '3',, '9' are 48, 49, 50, 51,, 57 Therefore, < 10, oe way o ge is Uicode value is (char)('0' ) Recursive hikig: Base case: If < 10 we oupu (char)('0' ) Reducio: a ieger of he form yyy y (each ad y beig a sigle digi) ca be reduced usig /10 ad yyy y %10 Assembly: The cocaeaio operaor ca be used o combie parial resuls io he fial value. Iroducio o Compuer Sciece, Shimo Schocke slide 21 Recursive implemeaio The ask: Wrie Wrie a a mehod mehod ha ha akes akes a a o-egaive ieger ieger ad ad oupus oupus is is decimal decimal represeaio usig usig characer characer oupu oupu Eample: Eample: Give Give he he ieger ieger ipu ipu 513, 513, oupu oupu he he srig srig "513" "513" class class PriIegerDemo mai(srig[] args) args) Sysem.ou.pri(oSrig(513)); Srig Srig osrig(i ) ) ( ( < 1 1 "" "" ((char) ((char) (48 (48 )); )); osrig( / 1 1 (char) (char) (48 (48 % 1; 1; Iroducio o Compuer Sciece, Shimo Schocke slide 22

12 Ru-ime aaomy osrig(5137) osrig(513) '7' 1 '513' 6 osrig(51) '3' Srig Srig osrig(i osrig(i ) ) ( ( < < 1 1 " " (char) (char) (48 (48 ); ); osrig( osrig( / / 1 1 (char) (char) (48 (48 % % 1; 1; 2 '51' 5 osrig(5) '1' 3 '5' 4 Base case: 5 < 10 Iroducio o Compuer Sciece, Shimo Schocke slide 23 Tower of Haoi The rules of he game: Move Move all all he he disks disks o o aoher spidle, so so ha: ha: (1) (1) oly oly oe oe disk disk moves a a a ime ime (2) (2) The The smaller disks disks are are always a a he he op op Iroducio o Compuer Sciece, Shimo Schocke slide 24

13 Tower of Haoi Sar: Fiish: The rules of he game: Move Move all all he he disks disks o o aoher spidle, so so ha: ha: (1) (1) oly oly oe oe disk disk moves a a a ime ime (2) (2) The The smaller disks disks are are always a a he he op op Iroducio o Compuer Sciece, Shimo Schocke slide 25 The recursive sraegy Sar: Move he op -1 disks from A o C Move he remaiig disk from A o B Move all he disks from C o B Fiish: Doe! Iroducio o Compuer Sciece, Shimo Schocke slide 26

14 Tower of Haoi implemeaio sar fiish emp 11 :: move move his his sigle sigle disk disk from from sar saro o fiish fiish > > 11 :: Move Move he he op op -1-1 disks disks from from sar saro o emp, emp, usig usig fiish fiish Move Move he he boom boom disk disk from from sar saro o fiish fiish Move Move he he op op -1-1 disks disks from from emp empo o fiish, fiish, usig usig sar sar class class TowerOfHaoi TowerOfHaoi mai(srig[] mai(srig[] args) args) movetower(3, movetower(3, "A", "A", "B", "B", "C"); "C"); Moves Moves a a ower ower of of disks disks from from A A o o B B usig usig C C movetower(i movetower(i,, Srig Srig sar, sar, Srig Srig fiish, fiish, Srig Srig emp) emp) (1) (1) Sysem.ou.pril(sar Sysem.ou.pril(sar "->" "->" fiish); fiish); movetower(-1, movetower(-1, sar, sar, emp, emp, fiish); fiish); Sysem.ou.pril(sar Sysem.ou.pril(sar "->" "->" fiish); fiish); movetower(-1, movetower(-1, emp, emp, fiish fiish,, sar); sar); Iroducio o Compuer Sciece, Shimo Schocke slide 27 Simulaio movetower(3, A, B, C ) Goal: Goal: move move a a ower ower of of size size 3 from from A o o B usig usig C: C: Goal: sar fiish emp Goal: move move a a ower ower of of size size 2 from from A o o C usig usig B: B: 3 "A" B" C" sar fiish emp Goal: Goal: move 2 move a a ower ower of "A" of size size 1 C" 1 from from A o o B B" usig usig C: C: Thigs Thigs o o do: do: sar fiish emp movetower(-1, sar, sar, emp, emp, fiish); fiish); Thigs Sysem.ou.pril(sar Thigs o o do: do: 1 "A" B" C" "->" "->" fiish); fiish); movetower(-1, movetower(-1, emp, sar, emp, sar, fiish emp, fiish emp,, sar); fiish); sar); fiish); Sysem.ou.pril(sar Thigs "->" "->" fiish); Thigs o o do: do: fiish); movetower(-1, emp, emp, fiish fiish, sar); movetower(-1, sar); sar, sar, emp, emp, fiish); fiish); Sysem.ou.pril(sar "->" "->" fiish); fiish); movetower(-1, emp, emp, fiish fiish, sar); sar); Iroducio o Compuer Sciece, Shimo Schocke slide 28

15 Simulaio movetower(3, A, B, C ) Goal: Goal: move move a a ower ower of of size size 3 from from A o o B usig usig C: C: Goal: sar fiish emp Goal: move move a a ower ower of of size size 2 from from A o o C usig usig B: B: 3 "A" B" C" sar fiish emp 2 "A" C" B" Thigs Thigs o o do: do: movetower(-1, sar, sar, emp, emp, fiish); fiish); Thigs Sysem.ou.pril(sar Thigs o o do: do: "->" "->" fiish); fiish); movetower(-1, movetower(-1, emp, sar, emp, sar, fiish emp, fiish emp,, sar); fiish); sar); fiish); Sysem.ou.pril(sar "->" "->" fiish); fiish); movetower(-1, emp, emp, fiish fiish, sar); sar); Iroducio o Compuer Sciece, Shimo Schocke slide 29 Simulaio movetower(3, A, B, C ) Goal: Goal: move move a a ower ower of of size size 3 from from A o o B usig usig C: C: Goal: sar fiish emp Goal: move move a a ower ower of of size size 2 from from A o o C usig usig B: B: 3 "A" B" C" sar fiish emp 2 "A" C" B" Thigs Thigs o o do: do: movetower(-1, sar, sar, emp, emp, fiish); fiish); Thigs Sysem.ou.pril(sar Thigs o o do: do: "->" "->" fiish); fiish); movetower(-1, movetower(-1, emp, sar, emp, sar, fiish emp, fiish emp,, sar); fiish); sar); fiish); Sysem.ou.pril(sar "->" "->" fiish); fiish); movetower(-1, emp, emp, fiish fiish, sar); sar); Iroducio o Compuer Sciece, Shimo Schocke slide 30

16 Simulaio (TBD) movetower(3, A, B, C ) Goal: Goal: move move a a ower ower of of size size 3 from from A o o B usig usig C: C: Goal: sar fiish emp Goal: move move a a ower ower of of size size 2 from from A o o C usig usig B: B: 3 "A" B" C" sar fiish emp 2 "A" C" B" Thigs Thigs o o do: do: movetower(-1, sar, sar, emp, emp, fiish); fiish); Thigs Sysem.ou.pril(sar Thigs o o do: do: "->" "->" fiish); fiish); movetower(-1, movetower(-1, emp, sar, emp, sar, fiish emp, fiish emp,, sar); fiish); sar); fiish); Sysem.ou.pril(sar "->" "->" fiish); fiish); movetower(-1, emp, emp, fiish fiish, sar); sar); Iroducio o Compuer Sciece, Shimo Schocke slide 31 Permuaios The ask: Wrie a mehod lispermuaios(srig s) s) ha ha geeraes a complee se se of of all all he he permuaios of of he he characers i i s. s. For For eample, lispermuaios( abcd ) will will geerae: abcd abcd bacd bacd cabd cabd dabc dabc abdc abdc badc badc cadb cadb dacb dacb acbd acbd bcad bcad cbad cbad dbac dbac acdb acdb bcda bcda cbda cbda dbca dbca adbc adbc bdac bdac cdab cdab dcab dcab adcb adcb bdca bdca cdba cdba dcba dcba (oe (oe afer afer he he oher) Observaios: If legh(s), here are (-1) (-2) 1! permuaios he lis of permuaios sarig wih a coais he prefi a followed by all he permuaios of bcd Iroducio o Compuer Sciece, Shimo Schocke slide 32

17 Sraegy Give Give "abcd" "abcd" we we have have o o geerae: abcd abcd bacd bacd cabd cabd dabc dabc abdc abdc badc badc cadb cadb dacb dacb acbd acbd bcad bcad cbad cbad dbac dbac acdb acdb bcda bcda cbda cbda dbca dbca adbc adbc bdac bdac cdab cdab dcab dcab adcb adcb bdca bdca cdba cdba dcba dcba Pri 'a' all permuaios of "abcd" wihou chara 0 Pri 'b' all permuaios of "abcd wihou chara 1 Pri 'c' all permuaios of "abcd wihou chara 2 Pri 'd' all permuaios of "abcd wihou chara 3 Srig Srig wihou wihou chara(i): res res s.subsrig(0,i) s.subsrig(i1, s.legh()); Iroducio o Compuer Sciece, Shimo Schocke slide 33 Implemeaio class class LisPermuaiosDemo LisPermuaiosDemo mai(srig[] mai(srig[] args) args) lispermuaios("abcd"); lispermuaios("abcd"); lispermuaios(srig lispermuaios(srig s) s) lispermuaios("", lispermuaios("", s); s); privae privae lispermuaios(srig lispermuaios(srig prefi, prefi, Srig Srig s) s) (s.legh() (s.legh() Sysem.ou.pril(prefi); Sysem.ou.pril(prefi); for for (i (i i0 i0 ; ; i<s.legh() i<s.legh() ; ; i) i) char char ch ch s.chara(i); s.chara(i); Srig Srig res res s.subsrig(0,i) s.subsrig(0,i) s.subsrig(i1); s.subsrig(i1); lispermuaios(prefi lispermuaios(prefi ch, ch, res); res); Iroducio o Compuer Sciece, Shimo Schocke slide 34

18 Fracals Fracal: A geomeric shape ha ca be spli io pars, each of which is (eiher eacly or approimaely) a reduced-size copy of he whole Some well-kow fracal shapes: Sierpiski riagles Koch sowflake Typical geeraive sraegy: Iroducio o Compuer Sciece, Shimo Schocke slide 35 TurleFracal DrawFracal(500, 1) DrawFracal(500, 2) DrawFracal(500, 3) DrawFracal(500, 4) Iroducio o Compuer Sciece, Shimo Schocke slide 36

19 Implemeaio class class TurleFracal Turle Turle urle urle ew ew Turle(); Turle(); mai(srig[] args) args) urle.aildow(); drawfracal(500,2); drawfracal(i legh, legh, i i level) level) (level urle.moveforward(legh); drawfracal(legh/3, level-1); level-1); urle.urlef(6; drawfracal(legh/3, level-1); level-1); urle.urrigh(12; drawfracal(legh/3, level-1); level-1); urle.urlef(6; drawfracal(legh/3, level-1); level-1); Iroducio o Compuer Sciece, Shimo Schocke slide 37 Fracals Iroducio o Compuer Sciece, Shimo Schocke slide 38

Lecture Recursion. Introduction to Computer Science, Shimon Schocken slide 1

Lecture Recursion. Introduction to Computer Science, Shimon Schocken slide 1 Lecure 12-1 Recursio Iroducio o Compuer Sciece, Shimo Schocke slide 1 Recursio Recursio: a fudameal algorihmic echique, based o divide ad coquer Recursive fucio: a mahemaical fucio defied i erms of iself.

More information

Definition: A complete graph is a graph with N vertices and an edge between every two vertices.

Definition: A complete graph is a graph with N vertices and an edge between every two vertices. Complete Graphs Let N be a positive integer. Definition: A complete graph is a graph with N vertices and an edge between every two vertices. There are no loops. Every two vertices share exactly one edge.

More information

FINITE DIFFERENCE SOLUTIONS TO THE TIME DEPENDENT HEAT CONDUCTION EQUATIONS. T T q 1 T + = (1)

FINITE DIFFERENCE SOLUTIONS TO THE TIME DEPENDENT HEAT CONDUCTION EQUATIONS. T T q 1 T + = (1) Recall he ime depede hea coducio equaio FINIE DIFFERENCE SOLUIONS O HE IME DEPENDEN HEA CONDUCION EQUAIONS + q () We have already ee how o dicreize he paial variable ad approimae paial derivaive. he ame

More information

Recursion. Recursion. Mathematical induction: example. Recursion. The sum of the first n odd numbers is n 2 : Informal proof: Principle:

Recursion. Recursion. Mathematical induction: example. Recursion. The sum of the first n odd numbers is n 2 : Informal proof: Principle: Recursio Recursio Jordi Cortadella Departmet of Computer Sciece Priciple: Reduce a complex problem ito a simpler istace of the same problem Recursio Itroductio to Programmig Dept. CS, UPC 2 Mathematical

More information

COMP26120: Algorithms and Imperative Programming

COMP26120: Algorithms and Imperative Programming COMP26120 ecure C3 1/48 COMP26120: Algorihms and Imperaive Programming ecure C3: C - Recursive Daa Srucures Pee Jinks School of Compuer Science, Universiy of Mancheser Auumn 2011 COMP26120 ecure C3 2/48

More information

Effective Test Case Prioritization Technique in Web Application for Regression Test Suite

Effective Test Case Prioritization Technique in Web Application for Regression Test Suite Available Online at www.ijcsmc.com International Journal of Computer Science and Mobile Computing A Monthly Journal of Computer Science and Information Technology IJCSMC, Vol. 3, Issue. 11, November 2014,

More information

Shortest Path Algorithms. Lecture I: Shortest Path Algorithms. Example. Graphs and Matrices. Setting: Dr Kieran T. Herley.

Shortest Path Algorithms. Lecture I: Shortest Path Algorithms. Example. Graphs and Matrices. Setting: Dr Kieran T. Herley. Shores Pah Algorihms Background Seing: Lecure I: Shores Pah Algorihms Dr Kieran T. Herle Deparmen of Compuer Science Universi College Cork Ocober 201 direced graph, real edge weighs Le he lengh of a pah

More information

Algorithm merge(a, B) Algorithm mergesort(s, C) Output sorted sequence of A B elements, comparator C. sorted sequences A { Output sequence S sort

Algorithm merge(a, B) Algorithm mergesort(s, C) Output sorted sequence of A B elements, comparator C. sorted sequences A { Output sequence S sort COMP0: Daa Srucures ad Alorihms Week Eih: Soris ad Ses Hui Wu Sessio, 0 hp://www.cse.usw.edu.au/~cs0 Oulie Mere Sor Quick Sor BuckeSor Radix Sor Sori Lower Boud UioFid Pariio Srucures DivideadCoquer Mere

More information

Common Fixed Point Theorem of two Self Mappings in Fuzzy Normed Spaces

Common Fixed Point Theorem of two Self Mappings in Fuzzy Normed Spaces Ier J Fuzzy Maheaical Archive Vol 3, No, 07, 77-8 ISSN: 30 34 (P), 30 350 (olie) Published o 6 Sepeber 07 wwwresearchahsciorg DOI: hp://dxdoiorg/0457/ijfav3a8 Ieraioal Joural of Coo Fixed Poi Theore of

More information

Algorithm Design Techniques. Divide and conquer Problem

Algorithm Design Techniques. Divide and conquer Problem Algorithm Desig Techiques Divide ad coquer Problem Divide ad Coquer Algorithms Divide ad Coquer algorithm desig works o the priciple of dividig the give problem ito smaller sub problems which are similar

More information

Abstract. 1. Introduction. A.K.Ojha 1 and A.K.Das 2. Orissa , India. Bhadrak, Orissa , India

Abstract. 1. Introduction. A.K.Ojha 1 and A.K.Das 2. Orissa , India. Bhadrak, Orissa , India IJCSI Ieraioal Joural of Compuer Sciece Issues, Vol. 7, Issue 1, No. 2, Jauary 2010 ISSN (Olie: 1694-0784 49 ISSN (Pri: 1694-0814 A.K.Oha 1 ad A.K.Das 2 1 School of Basic Scieces, I.I.T Bhubaeswar Orissa-751013,

More information

Recursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames

Recursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames Uit 4, Part 3 Recursio Computer Sciece S-111 Harvard Uiversity David G. Sulliva, Ph.D. Review: Method Frames Whe you make a method call, the Java rutime sets aside a block of memory kow as the frame of

More information

Lexisearch Approach to Travelling Salesman Problem

Lexisearch Approach to Travelling Salesman Problem IOSR Journal of Mathematics (IOSR-JM) e-issn: 2278-5728,p-ISSN: 2319-765X, Volume 6, Issue 4 (May. - Jun. 2013), PP 01-08 Lexisearch Approach to Travelling Salesman Problem G.Vijaya Lakshmi Abstract: The

More information

Data Structures and Algorithms. The material for this lecture is drawn, in part, from The Practice of Programming (Kernighan & Pike) Chapter 2

Data Structures and Algorithms. The material for this lecture is drawn, in part, from The Practice of Programming (Kernighan & Pike) Chapter 2 Daa Srucures and Algorihms The maerial for his lecure is drawn, in par, from The Pracice of Programming (Kernighan & Pike) Chaper 2 1 Moivaing Quoaion Every program depends on algorihms and daa srucures,

More information

Assignment #2 Sample Solutions

Assignment #2 Sample Solutions CS 470/670 Intro to Artificial Intelligence Spring 2016 Instructor: Marc Pomplun Assignment #2 Sample Solutions Question 1: Living in Another World Imagine a world that is much more exciting than the one

More information

Surface Design based on Geometric Flow Method and Tessellation

Surface Design based on Geometric Flow Method and Tessellation Surface Desig based o Geomeric Flow Mehod ad essellaio Haogui CHEN Hua Ciy Uiversiy, Yiyag, Hua 43, CHNA Absrac: his paper combies geomeric flow mehod wih essellaio ad make full use of heir respecive sreghs

More information

4. Minimax and planning problems

4. Minimax and planning problems CS/ECE/ISyE 524 Inroducion o Opimizaion Spring 2017 18 4. Minima and planning problems ˆ Opimizing piecewise linear funcions ˆ Minima problems ˆ Eample: Chebyshev cener ˆ Muli-period planning problems

More information

Tree-Pattern Queries on a Lightweight XML Processor

Tree-Pattern Queries on a Lightweight XML Processor Tree-Pattern Queries on a Lightweight XML Processor MIRELLA M. MORO Zografoula Vagena Vassilis J. Tsotras Research partially supported by CAPES, NSF grant IIS 0339032, UC Micro, and Lotus Interworks Outline

More information

OBSERVATIONS ON THE HYPERBOLA

OBSERVATIONS ON THE HYPERBOLA OBSERVATIONS ON THE HYPERBOLA 87x K.Meea, M.A.Gopala, U.K.Rajalakshmi Former VC, Bharahidasa Uiversi, Trich-60 04 Professor, Deparme of Mahemaics, SIGC, Trich-60 00 M.Phil Scholar, Deparme of Mahemaics,

More information

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1 COSC 1P03 Ch 7 Recursio Itroductio to Data Structures 8.1 COSC 1P03 Recursio Recursio I Mathematics factorial Fiboacci umbers defie ifiite set with fiite defiitio I Computer Sciece sytax rules fiite defiitio,

More information

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13 CIS Data Structures ad Algorithms with Java Sprig 08 Stacks ad Queues Moday, February / Tuesday, February Learig Goals Durig this lab, you will: Review stacks ad queues. Lear amortized ruig time aalysis

More information

Lecture 18: Mix net Voting Systems

Lecture 18: Mix net Voting Systems 6.897: Advanced Topics in Crypography Apr 9, 2004 Lecure 18: Mix ne Voing Sysems Scribed by: Yael Tauman Kalai 1 Inroducion In he previous lecure, we defined he noion of an elecronic voing sysem, and specified

More information

Comparing Trees Via Crossing Minimization

Comparing Trees Via Crossing Minimization Comparing Trees Via Crossing Minimization 457 Henning Fernau 1,2, Michael Kaufmann 1, and Mathias Poths 1 1 Univ. Tübingen, WSI für Informatik, Sand 13, 72076 Tübingen, Germany {fernau/mk/poths}@informatik.uni-tuebingen.de

More information

Spline Curves. Color Interpolation. Normal Interpolation. Last Time? Today. glshademodel (GL_SMOOTH); Adjacency Data Structures. Mesh Simplification

Spline Curves. Color Interpolation. Normal Interpolation. Last Time? Today. glshademodel (GL_SMOOTH); Adjacency Data Structures. Mesh Simplification Las Time? Adjacency Daa Srucures Spline Curves Geomeric & opologic informaion Dynamic allocaion Efficiency of access Mesh Simplificaion edge collapse/verex spli geomorphs progressive ransmission view-dependen

More information

Sorting 9/15/2009. Sorting Problem. Insertion Sort: Soundness. Insertion Sort. Insertion Sort: Running Time. Insertion Sort: Soundness

Sorting 9/15/2009. Sorting Problem. Insertion Sort: Soundness. Insertion Sort. Insertion Sort: Running Time. Insertion Sort: Soundness 9/5/009 Algorithms Sortig 3- Sortig Sortig Problem The Sortig Problem Istace: A sequece of umbers Objective: A permutatio (reorderig) such that a ' K a' a, K,a a ', K, a' of the iput sequece The umbers

More information

Rational offset approximation of rational Bézier curves *

Rational offset approximation of rational Bézier curves * Cheg e al. / Zhejiag Uiv SCIECE A 6 7(9):56-565 56 oural of Zhejiag Uiversiy SCIECE A ISS 9-395 (Pri); ISS 86-775 (lie) www.zju.edu.c/jzus; www.sprigerlik.com E-mail: jzus@zju.edu.c Raioal offse approximaio

More information

Recursion. A problem solving technique where an algorithm is defined in terms of itself. A recursive method is a method that calls itself

Recursion. A problem solving technique where an algorithm is defined in terms of itself. A recursive method is a method that calls itself Recursio 1 A probem sovig techique where a agorithm is defied i terms of itsef A recursive method is a method that cas itsef A recursive agorithm breaks dow the iput or the search space ad appies the same

More information

Fill in the following table for the functions shown below.

Fill in the following table for the functions shown below. By: Carl H. Durney and Neil E. Coer Example 1 EX: Fill in he following able for he funcions shown below. he funcion is odd he funcion is even he funcion has shif-flip symmery he funcion has quarer-wave

More information

Breitung s nonparametric unit root tests., (1) which you want to test against the alternative hypothesis that is a zero-mean stationary process: H 1

Breitung s nonparametric unit root tests., (1) which you want to test against the alternative hypothesis that is a zero-mean stationary process: H 1 Breiug s oparaeric ui roo ess. The Breiug ess. The ui roo hypohesis versus zero-ea saioariy Cosider he ull hypohesis ha he ie series, =,..,, is a ui roo process: Y H : Y ' Y & % U, () which you wa o es

More information

NEWTON S SECOND LAW OF MOTION

NEWTON S SECOND LAW OF MOTION Course and Secion Dae Names NEWTON S SECOND LAW OF MOTION The acceleraion of an objec is defined as he rae of change of elociy. If he elociy changes by an amoun in a ime, hen he aerage acceleraion during

More information

STEREO PLANE MATCHING TECHNIQUE

STEREO PLANE MATCHING TECHNIQUE STEREO PLANE MATCHING TECHNIQUE Commission III KEY WORDS: Sereo Maching, Surface Modeling, Projecive Transformaion, Homography ABSTRACT: This paper presens a new ype of sereo maching algorihm called Sereo

More information

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 9 Poiters ad Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 9.1 Poiters 9.2 Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 9-3

More information

Sam knows that his MP3 player has 40% of its battery life left and that the battery charges by an additional 12 percentage points every 15 minutes.

Sam knows that his MP3 player has 40% of its battery life left and that the battery charges by an additional 12 percentage points every 15 minutes. 8.F Baery Charging Task Sam wans o ake his MP3 player and his video game player on a car rip. An hour before hey plan o leave, he realized ha he forgo o charge he baeries las nigh. A ha poin, he plugged

More information

EECS 487: Interactive Computer Graphics

EECS 487: Interactive Computer Graphics EECS 487: Ineracive Compuer Graphics Lecure 7: B-splines curves Raional Bézier and NURBS Cubic Splines A represenaion of cubic spline consiss of: four conrol poins (why four?) hese are compleely user specified

More information

Lecture 5: Recursion. Recursion Overview. Recursion is a powerful technique for specifying funclons, sets, and programs

Lecture 5: Recursion. Recursion Overview. Recursion is a powerful technique for specifying funclons, sets, and programs CS/ENGRD 20 Object- Orieted Programmig ad Data Structures Sprig 202 Doug James Visual Recursio Lecture : Recursio http://seredip.brymawr.edu/exchage/files/authors/faculty/39/literarykids/ifiite_mirror.jpg!

More information

Texture Classification Using N-Tuple Pattern Recognition

Texture Classification Using N-Tuple Pattern Recognition Texture Classification Using N-Tuple Pattern Recognition L.Hepplewhite & T. J. Stonham Department of Electronics and Electrical Engineering Brunel University, Uxbridge, Middlesex, UB8 3PH, U.K. Email:

More information

A Principled Approach to. MILP Modeling. Columbia University, August Carnegie Mellon University. Workshop on MIP. John Hooker.

A Principled Approach to. MILP Modeling. Columbia University, August Carnegie Mellon University. Workshop on MIP. John Hooker. Slide A Principled Approach o MILP Modeling John Hooer Carnegie Mellon Universiy Worshop on MIP Columbia Universiy, Augus 008 Proposal MILP modeling is an ar, bu i need no be unprincipled. Slide Proposal

More information

CENG 477 Introduction to Computer Graphics. Modeling Transformations

CENG 477 Introduction to Computer Graphics. Modeling Transformations CENG 477 Inroducion o Compuer Graphics Modeling Transformaions Modeling Transformaions Model coordinaes o World coordinaes: Model coordinaes: All shapes wih heir local coordinaes and sies. world World

More information

Data Structures and Algorithms

Data Structures and Algorithms Daa Srucures and Algorihms The maerial for his lecure is drawn, in ar, from The Pracice of Programming (Kernighan & Pike) Chaer 2 1 Goals of his Lecure Hel you learn (or refresh your memory) abou: Common

More information

IMP: Superposer Integrated Morphometrics Package Superposition Tool

IMP: Superposer Integrated Morphometrics Package Superposition Tool IMP: Superposer Itegrated Morphometrics Package Superpositio Tool Programmig by: David Lieber ( 03) Caisius College 200 Mai St. Buffalo, NY 4208 Cocept by: H. David Sheets, Dept. of Physics, Caisius College

More information

Available online at ScienceDirect. Procedia Computer Science 60 (2015 )

Available online at   ScienceDirect. Procedia Computer Science 60 (2015 ) Available olie a www.sciecedirec.com ScieceDirec Procedia Compuer Sciece 60 (2015 ) 1809 1816 19h Ieraioal Coferece o Kowledge Based ad Iellige Iformaio ad Egieerig Sysems Color disiciveess feaure for

More information

Motor Control. 5. Control. Motor Control. Motor Control

Motor Control. 5. Control. Motor Control. Motor Control 5. Conrol In his chaper we will do: Feedback Conrol On/Off Conroller PID Conroller Moor Conrol Why use conrol a all? Correc or wrong? Supplying a cerain volage / pulsewidh will make he moor spin a a cerain

More information

Hybrid Meta-heuristic Frameworks : A Functional Approach

Hybrid Meta-heuristic Frameworks : A Functional Approach Hybrid Meta-heuristic Frameworks : A Functional Approach by Richard James Senington Submitted in accordance with the requirements for the degree of Doctor of Philosophy. The University of Leeds School

More information

ADNAN MAHMOOD ADVISOR: DR. HONGYI CHEN. December 2011

ADNAN MAHMOOD ADVISOR: DR. HONGYI CHEN. December 2011 SOFTWARE IMPLEMENTATION OF HIERARCHICAL DECISION MODELING AND HIERARCHICAL DECISION MODELING SENSITIVITY ANALYSIS A THESIS SUBMITTED TO THE FACULTY OF THE GRADUATE SCHOOL OF THE UNIVERSITY OF MINNESOTA

More information

Recurrent Formulas of the Generalized Fibonacci Sequences of Third & Fourth Order

Recurrent Formulas of the Generalized Fibonacci Sequences of Third & Fourth Order Natioal Coferece o 'Advaces i Computatioal Mathematics' 7-8 Sept.03 :- 49 Recurret Formulas of the Geeralized Fiboacci Sequeces of hird & Fourth Order A. D.Godase Departmet of Mathematics V.P.College Vaijapur

More information

Parametric Polynomial Curves

Parametric Polynomial Curves Parameric Polyomial Curves Dr. David J Sahl, Jr. US Naval Academy sahl@usa.edu Absrac: Splie curves ad surface paches have a iae mahemaical beauy ad broad pracical applicaio i he field of compuer graphics.

More information

Lecture Notes 6 Introduction to algorithm analysis CSS 501 Data Structures and Object-Oriented Programming

Lecture Notes 6 Introduction to algorithm analysis CSS 501 Data Structures and Object-Oriented Programming Lecture Notes 6 Itroductio to algorithm aalysis CSS 501 Data Structures ad Object-Orieted Programmig Readig for this lecture: Carrao, Chapter 10 To be covered i this lecture: Itroductio to algorithm aalysis

More information

Chapter Six Chapter Six

Chapter Six Chapter Six Chaper Si Chaper Si 0 CHAPTER SIX ConcepTess and Answers and Commens for Secion.. Which of he following graphs (a) (d) could represen an aniderivaive of he funcion shown in Figure.? Figure. (a) (b) (c)

More information

UNIT OBJECTIVES. unit 3 POLYGON basics 59

UNIT OBJECTIVES. unit 3 POLYGON basics 59 UNIT 3 Polygo Basics The origis of baseball i he Uied Saes are o clear, bu i is believed ha professioal baseball bega i he id-1800s. Today s rules of baseball, icludig he layou of he field, ca be raced

More information

How do we evaluate algorithms?

How do we evaluate algorithms? F2 Readig referece: chapter 2 + slides Algorithm complexity Big O ad big Ω To calculate ruig time Aalysis of recursive Algorithms Next time: Litterature: slides mostly The first Algorithm desig methods:

More information

TensorFaces: Multilinear Model Approach. PIE Database (Weizmann) TensorFacesvsEigenfaces (PCA)

TensorFaces: Multilinear Model Approach. PIE Database (Weizmann) TensorFacesvsEigenfaces (PCA) Muliliea epeseaio of Image Esembles fo ecogiio ad Compessio he Poblem wih Liea () Appeaace Based ecogiio Mehods Eigeimages wok bes fo ecogiio whe oly a sigle faco eg, objec ideiy is allowed o vay aual

More information

. Written in factored form it is easy to see that the roots are 2, 2, i,

. Written in factored form it is easy to see that the roots are 2, 2, i, CMPS A Itroductio to Programmig Programmig Assigmet 4 I this assigmet you will write a java program that determies the real roots of a polyomial that lie withi a specified rage. Recall that the roots (or

More information

Assignment 2. Due Monday Feb. 12, 10:00pm.

Assignment 2. Due Monday Feb. 12, 10:00pm. Faculy of rs and Science Universiy of Torono CSC 358 - Inroducion o Compuer Neworks, Winer 218, LEC11 ssignmen 2 Due Monday Feb. 12, 1:pm. 1 Quesion 1 (2 Poins): Go-ack n RQ In his quesion, we review how

More information

Lecture 1: Introduction and Strassen s Algorithm

Lecture 1: Introduction and Strassen s Algorithm 5-750: Graduate Algorithms Jauary 7, 08 Lecture : Itroductio ad Strasse s Algorithm Lecturer: Gary Miller Scribe: Robert Parker Itroductio Machie models I this class, we will primarily use the Radom Access

More information

Algorithm. Counting Sort Analysis of Algorithms

Algorithm. Counting Sort Analysis of Algorithms Algorithm Coutig Sort Aalysis of Algorithms Assumptios: records Coutig sort Each record cotais keys ad data All keys are i the rage of 1 to k Space The usorted list is stored i A, the sorted list will

More information

Computer representations of piecewise

Computer representations of piecewise Edior: Gabriel Taubin Inroducion o Geomeric Processing hrough Opimizaion Gabriel Taubin Brown Universiy Compuer represenaions o piecewise smooh suraces have become vial echnologies in areas ranging rom

More information

MATH Differential Equations September 15, 2008 Project 1, Fall 2008 Due: September 24, 2008

MATH Differential Equations September 15, 2008 Project 1, Fall 2008 Due: September 24, 2008 MATH 5 - Differenial Equaions Sepember 15, 8 Projec 1, Fall 8 Due: Sepember 4, 8 Lab 1.3 - Logisics Populaion Models wih Harvesing For his projec we consider lab 1.3 of Differenial Equaions pages 146 o

More information

condition w i B i S maximum u i

condition w i B i S maximum u i ecture 10 Dyamic Programmig 10.1 Kapsack Problem November 1, 2004 ecturer: Kamal Jai Notes: Tobias Holgers We are give a set of items U = {a 1, a 2,..., a }. Each item has a weight w i Z + ad a utility

More information

Curves & Surfaces. Last Time? Today. Readings for Today (pick one) Limitations of Polygonal Meshes. Today. Adjacency Data Structures

Curves & Surfaces. Last Time? Today. Readings for Today (pick one) Limitations of Polygonal Meshes. Today. Adjacency Data Structures Las Time? Adjacency Daa Srucures Geomeric & opologic informaion Dynamic allocaion Efficiency of access Curves & Surfaces Mesh Simplificaion edge collapse/verex spli geomorphs progressive ransmission view-dependen

More information

MOTION DETECTORS GRAPH MATCHING LAB PRE-LAB QUESTIONS

MOTION DETECTORS GRAPH MATCHING LAB PRE-LAB QUESTIONS NME: TE: LOK: MOTION ETETORS GRPH MTHING L PRE-L QUESTIONS 1. Read he insrucions, and answer he following quesions. Make sure you resae he quesion so I don hae o read he quesion o undersand he answer..

More information

The isoperimetric problem on the hypercube

The isoperimetric problem on the hypercube The isoperimetric problem o the hypercube Prepared by: Steve Butler November 2, 2005 1 The isoperimetric problem We will cosider the -dimesioal hypercube Q Recall that the hypercube Q is a graph whose

More information

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19 CIS Data Structures ad Algorithms with Java Sprig 09 Stacks, Queues, ad Heaps Moday, February 8 / Tuesday, February 9 Stacks ad Queues Recall the stack ad queue ADTs (abstract data types from lecture.

More information

Analysis of Algorithms

Analysis of Algorithms Aalysis of Algorithms Ruig Time of a algorithm Ruig Time Upper Bouds Lower Bouds Examples Mathematical facts Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite

More information

RULES OF DIFFERENTIATION LESSON PLAN. C2 Topic Overview CALCULUS

RULES OF DIFFERENTIATION LESSON PLAN. C2 Topic Overview CALCULUS CALCULUS C Topic Overview C RULES OF DIFFERENTIATION In pracice we o no carry ou iffereniaion from fir principle (a ecribe in Topic C Inroucion o Differeniaion). Inea we ue a e of rule ha allow u o obain

More information

Design and implementation of production scheduling system based on genetic algorithm

Design and implementation of production scheduling system based on genetic algorithm Desig ad implemeaio of producio sysem based o geeic algorihm Xiaozhe Li, Boao Liu a, *, Cheyag Xiog, Hui Wag, Yog Li, Yua Zhao Absrac College of Compuer Sciece Yagze Uiversiy, JigZhou 434023, Chia a liuboao920@163.com

More information

Skills Practice Skills Practice for Lesson 6.1

Skills Practice Skills Practice for Lesson 6.1 Skills Practice Skills Practice for Lesson.1 Name Date Quilting and Tessellations Introduction to Quadrilaterals Vocabulary Write the term that best completes each statement. 1. A quadrilateral with all

More information

Our second algorithm. Comp 135 Machine Learning Computer Science Tufts University. Decision Trees. Decision Trees. Decision Trees.

Our second algorithm. Comp 135 Machine Learning Computer Science Tufts University. Decision Trees. Decision Trees. Decision Trees. Comp 135 Machie Learig Computer Sciece Tufts Uiversity Fall 2017 Roi Khardo Some of these slides were adapted from previous slides by Carla Brodley Our secod algorithm Let s look at a simple dataset for

More information

Package RcppRoll. December 22, 2014

Package RcppRoll. December 22, 2014 Type Package Package RcppRoll December 22, 2014 Title Fast rollig fuctios through Rcpp ad RcppArmadillo Versio 0.1.0 Date 2013-01-10 Author Kevi Ushey Maitaier Kevi Ushey RcppRoll

More information

CSE 2320 Notes 8: Sorting. (Last updated 10/3/18 7:16 PM) Idea: Take an unsorted (sub)array and partition into two subarrays such that.

CSE 2320 Notes 8: Sorting. (Last updated 10/3/18 7:16 PM) Idea: Take an unsorted (sub)array and partition into two subarrays such that. CSE Notes 8: Sortig (Last updated //8 7:6 PM) CLRS 7.-7., 9., 8.-8. 8.A. QUICKSORT Cocepts Idea: Take a usorted (sub)array ad partitio ito two subarrays such that p q r x y z x y y z Pivot Customarily,

More information

Alpha Individual Solutions MAΘ National Convention 2013

Alpha Individual Solutions MAΘ National Convention 2013 Alpha Idividual Solutios MAΘ Natioal Covetio 0 Aswers:. D. A. C 4. D 5. C 6. B 7. A 8. C 9. D 0. B. B. A. D 4. C 5. A 6. C 7. B 8. A 9. A 0. C. E. B. D 4. C 5. A 6. D 7. B 8. C 9. D 0. B TB. 570 TB. 5

More information

n Some thoughts on software development n The idea of a calculator n Using a grammar n Expression evaluation n Program organization n Analysis

n Some thoughts on software development n The idea of a calculator n Using a grammar n Expression evaluation n Program organization n Analysis Overview Chapter 6 Writig a Program Bjare Stroustrup Some thoughts o software developmet The idea of a calculator Usig a grammar Expressio evaluatio Program orgaizatio www.stroustrup.com/programmig 3 Buildig

More information

Random-Grid Based Region Incrementing Visual Secret Sharing

Random-Grid Based Region Incrementing Visual Secret Sharing Fudamea Iformaicae 37 05) 8 DOI 0.333/FI-05-80 IOS Press Radom-Grid Based Regio Icremeig Visual Secre Sharig Sachi Kumar, Rajedra Kumar Sharma Deparme of Mahemaics Idia Isiue of Techology Delhi Hauz Khas,

More information

Numerical Solution of ODE

Numerical Solution of ODE Numerical Soluion of ODE Euler and Implici Euler resar; wih(deools): wih(plos): The package ploools conains more funcions for ploing, especially a funcion o draw a single line: wih(ploools): wih(linearalgebra):

More information

Heaps. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015

Heaps. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015 Presetatio for use with the textbook Algorithm Desig ad Applicatios, by M. T. Goodrich ad R. Tamassia, Wiley, 201 Heaps 201 Goodrich ad Tamassia xkcd. http://xkcd.com/83/. Tree. Used with permissio uder

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Pytho Programmig: A Itroductio to Computer Sciece Chapter 6 Defiig Fuctios Pytho Programmig, 2/e 1 Objectives To uderstad why programmers divide programs up ito sets of cooperatig fuctios. To be able to

More information

Real Time Integral-Based Structural Health Monitoring

Real Time Integral-Based Structural Health Monitoring Real Time Inegral-Based Srucural Healh Monioring The nd Inernaional Conference on Sensing Technology ICST 7 J. G. Chase, I. Singh-Leve, C. E. Hann, X. Chen Deparmen of Mechanical Engineering, Universiy

More information

Recursive Procedures. How can you model the relationship between consecutive terms of a sequence?

Recursive Procedures. How can you model the relationship between consecutive terms of a sequence? 6. Recursive Procedures I Sectio 6.1, you used fuctio otatio to write a explicit formula to determie the value of ay term i a Sometimes it is easier to calculate oe term i a sequece usig the previous terms.

More information

Algorithms for fitting cylindrical objects to sparse range point clouds for rapid workspace modeling

Algorithms for fitting cylindrical objects to sparse range point clouds for rapid workspace modeling Algorihms for fiig cylidrical objecs o sparse rage poi clouds for rapid workspace modelig Soo-Wook Kwo GRA/Field Sysems ad Cosrucio Auomaio Lab., The Uiversiy of Texas a Ausi, Ausi, TX 787-76 USA (e-mail:

More information

Today. Curves & Surfaces. Can We Disguise the Facets? Limitations of Polygonal Meshes. Better, but not always good enough

Today. Curves & Surfaces. Can We Disguise the Facets? Limitations of Polygonal Meshes. Better, but not always good enough Today Curves & Surfaces Moivaion Limiaions of Polygonal Models Some Modeling Tools & Definiions Curves Surfaces / Paches Subdivision Surfaces Limiaions of Polygonal Meshes Can We Disguise he Faces? Planar

More information

CS280 HW1 Solution Set Spring2002. now, we need to get rid of the n term. We know that:

CS280 HW1 Solution Set Spring2002. now, we need to get rid of the n term. We know that: CS80 HW Solutio Set Sprig00 Solutios by: Shddi Doghmi -) -) 4 * 4 4 4 ) 4 b-) ) ) ) * ) ) ) 0 ) c-) ) ) ) ) ) ow we eed to get rid of the term. We ow tht: ) ) ) ) substitute ito the recursive epressio:

More information

Last class. n Scheme. n Equality testing. n eq? vs. equal? n Higher-order functions. n map, foldr, foldl. n Tail recursion

Last class. n Scheme. n Equality testing. n eq? vs. equal? n Higher-order functions. n map, foldr, foldl. n Tail recursion Aoucemets HW6 due today HW7 is out A team assigmet Submitty page will be up toight Fuctioal correctess: 75%, Commets : 25% Last class Equality testig eq? vs. equal? Higher-order fuctios map, foldr, foldl

More information

CS 470/670 Intro to Artificial Intelligence Fall 2018 Instructor: Marc Pomplun. Assignment #2. Sample Solutions

CS 470/670 Intro to Artificial Intelligence Fall 2018 Instructor: Marc Pomplun. Assignment #2. Sample Solutions CS 470/670 Intro to Artificial Intelligence Fall 2018 Instructor: Marc Pomplun Assignment #2 Sample Solutions Question 1: Living in Another World Imagine a world that is much more exciting than the one

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Pytho Programmig: A Itroductio to Computer Sciece Chapter 1 Computers ad Programs 1 Objectives To uderstad the respective roles of hardware ad software i a computig system. To lear what computer scietists

More information

Announcements. References. Selinger Optimizer History. More about the Selinger Algorithm. Selinger Algorithm. CSE 444: Database Internals

Announcements. References. Selinger Optimizer History. More about the Selinger Algorithm. Selinger Algorithm. CSE 444: Database Internals Announcements CSE 444: Database Internals Lab 2 deadline EXTENDED by 24 hours Lab 2 quiz moved to Monday Lecture 12 Query Optimization (part 3) 1 2 Selinger Optimizer History References 1960 s: first database

More information

CIS 121 Data Structures and Algorithms with Java Fall Big-Oh Notation Tuesday, September 5 (Make-up Friday, September 8)

CIS 121 Data Structures and Algorithms with Java Fall Big-Oh Notation Tuesday, September 5 (Make-up Friday, September 8) CIS 11 Data Structures ad Algorithms with Java Fall 017 Big-Oh Notatio Tuesday, September 5 (Make-up Friday, September 8) Learig Goals Review Big-Oh ad lear big/small omega/theta otatios Practice solvig

More information

Exceptions. Your computer takes exception. The Exception Class. Causes of Exceptions

Exceptions. Your computer takes exception. The Exception Class. Causes of Exceptions Your computer takes exceptio s s are errors i the logic of a program (ru-time errors). Examples: i thread mai java.io.filenotfoud: studet.txt (The system caot fid the file specified.) i thread mai java.lag.nullpoiter:

More information

Threads and Concurrency in Java: Part 1

Threads and Concurrency in Java: Part 1 Cocurrecy Threads ad Cocurrecy i Java: Part 1 What every computer egieer eeds to kow about cocurrecy: Cocurrecy is to utraied programmers as matches are to small childre. It is all too easy to get bured.

More information

MA/CS 109 Lecture 2. The Konigsberg Bridge Problem And Its generalizabons

MA/CS 109 Lecture 2. The Konigsberg Bridge Problem And Its generalizabons MA/CS 109 Lecture 2 The Konigsberg Bridge Problem And Its generalizabons All Course informabon at hdp://www.cs.bu.edu/fac/snyder/cs109/ Remark: This page will be conbnually updated. First Homework to be

More information

Image segmentation. Motivation. Objective. Definitions. A classification of segmentation techniques. Assumptions for thresholding

Image segmentation. Motivation. Objective. Definitions. A classification of segmentation techniques. Assumptions for thresholding Moivaion Image segmenaion Which pixels belong o he same objec in an image/video sequence? (spaial segmenaion) Which frames belong o he same video sho? (emporal segmenaion) Which frames belong o he same

More information

Threads and Concurrency in Java: Part 1

Threads and Concurrency in Java: Part 1 Threads ad Cocurrecy i Java: Part 1 1 Cocurrecy What every computer egieer eeds to kow about cocurrecy: Cocurrecy is to utraied programmers as matches are to small childre. It is all too easy to get bured.

More information

Pseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance

Pseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Pseudocode ( 1.1) High-level descriptio of a algorithm More structured

More information

CMPSC 274: Transac0on Processing Lecture #6: Concurrency Control Protocols

CMPSC 274: Transac0on Processing Lecture #6: Concurrency Control Protocols CMPSC 274: Transac0on Processing Lecure #6: Concurrency Conrol Proocols Divy Agrawal Deparmen of Compuer Science UC Sana Barbara 4.4.1 Timesamp Ordering 4.4.2 Serializa0on Graph Tes0ng 4.4.3 Op0mis0c Proocols

More information

Counting the Number of Minimum Roman Dominating Functions of a Graph

Counting the Number of Minimum Roman Dominating Functions of a Graph Coutig the Number of Miimum Roma Domiatig Fuctios of a Graph SHI ZHENG ad KOH KHEE MENG, Natioal Uiversity of Sigapore We provide two algorithms coutig the umber of miimum Roma domiatig fuctios of a graph

More information

Quantitative macro models feature an infinite number of periods A more realistic (?) view of time

Quantitative macro models feature an infinite number of periods A more realistic (?) view of time INFINIE-HORIZON CONSUMPION-SAVINGS MODEL SEPEMBER, Inroducion BASICS Quaniaive macro models feaure an infinie number of periods A more realisic (?) view of ime Infinie number of periods A meaphor for many

More information

Normal Distributions

Normal Distributions Normal Distributios Stacey Hacock Look at these three differet data sets Each histogram is overlaid with a curve : A B C A) Weights (g) of ewly bor lab rat pups B) Mea aual temperatures ( F ) i A Arbor,

More information

The VSS CCD photometry spreadsheet

The VSS CCD photometry spreadsheet The VSS CCD photometry spreadsheet Itroductio This Excel spreadsheet has bee developed ad tested by the BAA VSS for aalysig results files produced by the multi-image CCD photometry procedure i AIP4Wi v2.

More information

End Semester Examination CSE, III Yr. (I Sem), 30002: Computer Organization

End Semester Examination CSE, III Yr. (I Sem), 30002: Computer Organization Ed Semester Examiatio 2013-14 CSE, III Yr. (I Sem), 30002: Computer Orgaizatio Istructios: GROUP -A 1. Write the questio paper group (A, B, C, D), o frot page top of aswer book, as per what is metioed

More information

Behavioral Modeling in Verilog

Behavioral Modeling in Verilog Behavioral Modelig i Verilog COE 202 Digital Logic Desig Dr. Muhamed Mudawar Kig Fahd Uiversity of Petroleum ad Mierals Presetatio Outlie Itroductio to Dataflow ad Behavioral Modelig Verilog Operators

More information

COSC 3213: Computer Networks I Chapter 6 Handout # 7

COSC 3213: Computer Networks I Chapter 6 Handout # 7 COSC 3213: Compuer Neworks I Chaper 6 Handou # 7 Insrucor: Dr. Marvin Mandelbaum Deparmen of Compuer Science York Universiy F05 Secion A Medium Access Conrol (MAC) Topics: 1. Muliple Access Communicaions:

More information

CS 111: Program Design I Lecture 19: Networks, the Web, and getting text from the Web in Python

CS 111: Program Design I Lecture 19: Networks, the Web, and getting text from the Web in Python CS 111: Program Desig I Lecture 19: Networks, the Web, ad gettig text from the Web i Pytho Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago April 3, 2018 Goals Lear about Iteret Lear about

More information