



























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!




























GREENWICH | GCS
ASSIGNMENT 2
ASSIGNMENT 2 FRONT SHEET 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 Tran Nguyen Tan Sang Student ID GCS Class GCS0804_NX Assessor name Le Ngoc Thanh 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 TAN SANG Grading grid P4 P5 P6 P7 M4 M5 D3 D
ASSIGNMENT 2 BRIEF Qualification BTEC Level 5 HND Diploma in Business Unit number Unit 19 : Data Structures and Algorithms Assignment title Implement and assess specific DSA Academic Year 2021 Unit Tutor Issue date Submission date IV name and date Submission Format: Format: The submission is in the form of an individual written report. 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 Tutors. The form of submission will be a soft copy in PDF posted on corresponding course of http://cms.greenwich.edu.vn/ Project also needs to be submitted in zip format. Note: The Assignment must be your own work, and not copied by or from another student or from books etc. 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 know how to reference properly, and that understand the guidelines on plagiarism. If you do not, you definitely get fail Assignment Brief and Guidance: 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 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 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 Pass Merit Distinction LO1 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
P4. Implement a complex ADT and algorithm in an executable programming language to solve a well-
1) Object Sender is used to store information of a sender: − Properties:
Output of my program: P5. Implement error handling and report test results. 1) In main method, I read three messages from three files and I use try catch to catch exception when file not found.
− Therefore, I will add try catch into code when we do enqueue method: − This is the result when use try catch: 4) Stack overflow: − The program initializes the stack with a specified size: − So, if we insert packets exceed the size, the program will occur error like this: − To solve this problem I will check if stack is full, do not push new item − This is the result: 5) Read message from file .txt:
− Result: Successfully 6) Stop sending when Sender send full of message: − Result: Successfully 7) Stop receiving when receiver full of message
Step 3. Check if the index of array that store short messages equals to - 1. Program will increase currIndexOfMessages variable. Then split string of messages[currIndexOfMessages] and give it to array packets. Step 4. Check if current index of packets is larger than length of packets minus 1, we increase current index of array messages and give 0 value to current index of packets. Besides that, program will check if current index of array messages is larger than length of array messages, program will give true value to isEnd variable of Object Sender and then stop send method. But if currIndexOfMessages still smaller han length of array messages, we split string of messages[currIndexOfMessages] and give it to array packets. Step 5. Enqueue packets[currIndexOfPackets] into Queue. Step 6. Write on console the string that sender send to receiver. − Receive method of Object SenderReceiver: − Step 1. Check if the queue is empty and sender finish sending, stop the method Step 2. If not, check if queue is not empty, dequeue and give value to s variable. Step 3. If ‘s’ variable has value equal to “|” character (end of array packets), write all value stored in stack ion console Step 4. Else write ‘received packet on cosole’ 2) Sender ADT: − Sender is an ADT that I created to store information of a sender when start sending a message.
− Because properties name and isEnd of Object is private, I created public method to set and get them. − isEnd property is used to identify that sender have done. If isEnd is true, when random a value that this sender have to send, send method will not run all statement. − 3) Receiver ADT: − − This object is to store information of a receiver, because of private property, I create some public set and get method. 4) Stack ADT: