MDSA Asdignment
MDSA Asdignment
MDSA Asdignment
Computing
Unit 19: Data Structures & Algorithms
Assignment 01
Higher Nationals
Internal verification of assessment decisions – BTEC (RQF)
INTERNAL VERIFICATION – ASSESSMENT DECISIONS
Programme title Higher National Diploma in Computing
Student’s name
List which assessment criteria Pass Merit Distinction
the Assessor has awarded.
Give details:
Programme Leader
signature (if required) Date
LO2 Discuss the advantages, complexity of Abstract Data Type and importance concepts of
Object orientation.
LO4 Examine the advantages of Independent data structures and discuss the need of
asymptotic analysis to assess the effectiveness of an algorithm.
Pass, Merit & P6 P7 M5 D4
Distinction
Descripts
Action Plan
Summative feedback
Assessor Date
signature
• A Cover page or title page – You should always attach a title page to your assignment. Use previous
page as your cover sheet and make sure all the details are accurately filled.
• All the assignments should be printed on A4 sized papers. Use single side printing.
• Allow 1” for top, bottom , right margins and 1.25” for the left margin of each page.
• The font size should be 12 point, and should be in the style of Time New Roman.
• Ensure that all the headings are consistent in terms of the font size and font style.
• Use footer function in the word processor to insert Your Name, Subject, Assignment No, and
Page Number on each page. This is useful if individual sheets become detached for any reason.
• Use word processing application spell check and grammar check function to help editing your
assignment.
Important Points:
• It is strictly prohibited to use textboxes to add texts in the assignments, except for the compulsory
information. eg: Figures, tables of comparison etc. Adding text boxes in the body except for the before
mentioned compulsory information will result in rejection of your work.
• Carefully check the hand in date and the instructions given in the assignment. Late submissions will
not be accepted.
• Ensure that you give yourself enough time to complete the assignment by the due date.
• Excuses of any nature will not be accepted for failure to hand in the work on time.
• You must take responsibility for managing your own time effectively.
• If you are unable to hand in your assignment on time and have valid reasons such as illness, you may
apply (in writing) for an extension.
• Non-submission of work without valid reasons will lead to an automatic RE FERRAL. You will then
be asked to complete an alternative assignment.
• If you are proven to be guilty of plagiarism or any academic misconduct, your grade could be reduced
to A REFERRAL or at worst you could be expelled from the course
I hereby, declare that I know what plagiarism entails, namely to use another’s work and to present it as my
own without attributing the sources in the correct form. I further understand what it means to copy another’s
work.
Submission format
The submission should be in the form of a report, which contains code snippets (which must be
described well), text-based descriptions, and diagrams where appropriate. References to external
sources of knowledge must be cited (reference list supported by in-text citations) using the Harvard
Referencing style.
LO1. Examine abstract data types, concrete data structures and algorithms.
LO2. Specify abstract data types and algorithms in a formal notation.
LO3. Implement complex data structures and algorithms.
LO4. Assess the effectiveness of data structures and algorithms.
In order to manage this particular event ABC Pvt Ltd decided to develop an Application.
Application functions are listed down.
Task 1: Examine and create data structure by simulating the above scenario and explain the
valid operations that can be carried out on this data structure.
Determine the operations of a queue and critically review how it is used to implement function
calls related to the above scenario.
Task 2: Implement the above scenario using the selected data structure and its valid operations
for the design specification given in task 1 by using java programming. Use suitable error
handling and Test the application using suitable test cases and illustrate the system. Provide
evidence of the test cases and the test results.
Task 3 : Registered Car details are stored from oldest to newest. Management of ABC Pvt Ltd
should be able to find from the newest to oldest registered car details. Using an imperative
definition, specify the abstract data type for the above scenario and implement specified ADT
using java programming and briefly discuss the complexity of chosen ADT algorithm. List down
the advantages of Encapsulation and Information hiding when using an ADT selected for the
Task 4: ABC Pvt Ltd plans to visit all of these participants through the shortest path within a
day.
Analyse the above operation by using illustrations, of two shortest path algorithms, specify how
it operates using a sample graph diagram. Sort the cars based on numbers with two different
sorting algorithms and critically review the performances of those two algorithms by comparing
them.
Task 5: Evaluate how Asymptotic analysis can be used to assess the effectiveness of an
algorithm and critically evaluate the different ways in which the efficiency of an algorithm can
be measured.
Critically review the sort of trade-offs exists when you use an ADT for implementing programs.
You also need to evaluate the benefits of using independent data structures for implementing
programs.
A data structure is a way to organize data in a virtual system. Consider number sequences or data tables:
both are well-defined data structures. An algorithm is a set of steps performed by a computer to change
an input into a desired output. Data structures and algorithms work together to allow programmers to
create any computer programs they want. A thorough understanding of data structures and algorithms
ensures that code is well-optimized and efficient (Gupta, 2020).
1.2.1 Stack
A stack is a LIFO (Last in First Out the element placed at last can be accessed at first) structure which can
be commonly found in many programming languages. This structure is named as “stack” because it
resembles a real-world stack, a stack of plates (Mallawaarachchi, 2020).
#Pseudo code
if TOP = MAX-1
return "Overflow"
endif
top = top + 1
stack[top] = item
end
#Pseudo code
return "Underflow"
endif
item=Stack[Top]
top=top-1
return Item
end
Applications of stacks
ˉ Used to evaluate expressions (e.g.: shunting-yard algorithm for parsing and evaluating
mathematical expressions).
ˉ In recursion programming, this is used to generate function calls.
1.2.2 Queue
Queue operations
The two fundamental operations that may be carried out on a queue are listed below.
Applications of queues
A linked list is a sequential structure composed of a series of elements in linear order that are linked to one
another. As a result, you must access data sequentially; random access is not feasible. Linked lists are a
straightforward and adaptable way to express dynamic sets (Mallawaarachchi, 2020).
- Doubly linked list - A doubly linked list is a sort of linked list that carries a reference to both the
previous and next node in the sequence. A node in a doubly-linked list therefore consists of three
parts: node data, a reference to the next node in sequence (next pointer), and a pointer to the
previous node (previous pointer) (previous pointer) (Javatpoint, n.d.).
- Circular singly linked list - The final node of a circular singly linked list carries a reference to the
beginning node of the list. There are circular singly linked lists and circular doubly linked lists
(Javatpoint, n.d.).
- Circular doubly linked list - A circular doubly linked list is a more complicated data structure in
which each node has references to the node before it as well as the node after it. There are no
NULL nodes in the circular doubly linked list. The address of the first node in the list is contained
in the list's final node. In its previous pointer, the first node in the list also carries the address of the
last node (Javatpoint, n.d.).
ˉ Search: Using a basic linear search, find the first element with the key k in the supplied linked list and
return a reference to this element.
ˉ Insert: Insert a key into the linked list. Insertion can be performed in three ways: at the start of the list,
at the end of the list, or in the middle of the list.
ˉ Delete: Removes element x from a linked list. A node cannot be deleted in a single step. A deletion
can be performed in three ways: from the beginning of the list, from the end of the list, or from the
middle of the list.
#include<stdio.h>
#include<stdlib.h>
void beginsert(int);
struct node
{
int data;
struct node *next;
The linked list is suitable for this scenario because it works in the same way as all of the system functions
listed below; Main functions:
2) Delete a car
5) Search a particular
ABC (PVT) LTD is organizing an automotive event for 6 people and they decide to create an app for it.
In this basic application method, the first thing required to register an auto part is called sequentially. It
can also be used as a queue, nor can it be used as a queue as other functions cannot use the ones specified
here.
If we use a Linked List we can do this however we want. By entering the vehicle data, we can enter more
than one vehicle data at the same time. As an example, please enter the controller network card number
as a string, but we need to enter its age as a whole number.
We need to enter different kinds of details at the same time, then I suggested a possible function: Linked
List.
The next feature is the app's Lift Car feature. For this we can use three stacks, queues and Linked List for
our needs. Using the stack function we can remove only the last item from the given list. This is because
this is a first-in, last-out, or last-in, first-out theory, and the order cannot be used because the general
theory is first-in, first-out. This means we can delete the initial data from the list. So we can use Linked
List function to do this, then we can easily control what we want to do.
The next step is that we want to find the winners and the position as 1, 2 and 3. As mentioned above,
three functions can be used for this, but Linked List is the most convenient function because other
functions cannot do what is required here.
The last function will be Find custom car from the list. We can't use the other 2 builds here because
neither of these 2 builds can do what is required. So the most suitable structure for this is the linked list.
Therefore, it is better to choose the linked list for the next function.
2) Deleting a Car
3) Search a Car
4) Adding the results of 3 rounds and determining the winners (1st, 2nd, 3rd) Codes and Test Case for
Register Car Details
Here are some methods and basic functions in the system for this section and if it is not possible to create
this section correctly it will cancel the proposed system. Because the data we get from this section refers
to the last section of the system. "Identification of winners (1, 2, 3)". Accordingly, if we don't properly
create this segment here, ultimately all the data we get from this system is doomed to be out of core. For
this reason, I have tried to make this section meticulously down to the smallest detail. Below have used
two main strategies for this segment. where necessary and would like to independently clarify what is
going on with them. Methods used
ˉ Add method
I. Attempt to place one input value in the right location in the sorted output at each level of the outer
loop. So, from I -- 0 to n-1, repeat the outer loop n times.
After the first k iterations I -- 0 to k-1) of the outer loop, all k maximal items have been moved from
one index (n -- k) to a new index (n -- k) (n-1). So, during the (k + 1)th iteration of the outer loop
(where I -- k), the (k + 1)th maximum element must be placed at the (n -- k -1)th index. So an inner
loop from n -- k -- 1 or n -- I -- 1 must be executed. In other words, the inner loop will run from j --
0 through n -- I -- 2.
for(int i = 0; i < n; i = i + 1)
{
for(int j = 0; j < n - i - 1; j = j + 1)
{
........
}
}
for(int j = 0; j < n - i - 1; j = j + 1)
{
if(X[j] > X[j+1])
{
temp = A[j]
X[j] = X[j+1]
X[j+1] = temp
}
}
Progressively construct the partial solution or sorted array by finding the minimum value from the
unsorted component and adding it to the sorted section. Our sorted part size will increase by one at each
iteration, while the unsorted part size will drop by one.
1) Run the outer loop from I = 0 to n-2 and continue the steps below until the array is sorted.
Initialize the variable Also min Index to hold the unsorted part's minimal value index.
2) Run an inner loop from j = I to n-1 for each index I to get the index of the lowest value in the
unsorted portion.
3) Now, swap the value at i with the value at min Index to get the minimal value at ith index, i.e.
swap (X[min index], X[i]).