Block 3: Induction & Recursion

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Strong Induction

1. Prove some base case (instead of only using one basis step. Let's look at some values up to k) 2. Show correctness for all input values up to some value k. 3. Inductive step: Show [P(1) ∧ P(2) ... P(k)] -> P(k + 1) Strong induction is a form of mathematical induction where instead of assuming P(k) is true in our inductive hypothesis, we assume P(j) is true for 1 ≤ j ≤ k.

What is Full Binary Trees?

A full binary tree is a tree data structure in which every node has exactly zero or two children, and all leaf nodes are at the same level.

Definiton of prime number

A prime number (or simply prime) is a positive integer p >= 2 that is only divisible by 1 and itself

What is meant by "Proof by Induction". And what is it useful for?

A proof by induction is a way of showing that the statement P(n) is true for all n ∈ Z+. (All positive integers) "We want to show that we can reach step n for all n ∈ Z+, i.e., we can reach every step of the ladder" Induction is a useful tool for proving correctness of an algorithm and calculating running time of programs (time complexity). And more...

What is the difference between a recursive and an iterative algorithm?

A recursive algorithm is a method of solving a problem by calling itself with a simplified version of the input, while an iterative algorithm is a method of solving a problem by repeatedly applying a set of instructions to the input until a certain condition is met.

Mergesort

A sort that divides the list into two parts, sorts those parts, and then brings the sorted parts back together. Merge Sort is a recursive sorting algorithm. It is based on an subroutine (merge) that merges two sorted lists into one sorted list containing all elements from both input lists. The Merge function needs sorted input lists

recursion tree

A visual diagram of an operation done by a recursive function, that separates operations done directly by the function and operations done by recursive calls

Inductive step

Assume P(k) is true, and show that P(k+1) is true.

Well Ordering Principle

Every non-empty set of non-negative integers has a least element. We use the well ordering principle to know where to start when we're using math induction.

Induction: Basis step

First we show that P(1) is true. (base case)

Describe Mergesort

Merge sort is a divide-and-conquer algorithm that repeatedly divides an unsorted array into two subarrays, sorts each subarray, and then merges the sorted subarrays back together to produce the final, sorted array.

What is recursive algorithms and give an example of algorithms

Recursive algorithms are used to solve a problem that can be reduced to a series of smaller problems of the same type. Example: Sorting algorithms MergeSort and QuickSort.

Induction hypothesis

States that the statement p(k) is true for the natural number k, which is the "hypothesis" that you are making in order to prove that the statement is true for k+1.

What is the base case in recursion?

The base case is the stop condition of a recursive function, that specify when the recursion should stop and output a final result

What are the benefits of using recursion?

The benefits of using recursion include: 1. It can simplify the problem by breaking it down into smaller and simpler subproblems 2. It can make the code more elegant and easier to understand 3. It can be more natural or intuitive to express some problems 4. It can be more efficient than non-recursive

Recursive algorithm: Example with factorials

The factorial of n is the number of ways in which the n elements of a group can be ordered. The factorial of a number n represented by n! is the product of the natural numbers up to and including n. Example: 6! = 6 x 5 x 4 x 3 x 2 x 1 Basis Step: f (0) = 1 Recursive Step: f (n) = n · f (n - 1) for n > 0 proc PowerThree(n : natural number) if n = 0 then return 1 else return n· PowerThree(n -1)

Recursive step and basis step

The reduction to a smaller problem of the same type is called the Recursive Step. For the algorithm to terminate it is necessary that the reductions at some point reach an end. The solution for this final problem is often referred to as the Basis Step

What are the three rules of recursion?

The three rules of recursion are: 1. A recursive function must have a base case, which is the stop condition. 2. A recursive function must change its inputs towards the base case. 3. A recursive function must call itself with the new inputs

What is the time complexity of Mergesort?

The time complexity of Merge Sort is O(n log n) in the average and worst case, where n is the number of elements in the array. This makes it more efficient than other sorting algorithms with a similar worst case time complexity, like Quicksort.

Structural induction

a type of induction used to prove theorems about recursively defined sets that follows the structure of the recursive definition A structural induction proof is just a twist on proof using mathematical induction.

What are Fibonacci numbers?

found by starting with 0 and 1 and then adding each of the previous two numbers to produce the next.


संबंधित स्टडी सेट्स

Texas Government (2306)- Political Parties- CH 6

View Set

Autism Spectrum Disorder (Part 1 )IRIS

View Set

9. Processing Change Requests and Procurement Documents

View Set