1649 assignment 2 (pass)

26 15 0
1649 assignment 2 (pass)

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) 1649 assignment 2 (pass) FPT Greenwich

Higher Nationals in Computing Unit 19: Data Structures and Algorithms ASSIGNMENT Assessor name: PHAN MINH TAM Learner’s name: Đào Vĩnh Khang ID:GCS200222 Class: GCS0905B Subject code: 1649 Assignment due: Assignment submitted: ASSIGNMENT FRONT SHEET Qualification BTEC Level HND Diploma in Computing Unit number and title Unit 19: Data Structures and Algorithms Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Đào Vĩnh Khang Student ID GCS200222 Class GCS0905B Assessor name Phan Minh Tam Student declaration I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism I understand that making a false declaration is a form of malpractice Student’s signature Grading grid P4 P5 P6 P7 M4 M5 D3 D4 K  Summative Feedback: Grade:  Resubmission Feedback: Assessor Signature: Internal Verifier’s Comments: Signature & Date: Date: ASSIGNMENT BRIEF Qualification BTEC Level HND Diploma in Business Unit number Unit 19: Data Structures and Algorithms Assignment title Implement and assess specific DSA Academic Year 2022 Unit Tutor TamPM Issue date 12-Sep-2022 Submission date IV name and date Submission Format: Format: ● The submission is in the form of an individual written report and a presentation This should be written in a concise, formal business style using single spacing and font size 12 You are required to make use of headings, paragraphs and subsections as appropriate, and all work must be supported with research and referenced using the Harvard referencing system Please also provide a bibliography using the Harvard referencing system Submission ● ● Students are compulsory to submit the assignment in due date and in a way requested by the Tutor The form of submission will be a soft copy posted on http://cms.greenwich.edu.vn/ ● Remember to convert the word file into PDF file before the submission on CMS Note: ● The individual Assignment must be your own work, and not copied by or from another student ● If you use ideas, quotes or data (such as diagrams) from books, journals or other sources, you must reference your sources, using the Harvard style ● Make sure that you understand and follow the guidelines to avoid plagiarism Failure to comply this requirement will result in a failed assignment Unit Learning Outcomes: LO3 Implement complex data structures and algorithms LO4 Assess the effectiveness of data structures and algorithms Assignment Brief and Guidance: Assignment scenario Continued from Assignment Tasks For the middleware that is currently developing, one part of the provision interface is how message can be transferred and processed through layers For transport, normally a buffer of queue messages is implemented and for processing, the systems requires a stack of messages The team now has to develop these kind of collections for the system They should design ADT / algorithms for these structures and implement a demo version with message is a string of maximum 250 characters The demo should demonstrate some important operations of these structures Even it’s a demo, errors should be handled carefully by exceptions and some tests should be executed to prove the correctness of algorithms / operations The team needs to write a report of the implementation of the data structures and how to measure the efficiency of related algorithms The report should also evaluate the use of ADT in design and development, including the complexity, the trade-off and the benefits Learning Outcomes and Assessment Criteria (Assignment 2) Pass Merit Distinction LO3 Implement complex data structures and algorithms P4 Implement a complex ADT and algorithm in an executable programming language to solve a well defined problem M4 Demonstrate how the implementation of an ADT/algorithm solves a welldefined problem D3 Critically evaluate the complexity of an implemented ADT/algorithm P5 Implement error handling and report test results LO4 Assess the effectiveness of data structures and algorithms P6 Discuss how asymptotic analysis can be used to assess the effectiveness of an algorithm P7 Determine two ways in which the efficiency of an algorithm can be measured, illustrating your answer with an example M5 Interpret what a trade-off is when specifying an ADT using an example to support your answer D4 Evaluate three benefits of using implementation independent data structures Table of Contents P4 Implement a complex ADT and algorithm in an executable programming language to solve a welldefined problem…………………………………………………………………………………………………………………………….1 1/ Queue……………………………………………………………………………………………………………………………………… 1.1/ Node class……………………………………………………………………………………………………………………………….2 1.2/ Queue Class…………………………………………………………………………………………………………………………….3 1.3/ Application class…………………………………………………………………………………………………………………… 1.4/ Screenshot………………………………………………………………………………………………………………………………4 2/ Stack………………………………………………………………………………………………………………………………………….5 2.1/ Node class……………………………………………………………………………………………………………………………….6 2.2/ Stack class……………………………………………………………………………………………………………………………….7 2.3/ Application…………………………………………………………………………………………………………………………… 2.4/ Screenshot………………………………………………………………………………………………………………………………7 P5 Implement error handling and report test results………………………………………………………………………8 P6 Discuss how asymptotic analysis can be used to assess the effectiveness of an Algorithm……… 10 1/ Asymptotic analysis………………………………………………………………………………………………………………….11 1.1/ Definition………………………………………………………………………………………………………………………………11 1.2/ Asymptotic Notations……………………………………………………………………………………………………………12 1.3/ Common Asymptotic Notations…………………………………………………………………………………………… 13 1.4/ How to find time complexity? 14 2/ Example……………………………………………………………………………………………………………………………………15 P7 Determine two ways in which the efficiency of an algorithm can be measured, illustrating your answer with an example……………………………………………………………………………………………………………….16 1/ Two Main Measures for the Efficiency of an Algorithm…………………………………………………………….18 1.1/ Time complexity……………………………………….……………………………………………………………………………20 1.2/ Space complexity………………………………………………………………………………………………………………… 22 2/ Demonstration…………………………………………………………………………………………………………………………23 Page |1 ASSIGNMENT ANSWERS P4 Implement a complex ADT and algorithm in an executable programming language to solve a well-defined problem 1/ Queue 1.1/ Node class Explain: Data Field, which contains the data stored in the current Node Pointer Field of type Node, which contains the address information of the next Node in the queue Page |2 1.2/ Queue Class Page |3 Explain: The Rear keeps on moving ahead and always points to the position where the next element will be inserted The front remains at the first index No discount is the number of nodes in the queue 1.3/ Application class Page |4 Option 2: Option 3: Option 4: 2/ Stack Page |6 2.1/ Node class Explain: Data Field, which contains the data stored in the current Node Pointer Field of type Node, which contains the address information of the next Node in the stack Page |7 2.2/ Stack class Explain: The top is a new element added at one end of the stack discount is the number of nodes in the stack Page |8 2.3/ Application 2.4/ Screenshot Option Page |9 Option Option P5 Implement error handling and report test results No Actions Input test data Output test data Halo The message “ halo” is stored into the queue The message “ balo” is stored into the queue The message “ bags” is started into the queue The message ”we” is stored from the queue The message “halo” is deleted from the queue Select option on menu(queue) Select option on menu(queue) Select option on menu(queue) Select option on menu(queue) Select option on menu(queue) P a g e | 10 Balo bags we 10 11 12 13 14 Select option on menu(queue) Select option on menu(queue) Select option on menu(stack) Select option on menu(stack) Select option on menu(stack) Select option on menu(stack) Select option on menu(queue) Select option on menu(queue) Select option on menu(queue) The message in queue: 1: balo, 2: bags, 3:we Build successful 22 13 132 The message “ “ is stored from the stack The message “ 22 “ is stored from the stack The message “ 13 “ is stored from the stack The message “ 132 “ is stored from the stack The messafe”132” is delete from the stack The message in stack: 1: 1, 2: 22, 3: 13 Build successful P6 Discuss how asymptotic analysis can be used to assess the effectiveness of an Algorithm 1/ Asymptotic analysis 1.1/ Definition Asymptotic analysis of an algorithm refers to defining the mathematical foundation/framing of its runtime performance Using asymptotic analysis, we can very well conclude the best case, average case, and worst-case scenario of an algorithm Asymptotic analysis refers to computing the running time of any operation in mathematical units of computation For example, the running time of one operation is computed as f(n) and may be for another operation it is computed as g(n2) This means the first operation running time will increase linearly with the increase in n and the running time of the second operation will increase exponentially when n increases Similarly, the running time of both operations will be nearly the same if n is significantly small Usually, the time required by an algorithm falls under three types: • • • Best Case − Minimum time required for program execution Average Case − Average time required for program execution Worst Case − Maximum time required for program execution 1.2/ Asymptotic Notations P a g e | 11 Following is the commonly used asymptotic notations to calculate the running time complexity of an algorithm • Ο Notation • Ω Notation • θ Notation Big Oh Notation, Ο The notation Ο(n) is the formal way to express the upper bound of an algorithm's running time It measures the worst-case time complexity or the longest amount of time an algorithm can possibly take to complete Omega Notation, Ω The notation Ω(n) is the formal way to express the lower bound of an algorithm's running time It measures the best-case time complexity or the best amount of time an algorithm can possibly take to complete Theta Notation, θ P a g e | 12 The notation θ(n) is the formal way to express both the lower bound and the upper bound of an algorithm's running time It is represented as follows 1.3/ Common Asymptotic Notations Following is a list of some common asymptotic notations 1.4/ How to find time complexity? P a g e | 13 Finding out the time complexity of your code can help you develop better programs that run faster Some functions are easy to analyze, but when have loops, recursion might get a little trickier when you have recursion After reading this post, you can derive the time complexity of any code In general, you can determine the time complexity by analyzing the program’s statements (go line by line) However, you must be mindful of how the statements are arranged Suppose they are inside a loop or have function calls or even recursion All these factors affect the runtime of your code Let’s see how to deal with these cases 2/ Example P a g e | 14 Let us assume that we have an array of length 32 We’ll be applying Binary Search to search for a random element in it At each iteration, the array is halved Iteration 0: Length of array = 32 Iteration 1: Length of array = 32/2 = 16 Iteration 2: Length of array = 32/2^2=8 Iteration 3: Length of array = 32/2^3=4 Iteration 4: Length of array = 32/2^4 = Iteration 5: Length of array = 32/2^5 = Another example would be that for an array of size 1024, only 10 iterations are needs to approach unity For an array size 32768, we'll need only 15 iterations Thus, we can see that the number of operations grows at a very small rate compared to the size of the input array while complexity is logarithmic P7 Determine two ways in which the efficiency of an algorithm can be measured, illustrating your answer with an example 1/ Two Main Measures for the Efficiency of an Algorithm 1.1/ Time complexity Time complexity is defined as the amount of time taken by an algorithm to run, as a function of the length of the input It measures the time taken to execute each statement of code in an algorithm It is not going to examine the total execution time of an algorithm Rather, it is going to give information about the variation (increase or decrease) in execution time when the number of operations (increase or decrease) in an algorithm Yes, as the definition says, the amount of time taken is a function of the length of input only P a g e | 15 1.2/ Space complexity Whenever we say that our algorithm is sufficient then it means that the algorithm is solving the problem in less amount of time while taking the least amount of space Let's take an example of sorting algorithms like insertion and heap sort don't create a new array during sorting as they are in-place sorting techniques, but merge sort creates an array during the sorting of elements which takes an extra space so if there is a concern of space then obviously one will prefer the insertion or heap sort So, as we know that analyzing the algorithm is a much-needed task after designing an algorithm so as to increase its efficiency of an algorithm During analyzing any problem or algorithm you all may have encountered time complexity and space complexity Sometimes we ignore calculating the space complexity, but the fact is that space complexity is also an important parameter as the time complexity to analyze the efficiency of an algorithm or a problem P a g e | 16 2/ Demonstration 2.1/ Space complexity ❖ Array – the function’s only argument – the space taken by the array is equal to 4n bytes where n is ❖ the length of the array ❖ The int variable, size ❖ The int variable, sum ❖ The int iterator, i P a g e | 17 The total space needed for this algorithm to complete is 4n + + + (bytes) The highest order is n in this equation Thus, the space complexity of that code snippet is O(n) When the program consists of loops (In the case of Iterative algorithms), it will have linear space complexity or O(n) 2.2/ Time complexity Here, the O(1) chunk of code (the count statements) is enclosed inside a looping statement which repeats iteration for 'n' number of times Thus, our overall time complexity becomes n*O(1), i.e., O(n) P a g e | 18 REFERENCES 1/ Kusniyati, Harni, Pangondian Sitanggang, and Nicky Saputra "Aplikasi Edukasi Budaya Toba Samosir Berbasis Android." Jurnal Teknik Informatika UIN Syarif Hidayatullah 9.1 (2016): 133130 https://www.neliti.com/publications/133130/aplikasi-edukasi-budaya-toba-samosir-berbasis-android 2/ Schultz-Johnson, Karen "Static progressive splinting." Journal of Hand Therapy 15.2 (2002): 163-178 https://www.sciencedirect.com/science/article/abs/pii/S0894113002500314 3/ Chinowsky, Timothy M., Linda S Jung, and Sinclair S Yee "Optimal linear data analysis for surface plasmon resonance biosensors." Sensors and Actuators B: Chemical 54.1-2 (1999): 89-97 https://www.sciencedirect.com/science/article/abs/pii/S0925400598003165 4/ Yang, Jason C., et al "Real‐time concurrent linked list construction on the GPU." Computer Graphics Forum Vol 29 No Oxford, UK: Blackwell Publishing Ltd, 2010 https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1467-8659.2010.01725.x 5/ Kunniyur, Srisankar, and Rayadurgam Srikant "Analysis and design of an adaptive virtual queue (AVQ) algorithm for active queue management." ACM SIGCOMM Computer Communication Review 31.4 (2001): 123134 https://link.springer.com/article/10.1007/BF01683268 6/ Beck, Anatole, and Donald J Newman "Yet more on the linear search problem." Israel journal of mathematics 8.4 (1970): 419-429 https://link.springer.com/chapter/10.1007/3-540-45253-2_31 7/ Hivert, Florent, J-C Novelli, and J-Y Thibon "The algebra of binary search trees." Theoretical Computer Science 339.1 (2005): 129-165 https://dl.acm.org/doi/abs/10.1145/1837853.1693488 8/ Dyer, Chris, et al "Transition-based dependency parsing with stack long short-term memory." arXiv preprint arXiv:1505.08075 (2015) https://iopscience.iop.org/article/10.1149/1.3700896/meta P a g e | 19 9/ Artyszuk, J "Steady-state manoeuvring of a generic ASD tug in escort pull and bow-rope aided push operation." TransNav: International Journal on Marine Navigation and Safety of Sea Transportation 8.3 (2014) https://ieeexplore.ieee.org/abstract/document/782080/ 10/ Sfaelou, Stavroula, et al "Mesoporous WO3 photoanodes for hydrogen production by water splitting and PhotoFuelCell operation." international journal of hydrogen energy 41.14 (2016): 5902-5907 https://www.sciencedirect.com/science/article/abs/pii/S036031991531380X P a g e | 20

Ngày đăng: 18/07/2023, 23:55

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan