












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
The implementation and assessment of complex data structures and algorithms as part of a higher national diploma in computing. It includes an assignment brief, code examples, and discussions on asymptotic analysis, time complexity, and space complexity. Insights into implementing a complex abstract data type (adt) and algorithm in a programming language, evaluating the benefits of implementation-independent data structures, and assessing the effectiveness of algorithms using techniques like big-o notation and performance measurements. The document aims to help students develop a strong understanding of data structures and algorithms, which are crucial for solving complex problems in enterprise-level applications.
Typology: Lecture notes
1 / 20
This page cannot be seen from the preview
Don't miss anything!













Grade: Assessor Signature: Date: Internal Verifier’s Comments: IV Signature:
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. 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 ● 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. 2 http://cms.greenwich.edu.vn/.
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 well- defined 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 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 4
public class Queue{ private int total = 0 ; private String[] queue; private int rear; private int front; public Queue(){ queue = new String[ 25 ]; rear = 0 ; front = - 1 ; } public void enqueue(String s){ if (total < 25 ){ total++; front++; queue[front] = s; } } public String dequeue(){ if (total > 0 ){ total--; String temp = queue[rear++]; if (rear == queue.length){ rear = 0 ; front = - 1 ; } return temp; } return ""; } public boolean isEmpty(){ return total == 0 ;
The system must be designed with ADT / algorithms for these two settings and run a trial version with a message of up to 250 characters. The demo should show some important features of these structures. Although this is a trial version, errors must be handled with exceptions, and some tests must be performed to demonstrate the accuracy of the algorithms / functions.
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: Code: include 3 files: Queue.java, Stack.java, Application.java
public class Stack{ private String[] stack; private int index; private int total = 0 ; public Stack(){ stack = new String[ 25 ]; index = - 1 ; } public void push(String s){ if (index < 24 ){ total++; stack[++index] = s; } } public String pop(){ if (index >= 0 ){ total--; return stack[index--]; } return ""; } public boolean isEmpty(){ return total == 0 ; } public boolean isFull(){ return total == 25 ; } } This is Queue , the data structure which have enqueue and dequeue function to put in and take out the data.
Screen shoots of the application successfully running In this main function, I simulate a chat box 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.
Big O Notation is a way to measure an algorithm’s efficiency. It measures the time it takes to run your function as the input grows. Or in other words, how well does the function scale. To measure < Time and Space Complexity = we use < Asymptotic Analysis =. In mathematical analysis, asymptotic analysis, also known as asymptotic, is a method of describing limiting behaviour. (wikipedia, n.d.) Asymptotic Analysis is the big idea that handles above issues in analysing algorithms. In Asymptotic Analysis, we evaluate the performance of an algorithm in terms of input size (we don’t measure the actual running time). We calculate, how does the time (or space) take by an algorithm increases with the input size. For example: When consider the search problem searching a given item in a sorted array. One way to search is Linear Search (order of growth is linear) and other way is Binary Search (order of growth is logarithmic). To understand how Asymptotic Analysis solves the above-mentioned problems in analysing algorithms, let us say we run the Linear Search on a fast computer and Binary Search on a slow computer. For small values of input array size n, the fast computer may take less time. But, after certain value of input array size, the Binary 10
Search will definitely start taking less time compared to the Linear Search even though the Binary Search is being run on a slow machine. The reason is the order of growth of Binary Search with respect to input size logarithmic while the order of growth of Linear Search is linear. Thus, the machine dependent constants can always be ignored after certain values of input size. (geeksforgeeks, n.d.) Usually, the time required by an algorithm falls under three types:
var watch = System.Diagnostics.Stopwatch.StartNew(); watch.Start(); myTransfer.SendMessage(source); watch.Stop(); possibility of other programs or tasks running at the same time in a multi-processing and multi-programming environment. In this program, when implement in C#, I have used DotNet library Diagnostics to calculate time Transfer Function executed: Result of using System Diagnostics With maximum buffer = 50 , it’s took 00.0079028 Sec to send message with 178 characters. So, the algorithm of this program could be considered as an effective algorithm. Space complexity Space complexity: is a function describing the amount of memory (space) an algorithm takes in terms of the amount of input to the algorithm. We often speak of "extra" memory needed, not counting the memory needed to store the input itself. Again, we use natural (but fixed length) units to measure this. We can use bytes, but it's easier to use, say, number of integers used, number of fixed-sized structures, etc. In the end, the function we come up with will be independent of the actual number of bytes needed to represent the unit. Space complexity is sometimes ignored because the space used is minimal and/or obvious, but sometimes it becomes as important an issue as time.
long available = GC.GetTotalMemory(false); Console.WriteLine($"Memory usage (Buffer = {myTransfer.maxBuffer}): {available} bytes"); In this program, When implement in C#, I have used GC.GetTotalMemory to calculate the memory usage when Transfer Function executed: Memory usage with GC.GetTotalMemory Memory using for each object in program 14
Memory using for each object in program With maximum buffer = 150 , it’s took 00.0078182 Sec to send message with 178 characters and this Function used 324712 bytes memory.
Data Structures are structures programmed to store ordered data, so that various operations can be performed on it easily. It represents the knowledge of data to be organized in memory. It should be designed and implemented in such a way that it reduces the complexity and increases the efficiency. The implementation of a data structure usually requires writing a set of procedures that create and manipulate instances of that structure. The efficiency of a data structure cannot be analyzed separately from those operations. This observation motivates the theoretical concept of an abstract data type, a data structure that is defined indirectly by the operations that may be performed on it, and the mathematical properties of those operations (including their space and time cost) After this subject, I have a lot of knowledge to know what ADT is and using ADT to implement a real program to solve a real problem in life. In some case, I also have different prioritize about time or space to implement the system work well. When measuring the program, I can make sure that system will work with right requirement. 16
[1] Jamieson, A. (2021). Introduction to Big O Notation. [online] Medium. Available at: https://towardsdatascience.com/introduction-to-big-o-notation-820d2e25d3fd. [2] Anon, 2022. Big O notation. Wikipedia. Available at: https://en.wikipedia.org/wiki/Big_O_notation [3] GeeksforGeeks. (2012). Analysis of Algorithms | Set 1 (Asymptotic Analysis). [online] Available at: https://www.geeksforgeeks.org/analysis-of-algorithms-set- 1 - asymptotic- analysis/. [4] purplechaiblogger. (2019). Data Structure - Importance and Advantages. [online] Available at: http://www.purplechaiblogger.com/data-structure-importance-and-advantages/. [5] Tutorialspoint.com. (2019). Data Structures - Asymptotic Analysis - Tutorialspoint. [online] Available at: https://www.tutorialspoint.com/data_structures_algorithms/asymptotic_analysis.htm. [6] Wikipedia. (2020). Asymptotic analysis. [online] Available at: https://en.wikipedia.org/wiki/Asymptotic_analysis. [7] codenza_1hhy2b (n.d.). Time & Space Complexity for Data Structures ›› Codenza. [online] Codenza. Available at: https://codenza.app/data-structures/ [8] EDUCBA. (2020). Array Implementation of Stack | Java Stack Implementation using Array. [online] Available at: https://www.educba.com/array-implementation-of-stack/