assignment 1 1649.pdf, Assignments of Computer Networks

assignment 2 1649.pdf procedural programming

Typology: Assignments

2021/2022

Uploaded on 08/07/2022

hiep-pham-van
hiep-pham-van 🇻🇳

4.7

(35)

19 documents

1 / 23

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PHAM VAN HIEP
GCS200581 GCS0903B
DATA STRUCTURE AND
ALTHOGRIMS
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17

Partial preview of the text

Download assignment 1 1649.pdf and more Assignments Computer Networks in PDF only on Docsity!

PHAM VAN HIEP GCS200581 GCS0903B

DATA STRUCTURE AND

ALTHOGRIMS

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 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.

Contents

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 2. MyStack

Figure 4. My Queue 2 Finally, I create a "Main" class for the system with the following functions:

Figure 5. Main Error handling is that the process of responding to and recovering from error conditions in your program. When executing Java code, different errors can occur: coding errors made by the programmer, errors because of wrong input, or other unforeseeable things. When a slip occurs, normally Java will stop and generate a mistake message. The technical term for this is: Java will throw an exception (throw an error). An Exception is an unusual event, often miscalculation, that needs special processing. Exceptions will be caused by employing a reference that's not yet initialized, dividing by zero, going beyond the length of an array, or perhaps JVM not having the ability to assign objects on the heap. The try-catch block is employed to execute the exception handling catch-and-throw pattern. The try statement allows you to define a block of code to be tested for errors while it's executed. The catch statement allows you to define a block of code to be executed if a mistake occurs within the try block.

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

4 Check the feature of displaying all messages Display all messages in the system All messages have been displayed in the system Pass 1.2.3 Result − With the number entered is the character: Figure 10. Result 1 − Check new function is sent message: Figure 11. Result 2 − Check the feature of receiving messages:

− 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.

Figure 15. Big O In the figure, n0 is that the point from which we want to contemplate the speed of growth for a given algorithm. Below n0, the speed of growth can be different. n0 is termed the brink for the given function. For example, if f(n) = n4 + 3n3 + 2n2 + 10n + 50 is that the given algorithm, then n4 is g(n). meaning g(n) gives the most rate of growth for f(n) at larger values of n. 2.1.1 Big-O examples Example: The function f(n) = 8n +5 is O(n). Justification: By the big-Oh definition, we need to find a real constant c > 0 and an integer constant n 0 ≥ 1 such that 8n + 5 ≤ cn for every integer nn 0. It is easy to see that a possible choice is c = 9 and n 0 = 5. Indeed, this is one of infinitely many choices available because there is a trade-off between c and n. for example, we could rely on constants c = 12 and n 0 = 1. 2.2 Analyse performances Based on the given scenario, I also used the stack and queue to solve this problem. Stack is used to store the process messages. Queue is used to store the transported messages.