Partitions of Integers Prof. Sin-Min Lee Department of Computer Science San Jose State University.

Slides:



Advertisements
Similar presentations
College of Information Technology & Design
Advertisements

Problems and Their Classes
1 EE5900 Advanced Embedded System For Smart Infrastructure Advanced Theory.
Back to Sorting – More efficient sorting algorithms.
CS 206 Introduction to Computer Science II 02 / 27 / 2009 Instructor: Michael Eckmann.
ML: a quasi-functional language with strong typing Conventional syntax: - val x = 5; (*user input *) val x = 5: int (*system response*) - fun len lis =
CSCI-455/552 Introduction to High Performance Computing Lecture 11.
Partitioning and Divide-and-Conquer Strategies ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, Jan 23, 2013.
CS 206 Introduction to Computer Science II 03 / 02 / 2009 Instructor: Michael Eckmann.
CS223 Advanced Data Structures and Algorithms 1 Divide and Conquer Neil Tang 4/15/2010.
Error Measurement and Iterative Methods
CMPS1371 Introduction to Computing for Engineers SORTING.
Recursion. Idea: Some problems can be broken down into smaller versions of the same problem Example: n! 1*2*3*…*(n-1)*n n*factorial of (n-1)
LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Algorithm Design Techniques: Induction Chapter 5 (Except Sections 5.6 and 5.7)
Memory Problems (I.1.1) Prof. Sin-Min Lee Department of Mathematics and Computer Science.
Discrete Structures Chapter 2 Part A Sequences Nurul Amelina Nasharuddin Multimedia Department.
Algorithm Design Techniques: Induction Chapter 5 (Except Section 5.6)
Lecture 8 Analysis of Recursive Algorithms King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part 5. Recursive Algorithms.
Numerical Solutions of Differential Equations Taylor Methods.
Dynamic Programming Introduction to Algorithms Dynamic Programming CSE 680 Prof. Roger Crawfis.
Consecutive Numbers Algebra I.
6.2 Factoring Simple Quadratics Objective: Learn/review the basics needed for factoring.
Decoders and Multiplexers Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Ch. 8 & 9 – Linear Sorting and Order Statistics What do you trade for speed?
Great Theoretical Ideas in Computer Science.
1 Chapter 18-1 Recursion Dale/Weems. 2 Chapter 18 Topics l Meaning of Recursion l Base Case and General Case in Recursive Function Definitions l Writing.
RECURSION II CITS Scope of this lecture Recursive data structures/objects Combinations.
Sequences Informally, a sequence is a set of elements written in a row. – This concept is represented in CS using one- dimensional arrays The goal of mathematics.
Recursion, Complexity, and Searching and Sorting By Andrew Zeng.
Copyright © Cengage Learning. All rights reserved. CHAPTER 9 COUNTING AND PROBABILITY.
Digit Sums of the factors of a number An Investigation.
Discrete Mathematical Structures (Counting Principles)
Copyright © Cengage Learning. All rights reserved.
Whole Numbers Section 3.3 Multiplication and Division of Whole Numbers
Computer Science Department Data Structure & Algorithms Lecture 8 Recursion.
12.1 Sequences and Series ©2001 by R. Villar All Rights Reserved.
Algorithm. An algorithm is a procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed.
Section 2.4. Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations.
Getting Started Introduction to Algorithms Jeff Chastine.
INTRODUCTION. What is an algorithm? What is a Problem?
Adding INTEGERS Adding Integers Blues Song - By Mr. W.
Sequences and Summations Section 2.4. Section Summary Sequences. – Examples: Geometric Progression, Arithmetic Progression Recurrence Relations – Example:
Erdal Kose CC30.10 These slides are based of Prof. N. Yanofsky Lecture notes.
Nicholas Bulinski.  Informally it is the question of if a computer can quickly verify that a solution to a problem is true then can the computer solve.
Applying the Distributive Property Lesson Application Problem O A parking structure has 10 levels. There are 3 cards parked on each level. How many.
Algorithm Analysis. What is an algorithm ? A clearly specifiable set of instructions –to solve a problem Given a problem –decide that the algorithm is.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
CS 206 Introduction to Computer Science II 10 / 10 / 2008 Instructor: Michael Eckmann.
Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Prof. Sumanta Guha Slide Sources: CLRS “Intro.
 A sequence is a list of objects arranged in a specific order.  A sequence in computer science is known as an array. An array hold objects of the same.
ECE DIGITAL LOGIC LECTURE 2: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/14/2016.
1Computer Sciences Department. 2 QUICKSORT QUICKSORT TUTORIAL 5.
Chapter 6 (Lafore’s Book) Recursion Hwajung Lee.  Definition: An algorithmic technique. To solve a problem on an instance of size n, the instance is:
Advanced Algorithms Analysis and Design
Quick-Sort 2/18/2018 3:56 AM Selection Selection.
Recursion Recursion is a fundamental programming technique that can provide an elegant solution certain kinds of problems © 2004 Pearson Addison-Wesley.
Data Structures and Algorithms
Consecutive Numbers Algebra I.
2.6 Factoring Simple Quadratics
ICS 353: Design and Analysis of Algorithms
ICS 353: Design and Analysis of Algorithms
Section 14.3 Complexity Classes
ICS 353: Design and Analysis of Algorithms
Applied Discrete Mathematics Week 7: Computation
Quick-Sort 5/7/2019 6:43 PM Selection Selection.
6.2 Factoring Simple Quadratics
Quick-Sort 5/25/2019 6:16 PM Selection Selection.
ICS 353: Design and Analysis of Algorithms
Presentation transcript:

Partitions of Integers Prof. Sin-Min Lee Department of Computer Science San Jose State University

A numerical partition of an integer n is a sequence p 1 > p 2 > · · · > p k > 0, such that p 1 +p 2 + · · · +p k = n. Each p i is called a part. For example, is a partition of 18 into 6 parts. The number of partitions of n is denoted p(n) and the number of partitions of n into k parts is denoted p(n,k). p(n,k) = p(n - 1, k - 1) + p(n - k,k) p(n) = 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101, 135, 176,…..

In 1740, German mathematician Naude wrote to Euler to ask in how many ways a given positive integer can be expressed as a sum of r distinct positive integers. This problem was quickly solved by Euler. First Euler introduced the idea of a partition of a positive number n into r parts as a sequence, n 1 <n 2 <…<n r, of positive integers such that n= n 1 <n 2 <…<n r where the ni are the parts. As an example, the partitions of 4 are: , , 1 + 3, 2 + 2, 4

Below we show a table of the numbers p(n,k) for 0 < k< n < 9.

The partitions on a number n correspond to the set of solutions (j 1,…,j n ) to the Diophantine equationDiophantine equation For example, the partitions of four, given by (1, 1, 1, 1), (1, 1, 2), (2, 2), (4), and (1, 3) correspond to the solutions(j 1,j 2,j 3,j 4 )= (4,0,0,0) = 4 * 1, (2, 1, 0, 0) = 2 * * 2, (0, 2, 0, 0) = 0 * * 2, (0, 0, 0, 1) = 0 * * * * 4, and (1, 0, 1, 0).= 1 * * * 3 So, there are five different partitions of four.

Euler use p(n) denote the number of partitions of n into any number of parts, where p(0) = 1. Ex: p(4) = 5 because there are five different partitions of four. In order to study the sequence {p(n)}, he introduced the concept of a generating function, and showed that

The partitions of n can be enumerated by a simple recursive routine: function partition(n, limit, answer) { var i; if(n > 0) for(i = min(n, limit); i > 0; i --) partition(n-i, i, answer now including i); else process the answer } //partition //initial call: partition(n, n, initial empty answer);

(1) For each permutation (represented as  ) (  (1),  (2),….,  (p- 1),  (p)) Create an arrayA1[  (1),  (2),….,  (p-1),  (p)] A2[  (1)+  (2),  (2)+  (3),…,  (p-2)+  (p-1),  (p-1)+  (p)] A3[  (1)+  (2)+  (3),  (2)+  (3)+  (4),…,  (p-3)+  (p-2)+  (p-1),  (p-2)+  (p-1)+  (p)] … until … Ap[  (1)+  (2)+  (3)+…+  (p)]. Now create a new array by appending the elements of == A1,A2,…,Ap together, call this array B.

(2) Use any sorting algorithm sort the numbers in array B. (3) If the sorted number of B is of the form : 1 a,2 b,3 c,… we say the permutation is good, print this permutation.

Example 1. For example n=4, p=3 The partition (2,1,1) is good.

Example 2.n=6,p=3. (1,2,3) is not good but (1,3,2) is good. The partition (1,2,3) is not good.

Turn in Thursday (2/26/2004) two separate envelopes containing the following: - A report-describing what you discovered from the program (1) For p=3, what is the maximum n which will produce good permutations. (2) Do this for p=4,5,6,7,8. In your report you should mention what kind of permutation algorithms and sorting algorithm you are using.