

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
assignment 2 1649 procedural programming
Typology: Assignments
1 / 25
This page cannot be seen from the preview
Don't miss anything!


















Qualification BTEC Level 5 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 Phạm Văn Hiệp Student ID GCS Class GCS0903B Assessor name Lê Ngọc Thành 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 HIEP Grading grid P4 P5 P6 P7 M4 M5 D3 D x x x x
Assignment Brief 2 (RQF) Higher National Certificate/Diploma in Business Student Name/ID Number: Phạm Văn Hiệp Unit Number and Title: Unit 19: Data Structures and Algorithms Academic Year: 2021 Unit Assessor: Assignment Title: Implement and assess specific DSA Issue Date: Submission Date: Internal Verifier Name: 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 1. 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 require a stack of messages. The team now has to develop these kinds of collections for the system. They should design ADT / algorithms for these 2 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 2 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 D3 Critically evaluate the complexity of an implemented ADT/algorithm P4 Implement a complex ADT and algorithm in an executable programming language to solve a well-defined problem. P5 Implement error handling and report test results. M4 Demonstrate how the implementation of an ADT/algorithm solves a well- defined problem LO4 Assess the effectiveness of data structures and algorithms D4 Evaluate three benefits of using implementation independent data structures 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
1. Implement ADT & algorithms 1.1 Description of scenario: “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 require a stack of messages. The team now has to develop these kinds of collections for the system. They should design ADT / algorithms for these 2 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 2 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.” Founded on the given scenario, we can decide that we need some right ADTs to solve this problem. They are stack and queue, which are defined in Assignment 1 Stack is used to reserving the process messages. The queue is used to reserve the transported notices. 1.2 ADT (P4, P5) 1.2.1 Implement A stack could be a linear arrangement that may only be accessed at in an exceedingly one in every of its ends to store and retrieve data. Such a stack is sort of a stack of trays in a cafeteria: new trays are placed on the highest of the stack and brought out the highest. The last tray placed on the stack is that the first tray aloof from the stack. Therefore, it's called the Last in stay (LIFO) or First in Last Output (FILO) list. So, Stack is employed to storing progress messages. A queue is just a queue that grows by adding elements to the tip and shrinks by saying elements from its front. Unlike a stack, a queue could be a structure during which both ends are used: one end to feature new
elements and one end to get rid of them. therefore, the last element needs to wait until all the weather before it on the queue are removed. Hence, it's called a primary Out (FIFO) or Last in Last (LILO) list. Therefore, Queues are wont to store the messages being transported. The message is going to be added to the queue, if the queue is full then the message won't be added to the queue. To solve this problem, First, I have designed a “Message” object to store the messages in the system. Figure 1. Message I design the stack and queue ADT for the system:
Figure 4. My Queue 2 Finally, I create a "Main" class for the system with the following functions:
The catch block in Java is employed to handle the Exception by declaring the exception type within the parameter. The declared exception must be an exception of the parent class exception (i.e, Exception) or the generated exception type. However, the great approach is to declare the generated form of exception. The catch block must be used after the try block only. you'll use multiple catch blocks with one try block. The attempt to catch keywords are available pairs: Figure 6. try and catch We will run into various problems when developing the system, including exceptions like IndexOutOfBoundsException and NullPointerException (which are produced when a program attempts to refer to an object that doesn't exist in memory, or has a null value). Figure 7. IllegalStateException: Underflow Exception When implementing the system, I used try-catch to catch the error.
Figure 8. Try-catch in Main Figure 9. Try-catch in MyStack 1.2.2 Test Test case ID Description Expected result Actual results Result 1 Enter a message. The message is a string of maximum 250 characters. If it exceeds 250 characters, an error message is output. Enter your message. If it exceeds 250 characters, an error message will appear asking you to enter the message The length limit of string is 250. Please again. Pass 2 Check new function is sent message Enter a message. This message has added to system. Message has added to system. Pass 3 Check the feature of receiving messages The system will receive the sent message The system received the sent message Pass
Figure 12. Result 3 Check the feature of displaying all messages Figure 13. Result 4
Check the feature of displaying all messages: Figure 14. Result 5
2. Analysis (P6, P7) 2.1 Big O The most commonly used notation for determining asymptotic complexity – that is, for estimating the speed of function growth - is that the big-O notation introduced in 1894 by Paul Bachmann. Let f(n) and g(n) functions mapping positive integers to positive real numbers, consider the subsequent definition: Definition: f (n) is O(g(n)) if there exist positive numbers c and n0 such f (n) ≤ cg(n) for all n ≥ n0. This definition is usually said because the "big-Oh" notation, for its sometimes pronounced as" f (n) is that the big-Oh of g (n)." This definition reads: f is big-O of g if there is a positive number c such f isn't larger than cg for a sufficiently large ns; that's, for any ns greater than some n0. the link between f and g will be expressed by saying that g (n) is a boundary on the worth of f(n) or, within the long term, f grows at the most as fast as g. The following figure illustrates the overall definition.