Information Technology

ITECH1400 COLLATZ CONJECTURE

14 May 2023 14:06 PM | UPDATED 11 months ago

ITECH1400 COLLATZ CONJECTURE :

ITECH1400 ASSIGNMENT 1 COLLATZ CONJECTURE
ITECH1400 COLLATZ CONJECTURE

ITECH1400 Fundamentals of Programming

ASSIGNMENT 1 – COLLATZ CONJECTURE

Overview

In this ITECH1400 ASSIGNMENT 1 COLLATZ CONJECTURE assignment you will have the opportunity to test your Python skills in generating and manipulating lists. Throughout the assignment you are expected to apply the principles of problem solving that we have already discussed in this course.

Timelines and Expectations

Percentage Value of Task: 20%

Due: (Week 7)

 Minimum time expectation: 20 hours

Learning Outcomes Assessed

The following course learning outcomes are assessed by completing this assessment:

Knowledge:

K1. Identify and use the correct syntax of a common programming language.

K2. Recall and use typical programming constructs to design and implement simple software solutions.

K4. Explain the importance of programming style concepts (documentation, mnemonic names, indentation).

Skills:

S1. Utilize pseudocode and/or algorithms as a major program design technique.

S2. Write and implement a solution algorithm using basic programming constructs.

S4. Describe program functionality based on analysis of given program code.

Application of knowledge and skills:

A1. Develop self-reliance and judgement in adapting algorithms to diverse contexts.

A2. Design and write program solutions to identified problems using accepted design constructs.

ASSESSMENT DETAILS

0.Introduction.

In this ITECH1400 ASSIGNMENT 1 COLLATZ CONJECTURE assignment you are required to develop software (a set of functions) that can be used to investigate/research the unsolved mathematical problem called Collatz Conjecture.

Although the problem is considered to be very difficult, its formulation can be understood by a school student:

Collatz Conjecture: Consider the following operation on an arbitrary positive integer, n, which we denote f(n):

If thenumber n is even, then f(n)= n/2.
If thenumber n is odd, f(n) = 3*n+ 1.

Now form a sequence (a Collatz sequence) by performing this operation repeatedly, beginning with a positive integer, n, and taking the result at each step as the input at the next. You stop once you reach 1.

For example, if n = 3, then the sequence will be:

[3, 10, 5, 16, 8, 4, 2, 1]

Or for n = 7 the sequence is:

[7,22, 11,34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]
Youcan seethat in both examples we eventually reach 1.
TheCollatzConjecture claims that this is always true, i.e.,
theprocesswill eventually reach the number 1, regardless of

which positive integer n is chosen initially.

Task 1. Building Collatz sequence. In this task you are required to write a Python function named

collatzSequence(n),

that takes a positive integer parameter, n, and returns a list containing the Collatz sequence for n.

For example, collatzSequence(3) should return the list:

[3, 10, 5, 16, 8, 4, 2, 1]

In your program you may define other (auxiliary) functions with arbitrary names, however, the solution function of this task should be named collatzSequence(n).

[5 marks]

Task 2. Function maxLengths(m).

In this task you are required to write a Python function,

maxLength, that returns two integers:

  • First returned value: for each integer k, 1 ≤ k ≤ m, the length of Collatz sequence for each k is computed and the largest of these numbers is returned.
  • Second returned value is the integer k, 1 ≤ k ≤ m, whose Collatz sequence has the largest length. In case there are several such numbers, return the first one (the smallest).

For example, maxLength(10) returns numbers

20 and 9

Which means that among the numbers 1, 2, 3,…, 10, nine has the longest Collatz sequence, and its length is equal to 20.

In your program you may define other (auxiliary) functions with arbitrary names, however, the solution function of this task should be named maxLength(m).

[5 marks]

Task 3. Function maxValue(m).

In this task you are required to write a Python function,

maxValue, that returns two integers:

  • First returned value: for each integer k, 1 ≤ k ≤ m, the maximal integer in the Collatz sequence for k is computed and the largest of these numbers is returned.
  • Second returned value is the integer k, 1 ≤ k ≤ m, whose Collatz sequence has the largest maximal member. In case there are several such numbers, return the first one (the smallest).

For example, maxValue(10)returns the numbers

52 and 7

Which means that among the numbers 1, 2, 3,…, 10, seven has the largest maximal number in its Collatz sequence, and that number is equal to 52.

In your program you may define other (auxiliary) functions with arbitrary names, however, the solution function of this task should be named maxValue(m).

[5 marks]

Task 4. Function main().

In this task you are required to write a function main() where you test your functions. The output should be similar to the following:

[5 marks]

Allocated Marks: See Course Description

Due Date: See Course Description

Please refer to the Course Description for information relating to late assignments and special consideration.

Assignment Submission

You must supply your program source code files and your documentation as a single zip file named as follows:

<YOUR-NAME>_<YOUR-STUDENT-ID>.zip,

e.g. John_SMITH_30000000

Your documentation should be in PDF format.

Assignments will be marked on the basis of fulfilment of the requirements and the quality of the work.

In addition to the marking criteria, marks may be deducted for failure to comply with the assignment requirements, including (but not limited to):

  • Incomplete implementation(s), and
    • Incomplete submissions (e.g. missing files), and
    • Poor spelling and grammar.

You might be asked to demonstrate and explain your work.

Submit your assignment (all program source files plus your pdf document to the Assignment 1 Upload location on Moodle before the deadline.

Marking Criteria/Rubric

Student ID:                                   Student Name:                                      

TasksWeightAwarded
Marks deducted for badly commented or badly written code(-4) 
  Task 1.collatzSequence function  
Algorithm in pseudo-code1
Python code4
Task 2. maxLengths(m) function  
Algorithm in pseudo-code1
Python code4
Task 3. maxValue(m) function  
Algorithm in pseudo-code1
Python code4
Task 4. Main() function Demonstration that the written functions work correctly by using representative samples.    5 
Total20+(-4) 
ITECH1400 ASSIGNMENT 1 COLLATZ CONJECTURE

Visit:https://auspali.info/

Also visit:https://www.notesnepal.com/archives/767