- MIT18_100CF12_Prob_Set_1.pdf
- Introduction to Number Theory
- Proofs
- 210-recursion
- N9
- Prime Numbers Public Key Cryptography 969
- HW1 Solutions
- Revision Guide
- 2_Number Patterns and Sequences
- Problem Set 3.pdf
- 10.1.1.48.6234
- Scientia Magna Vol 2 No 3
- Recurrences
- Backstrom on the Determination of Zeros of Te Fibonacci Sequence
- Smarandache k-k additive relationships, by H. Ibstedt
- N T H E T O W E R O F B A B E L : B E Y O N D S Y M M E T R Y I N I S L A M I C D E S I G N
- 2nd Errata
- Goethe- The Experiment as Mediator of Object and Subject
- 2006j Getenet; Inclusion Exclu
- 5th Grade Summer Review
- real numbers
- [Leonard_Gillman]_Writing_Mathematics_Well_A_Manu(BookFi.org).pdf
- How to read a hard math book
- Palindrome Studies (Part 1)
- A Study of Japanese Mathematics, Wasan
- Guia Base de datos
- ON CERTAIN INEQUALITIES INVOLVING THE SMARANDACHE FUNCTION
- Hard Math #3 Explanations
- Methods of Mathematics Proof
- 23 2 prime numbers advanced concept
- Sapiens: A Brief History of Humankind
- The Unwinding: An Inner History of the New America
- Yes Please
- Dispatches from Pluto: Lost and Found in the Mississippi Delta
- Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
- The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution
- John Adams
- Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
- A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
- Grand Pursuit: The Story of Economic Genius
- This Changes Everything: Capitalism vs. The Climate
- The Emperor of All Maladies: A Biography of Cancer
- The Prize: The Epic Quest for Oil, Money & Power
- Team of Rivals: The Political Genius of Abraham Lincoln
- The New Confessions of an Economic Hit Man
- The World Is Flat 3.0: A Brief History of the Twenty-first Century
- Rise of ISIS: A Threat We Can't Ignore
- Smart People Should Build Things: How to Restore Our Culture of Achievement, Build a Path for Entrepreneurs, and Create New Jobs in America
- The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
- How To Win Friends and Influence People
- Angela's Ashes: A Memoir
- Steve Jobs
- Bad Feminist: Essays
- The Light Between Oceans: A Novel
- Leaving Berlin: A Novel
- The Silver Linings Playbook: A Novel
- The Sympathizer: A Novel (Pulitzer Prize for Fiction)
- Extremely Loud and Incredibly Close: A Novel
- You Too Can Have a Body Like Mine: A Novel
- The Incarnations: A Novel
- Life of Pi
- The Love Affairs of Nathaniel P.: A Novel
- A Man Called Ove: A Novel
- Bel Canto
- The Master
- We Are Not Ourselves: A Novel
- The First Bad Man: A Novel
- The Rosie Project: A Novel
- The Blazing World: A Novel
- Brooklyn: A Novel
- The Flamethrowers: A Novel
- The Art of Racing in the Rain: A Novel
- Wolf Hall: A Novel
- The Wallcreeper
- Interpreter of Maladies
- Beautiful Ruins: A Novel
- The Kitchen House: A Novel
- The Perks of Being a Wallflower
- The Bonfire of the Vanities: A Novel
- Lovers at the Chameleon Club, Paris 1932: A Novel
- A Prayer for Owen Meany: A Novel
- The Cider House Rules
- Mislaid: A Novel

Text: Read Weiss, §1.1 ± 1.3

Izmir University of Economics

1

Course Policy

Syllabus Grading Labs always in C programming language Each assignment starts and ends in the same Lab session. Late assignments will not be accepted. Study hard!

Izmir University of Economics 2

Introduction See that how a program performs for reasonably large input is just as important as its performance on moderate amounts of input Summarize basic mathematical background needed Review recursion Izmir University of Economics 3 .

A simulation with a random file of 10 million elements and k = 5. If the new element read is smaller than the last.000 shows that each requires several days of computer processing. Sort them in decreasing order. Next read the remaining elements one by one. Izmir University of Economics 4 . II: read the first k elements into the array. Return the kth element.000. I: read them into an array.Motivating Examples: Selection Selection problem: you have a group of N numbers and would like to determine the kth largest. Sort them in decreasing order. ignore it otherwise place in the correct spot in the array bumping one element out of the array.

vertically or diagonally in either direction. {this. test whether the word is in the word list. The objective is to find the words lying horizontally. that} Izmir University of Economics 5 . check (row. two. column.Motivating Examples: Word Puzzles Solving a popular word puzzle: Input consists of a two dimensional array of letters and a list of words. fat. orientation. number of characters). column. I: for each word in the word list. orientation) II: for each ordered quadruple (row.

Math Review .Exponents XAXB = XA+B XA/XB = XA-B (XA)B = XAB XN+XN = 2XN !=X2N Izmir University of Economics 6 .

A != 1 Proof: Let X=logCB. and 2Z=AB. B=CX=(CY)Z. AZ=B by Definition 1. Definition 1. logAB = logCB/logCA where A. 2X=A.2. Y=logCA. X=YZ Theorem 1. Y=logB. CY=A.1. B > 0 Proof: X=logA.1.Therefore. log AB = logA + logB where A. all logarithms are to the base 2 unless specified otherwise. 2Y=B. and Z=logAB.1. XA = B iff logXB=A Theorem 1. B. Z=logAB CX=B. C > 0.Math Review ± Logarithms I In computer science. 2X2Y=AB=2Z. Therefore. X+Y=Z Izmir University of Economics 7 .

Math Review ± Logarithms II log A/B = logA ± logB log(AB)=BlogA logX < X for all X > 0 log1 = 0. log1024 = 10 Izmir University of Economics 8 . log2 = 1.

. then and as N tends to g. the sum approaches 1/(1-A) S=1+A+A2+A3+A4... S-AS= 1 which implies S=1/(1-A) Izmir University of Economics 9 N i 1 A e § 1 A i !0 .. AS=A+A2+A3+A4+A5.Math Review ± Series I Geometric Series N i § 2 ! 2 N 1 1 i !0 N i A N 1 1 §A ! A1 i !0 If 0 < A < 1.

1 __________ __________ __________ _ 2S ! N 1 N 1 N 1 .. 2 2 2 1 1 1 2S S ! S ! 1 2 3 . 2 2 2 2 2 3 4 2S ! 1 2 3 ...Math Review ± Series II i §i !1i / 2 ! ? 1 2 3 4 S ! 2 3 4 ....... N 1 S ! N ( N 1) / 2 Izmir University of Economics xample : k k k § 3i 1 ! § 3i §1 i !1 i !1 i !1 k k 3 § i §1 i !1 i !1 3k (k 1) / 2 k k (3k 1) / 2 10 .. ! 2 2 2 2 Arithmetic Series N N ( N 1) N 2 (Gauss Method ) } §i ! 2 2 i !1 2 3 ... N S ! 1 S ! N N 1 N 2 .

57721566 eneral lgebraic Manipulations N § f ( N ) ! Nf ( N ) i !1 n 1 N N 0 § f (i) ! § f (i) § f (i) i ! n0 i !1 i !1 Izmir University of Economics 11 .Math Review ± Series III N 2 §i ! S i !1 N 3 3 ! N i3 N (i 1)3 ! N 3 § i (i 1) § § i !1 i !1 i !1 N 3 3 2 N 2 § i (i 3i 3i 1) ! § 3i 3i 1 i !1 i !1 N 3 !3S 3N ( N 1) / 2 N S ! ( N 3 3N ( N 1) / 2 N ) / 3 S ! N ( N 2 3( N 1) / 21) / 3 S ! N (2 N 2 3( N 1) 2) / 6 S ! N (2 N 2 3N 1) / 6 S ! N ( N 1)(2 N 1) / 6 } N3 /3 N k N k 1 when k { 1 §i } k 1 i !1 N th Harmonic Series N1 when k ! 1 H ! § }log N e N i !1 i The error in the approximation tends to Euler¶s constant K = 0.

If N divides A-B (remainders are the same) Example:81 | 61 | 1 (mod 10) if A | B (mod N).Math Review ± Modular Arithmetic A | B (mod N) means A is congruent to B modulo N. then A + C | B + C (mod N) and AD | BD (mod N) Izmir University of Economics 12 .

Establishing that a theorem is true for some small (usually degenerate) value(s). an inductive hypothesis is assumed.The P Word ± Proof by Induction There are various ways of proving statements in data structures analysis Proof by Induction: It has two standart parts: The first step is proving a base case. the theorem is then shown to be true for the next value. Generally this means that the theorem is assumed to be true for all cases up to some limit k. typically k+1.Using the assumption. Next. Izmir University of Economics 13 . This step is almost always trivial.

k. . !F F F k 1 k k 1 (5 / 3) k (5 / 3) k 1 F k 1 (3 / 5)(5 / 3) k 1 (3 / 5) 2 (5 / 3) k 1 F k 1 (3 / 5 9 / 25)(5 / 3) k 1 F k 1 (24 / 25)(5 / 3) k 1 F k 1 (5 / 3) k 1 F k 1 Izmir University of Economics 14 . F1=1. satisfy Fi < (5/3)i for i 1... F2 = 2 < (5/3)2.. 2. this is the inductive hypothesis. and Fi=Fi-1+Fi-2 for i > 1.The P Word ± Induction Example I Example: Prove that Fibonacci Numbers F0=1. We now assume that the theorem is true for i = 1. Proof: Verify that the theorem is true for the trivial cases (base cases): F1=1 < (5/3)1 and. we need to prove Fk+1<(5/3)k+1. These prove the basis. To prove the theorem.

Let¶s try to prove that it is true for N + 1 N 1 2 N 2 § i ! § i ( N 1)2 i !1 i !1 N 1 2 N ( N 1)(2 N 1) ( N 1)2 by § i ! 6 i !1 « N (2 N 1) » ! ( N 1)¬ ( N 1)¼ 6 ½ 2N 2 7 N 6 ! ( N 1) 6 ( N 1)( N 2)(2 N 3) ! 6 Izmir University of Economics 15 Inductive Hypothesis .The P Word ± Induction Example II Example: If N 1 then §iN 1i 2 ! N ( N 1)(2N 1) / 6 ! Proof: For the base case. assume the theorem is true for 1 k N. the theorem is true when N = 1. For the inductive hypothesis.

Example: The statement Fk k2 is false.Proof by Counterexample Proof by Counterexample: Best way for proving that a statement is false. The easiest way to prove this is to compute F11 = 144 > 112 = 121 Izmir University of Economics 16 .

P2. This is a contradiction: numbers are either prime or a product of primes. so by assumption N can not be prime. Clearly... Let P1. and hence the original assumption is erroneous.. Proof: Assume the theorem is false.. N > Pk. . Izmir University of Economics 17 . Pk be all the primes in order and consider N = P1P2. Example: Prove that there is an infinite number of primes. Hence the original assumption is false implying that the theorem is true. none of P1. because remainders are all 1.. However..Proof by Contradiction It proceeds by assuming that the theorem is false and showing that this assumption implies that some known property is false.Pk + 1. so that there is some largest prime Pk. P2... Pk divides N exactly. .

then 2*F(3)+4*4 will be int F( int X ) { required to be computed. calls until a base case. Recursive printf( "F(4) = %d\n". Automatic Bookkeeping } Izmir University of Economics 18 .h> If F is called with a value of 4. Example: f ( x)! 2 f ( x 1) x 2 for all integers x 0 with f(0)=0 #include <stdio. return 0. Thus if( X == 0 ) /* base case */ a call is made to find F(3). F(-1)= return 0.1 ) + X * X. F(4)=2*F(3)+4*4 else return 2 * F( X .A Brief Introduction to Recursion A function that is defined in terms of itself is called recursive. F( 4 ) ). F(3)=2*F(2)+3*3 } F(2)=2*F(1)+2*2 F(1)=2*F(0)+1*1 main( ) { F(0)=0 base case. Not all mathematically recursive functions are correctly or efficiently implemented by recursion.

} Izmir University of Economics 19 . the computer will repeatedly make calls to Bad(1). Bad(N)=Bad(N/3 + 1) + N ± 1 To compute Bad(1).1. it will run out of space #include <stdio. } main( ) { printf( "Bad is infinite recursion\n" ).h> int Bad( unsigned int N ) { if( N == 0 ) return 0. else return Bad( N / 3 + 1 ) + N .Recursion .Bad Bad(0)=0. Eventually. return 0.

which can be solved without recursion. the recursive call must always be to a case that makes progress toward a base case. Izmir University of Economics 20 .I 1) Base cases: You must always have some base cases. 2) Making progress: For the cases to be solved recursively.Fundamental Rules of Recursion .

} is correct. return 0. PrintDigit( N % 10 ). then it } main( ) { PrintOut( 1369 ). PrintDigit(Ch) take a single digit number as character and output it to the terminal #include <stdio.Recursion . Assume it works for all numbers of k or fewer digits. N ! ¬ N / 10¼ N (mod 10) ¬ ¼ ½ By the inductive hypothesis. Proof (by induction): If N has one digit. 21 Izmir University of Economics .h> #define PrintDigit( Ch ) ( putchar( ( Ch ) + '0' ) ) /* Print nonnegative N */ void PrintOut( unsigned int N ) { if( N >= 10 ) Theorem: Recursive number-printing PrintOut( N / 10 ).Induction PrintOut(N) prints out positive integers. first part is printed correctly and then the last digit is appended. algorithm is correct for N 0. A number of k+1 digits is expressed by its first k digits followed by its least significant digit. putchar( '\n' ).

II 3) Design rule: Assume that all the recursive calls work. Hidden bookkeeping costs are mostly justifiable. However. This rule is important. It relieves you of the burden of thinking about the details of bookkeeping. It should never be used as a substitute for a simple loop. Izmir University of Economics 22 . 4) Compound interest rule: Never duplicate work by solving the same instance of a problem in separate calls.Fundamental Rules of Recursion .

- MIT18_100CF12_Prob_Set_1.pdfUploaded byJuang Bhakti Hastyadi
- Introduction to Number TheoryUploaded byjj012586
- ProofsUploaded bytheresa.painter
- 210-recursionUploaded byphatmo
- N9Uploaded byAditya Baid
- Prime Numbers Public Key Cryptography 969Uploaded byBarbara Wendy Juna
- HW1 SolutionsUploaded by陳永傑
- Revision GuideUploaded byAdnan Oomerjee
- 2_Number Patterns and SequencesUploaded byChin Shee Yan
- Problem Set 3.pdfUploaded byhkx0601
- 10.1.1.48.6234Uploaded bySujay Jayakar
- Scientia Magna Vol 2 No 3Uploaded byscience2010
- RecurrencesUploaded bykalai2790
- Backstrom on the Determination of Zeros of Te Fibonacci SequenceUploaded byCeiba Groove
- Smarandache k-k additive relationships, by H. IbstedtUploaded byscience2010
- N T H E T O W E R O F B A B E L : B E Y O N D S Y M M E T R Y I N I S L A M I C D E S I G NUploaded byjamey_mork1
- 2nd ErrataUploaded byAnonymous jSTkQVC27b
- Goethe- The Experiment as Mediator of Object and SubjectUploaded byjorge_lazaro_6
- 2006j Getenet; Inclusion ExcluUploaded byMiliyon Tilahun
- 5th Grade Summer ReviewUploaded byEnssanu
- real numbersUploaded byapi-296824694
- [Leonard_Gillman]_Writing_Mathematics_Well_A_Manu(BookFi.org).pdfUploaded bychrischov
- How to read a hard math bookUploaded byJaqui Cabañitas
- Palindrome Studies (Part 1)Uploaded byMia Amalia
- A Study of Japanese Mathematics, WasanUploaded byJavier Andrés Fernández
- Guia Base de datosUploaded byCarlos V.
- ON CERTAIN INEQUALITIES INVOLVING THE SMARANDACHE FUNCTIONUploaded byRyanElias
- Hard Math #3 ExplanationsUploaded byapi-3740487
- Methods of Mathematics ProofUploaded bySKASTHURI
- 23 2 prime numbers advanced conceptUploaded byapi-299265916