








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









Summative Feedback: Resubmission Feedback:
Task 1 - State your simple business problems to be solved (P1) (Pass) 1.1Overview about Algorithm 1.1.1 Definition about Algorithm
1.1.2 Characteristics of an Algorithm Figure 2: Characteristics of an Algorithm ( Source: https://www.geeksforgeeks.org/introduction-to-algorithms/)
Task 2 - Analyse the problem and design the solutions by the use of suitable methods (P1) (Pass) 2.1 Analyse the problem The problem is simply uses an exhaust coupled with memoization to avoid re- computing the same value over and over. The search space is iterated, and any partial results (that may form the tail of subsequent sequences) will be cached along with the associated chain length. Upon completion, search for the largest chain. I saved an array of objects (number, count) and saved each number as I solved it, then while solving if my working number ever went below the number I was solving I would search the array for the corresponding number and pull the count. I changed the array of objects to store every number I came across, including numbers above the number I was currently solving for, but this meant checking every step of every number against the array of objects. All of these were technically correct algorithms after ~100, 000 or so would only solve about 1000 numbers per second. The index is the number being solved and the value stored at that index is the count for that particular index, and storing every number I come across. In my local browser, this solved longest Collatz Sequence (1000000) in about 850ms. Since then, I’ve optimized the function in various ways, with the biggest improvement being not storing the count of values above the limit. As it’s presented below, my local browser solves the problem in 112ms on average. 2.2 Flowchart This is my flowchart about the problem Longest Collatz sequence
Figure 4: Longest Collatz sequence
sequenceLength = length; startingNumber = i; } } Console.WriteLine("Longest Number = " + startingNumber); Console.WriteLine("produces a sequence of " + sequenceLength); } } } 3.2.2 Screen shots of the final result Figure 5: The final result of Longest Collatz sequence 3.3 Explain briefly what is Software Development Life Cycle
Test 3: change number to 0 Figure 8: Test cases 3 4.2 Evaluate how the problem is solved from the designed algorithm to the execution program written by a specific programming language. When I analyse the problem, I thought solution from the topic of the problem. So I decide use for loop and condition sentences to find the non-zero elements in order to control and edit my code easily. After that, all I need to do is call them in main function for the computer to compile and execute. To sum up, when I analyse this problem, all I need is knowledge about array, loop, condition and with algorithm, it help me to solve it easier by using code and also help me improve my thinking ability. References ❖ https://www.geeksforgeeks.org/introduction-to-algorithms/ ❖ https://www.geeksforgeeks.org/introduction-to-algorithms/ ❖ https://www.c-programming-simple-steps.com/algorithm-examples.html ❖ https://euler.beerbaronbill.com/en/latest/solutions/14.html