higher nationals in computing unit 19 data structure and algorithms

13 0 0
Tài liệu đã được kiểm tra trùng lặp
higher nationals in computing unit 19 data structure and algorithms

Đ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

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

Trang 1

Higher Nationals in Computing

Unit 19: Data Structure and Algorithms No.2

Assessor Name: Le Ngoc Thanh

Class: GCS0903B ID: GCS200345

Assignment due: June 26 , 2022thAssignment submitted: June 26 , 2022th

Trang 2

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

Student Name Hong Thanh Hung Student ID GCS200345

Trang 3

Summative Feedback: Resubmission Feedback:

Internal Verifier’s Comments:

IV Signature:

Trang 4

2

Assignment Brief 2 (RQF)

Higher National Certificate/Diploma in Business

Student Name/ID Number:

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

Trang 5

● 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:

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

Trang 6

4

Learning Outcomes and Assessment Criteria (Assignment 2)

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

Contents

Assignment Brief 2 (RQF) 2

Higher National Certificate/Diploma in Business 2 P4 Implement a complex ADT and algorithm in an executable programming language to solve a well-defined problem 5 P5 Implement error handling and report test results 7 P6 Discuss how asymptotic analysis can be used to assess the effectiveness of an algorithm 9 P7 Determine two ways in which the efficiency of an algorithm can be measured, illustrating your answer with an example 10 References: 11

Trang 7

P4 Implement a complex ADT and algorithm in an executable programming language to solve a well-defined problem

To develop data structure and algorithms I have chosen ADT array and write in the Java language Here is my code to implement an algorithm:

This is the App file which is take responsible to run the algorithm and give us back the result

Stack myStack = new Stack(); Queue myQueue = new Queue(); for (int = 0; < i25;++){ String temp = "Hello "; Random rand = newRandom(); temp += rand.nextInt(100); myQueue.enqueue(temp);

System.out.println("Messages sent from user 1: " + temp); }

while (!myQueue.isEmpty()){ String temp = myQueue.dequeue(); myStack.push(temp); }

System.out.println(); while (!myStack.isEmpty()){

System.out.println("Messages received from user 2: " + myStack.pop()); }

} }

In this main function, I simulate a chatbox of user 1 and user 2 Whenever user 1 sends a message, the message enqueue to the queue Then user 2 saw that the program will dequeue all of the messages in the stack to see the message

Trang 8

6

This is queue, the data structure which have enqueue and dequeue function to put in and take out the data

private inttotal = 0

private intrear; private intfront;

}

iftotal > 0){ total ;

String temp = queue[rear++]; (ifrear == queue.length){ rear = 0

front = -1

}

Trang 9

return temp; } return ""; }

return total == ; 0

}

return total == queue.length; }

}

This is the stack, the data structure and its function have a mission that checks out the data and stops it when it reaches the limit

private intindex; private inttotal = 0

}

ifindex >= 0){ total ; return stack[index ]; }

return ""; }

return total == ; 0

}

Trang 11

P6 Discuss how asymptotic analysis can be used to assess the effectiveness of an algorithm

An algorithm's effectiveness can be determined using Big O Notation As the input increases, it measures the amount of time it takes to run your function Alternatively, how well does the function scale?

Time complexity and spatial complexity are the two components that makeup efficiency measurement The length of the function's computation-step execution time is known as its time complexity The function's utilization of memory has an impact on space complexity With the help of two search algorithms, this blog will demonstrate time complexity

Trang 12

10

Stack illustration because it keeps items in order but only allows access to the top item, a stack is a linear data structure similar to a list When you hit Command + Z and Command + Y on a Mac or Control + Z and Control + Y on a Microsoft device to undo and redo something, you will only be able to access the most recent modification you made in both circumstances When using the browser, trying to move backward or forward is another example of a stack in action Additionally, even though a stack is an abstract data type, it may be implemented using actual data structures like dynamic arrays and linked lists

P7 Determine two ways in which the efficiency of an algorithm can be measured, illustrating your answer with an example

In computer science, there are typically multiple algorithms that can be used to address a given problem Therefore, using a method to compare the answers and determine which is more ideal is absolutely necessary The procedure must be:

• Independent of the computer being used to run the algorithm and its configuration • Displays a straight-line relationship with the number of inputs

• Can plainly and unambiguously discriminate between two algorithms There are two such methods: time complexity and spatial complexity

• Time Complexity: An algorithm's time complexity measures how long it takes to complete a task in relation to the size of the input It should be noted that the time required to complete the procedure depends on the length of the input rather than the machine's real processing speed

The total operations for an input length on N are calculated in order to determine the time complexity of an algorithm It is assumed that each operation takes a fixed amount of time, c To comprehend the computation process, consider the following example: Let's say that the task at hand is to determine whether a pair (X, Y) exists in an array (A) with N elements and a sum of Z The easiest approach is to take into account each pair and determine whether or not it fits the requirement

Trang 13

• Space Complexity: The amount of space an algorithm uses to operate as a function of input length is measured by its space complexity Here's an illustration: Imagine you are trying to determine the frequency of an array's elements

In addition to spatial complexity, there is auxiliary space The primary distinction is that although auxiliary space quantifies additional space utilized in the method beyond the input given, space complexity quantifies the total amount of space needed by the algorithm

OPERATION BEST AVERAGE WORST BEST AVERAGE WORST

isEmpty() O(1) O(1) O(1) O(1) O(1) O(1)

enqueue() O(1) O(1) O(1) O(1) O(1) O(1)

dequeue() O(1) O(1) O(1) O(1) O(1) O(1)

push() O(1) O(1) O(1) O(1) O(1) O(1)

pop() O(1) O(1) O(1) O(1) O(1) O(1) Example for Time and Space Complexity of Queue using Array

References:

Medium 2022 Introduction to Big O Notation [online] Available at:

<https://towardsdatascience.com/introduction-to-big-o-notation-820d2e25d3fd> [Accessed 26 June 2022]

2022 [online] Available at: <https://codenza.app/data-structures/> [Accessed 26 June 2022]

Stack, A., 2022 Array Implementation of Stack | Java Stack Implementation using Array [online] EDUCBA Available at: <https://www.educba.com/array-implementation-of-stack/> [Accessed 26 June 2022]

Ngày đăng: 13/05/2024, 14:54