Professional Documents
Culture Documents
Task 01
Task 01
TASK 01
What is Data Structure?
A data structure is a specialized format for organizing, processing, retrieving and storing data.
In computer science and computer programming, a data structure may be selected or designed
to store data for the purpose of using it with various algorithms. In some cases, the
algorithm's basic operations are tightly coupled to the data structure's design. Each data
structure contains details about the data values, relationships between the data and -- in some
cases -- functions that can be applied to the data.
1|Page
Author-Rajith Karunarathne
function is LinkedList Next function is Delete a car from the application function. For that we
can use all the three stacks, queues and LinkedList for our need. While using stack function
we can only delete last element of the given list. The reason because it comes as First in last
out or Last in First out theory and also queue cannot be used because it common theory was
First thing First out. That means we can delete what data in the first in the list. So, we can
LinkedList Function for this then we can easily manage what we want to do.
For the next function Insert 3 rounds result. We can use Stack functions method Last in first
Out But same process can be done using the LinkedList function here. The next step is we
want to find out winners and position as 1,2,3. As I mentioned earlier the three functions can
be used for this but most suitable function is Linked List because other functions cannot do
what require here. The last function will be Search Particular Car from the list. In here we
cannot use other 2 structures because none of that 2 can do what require. So, for that most
suitable structure is the Linked list. So, I choose LinkedList for the following function.
Task 2
Basic functions are,
1. Car Registration Details
2. Deleting a Car
3. Search a Car
4. Inserting 3 rounds results and finding the winners (1st, 2nd ,3rd)
2|Page
Author-Rajith Karunarathne
Addtolist Method
What I did utilizing this technique was to add details to this strategy utilizing the Add ()
method above and afterward check in case it is feasible to enter the data in the linked list that
coordinates with the applicable car ID. In case there is no space in the linked list, the PC
screen will re-yield that the pertinent client cannot enter additional details into the system.
3|Page
Author-Rajith Karunarathne
4|Page
Author-Rajith Karunarathne
Below are 6 basic linked lists for entering all the data mentioned above. When data is added
to the system with the new car, the relevant carid is included in a separate linked list
5|Page
Author-Rajith Karunarathne
6|Page
Author-Rajith Karunarathne
7|Page
Author-Rajith Karunarathne
Codes And Test Case for Search a Car Details Code for Search a Car
This function is additionally a vital component in this system and it permits the clients of the
pertinent system to look for the data of the cars remembered for the system whenever. In the
entering the ID of the cars we need to know the details in this system, the client will actually
want to see the pertinent data of the cars in which details is put away in this system under the
significant Car Id. Subsequently, I was more cautious in making this function. This is on the
grounds that this segment ought to give the client the specific details that coordinates with the
cars ID entered by the client. Thus, I used one technique for this too so when the relevent
client signs into the system it will show the Id's of the cars that have been added to the system
and the applicable client can enter the necessary Car ID into the system so the individual can
appropriately see the necessary data.
8|Page
Author-Rajith Karunarathne
9|Page
Author-Rajith Karunarathne
Codes And Test Case for Inserting 3 rounds results and finding the winners Code for
Inserting 3 rounds results and finding the winners
This is the main function of this system. Since this is the essential function anticipated from
this system. That is, after we have entered every one of the details, this is the technique that
we will at long last use to choose the champs of the car race. Consequently, this function is
vital and extraordinary consideration ought to be taken while making this part. In this way, I
have essentially used one technique here and the client should enter the details of car 6
preceding beginning the game. Else, I have made this piece of the system so that it can't be
opened.
As needs be, in the entering every one of the details and opening this segment, I have made a
LinkedList that I have made above to consequently duplicate the LinkedList I made above to
enter the Car ID s, and the car Id of the player who finished that round toward the finish of
each round of the opposition. I have planned it to be remembered for this system. I then, at
that point, planned the system so that toward the finish of the last round the car ID s of the
principal, second and third spot finishers in the opposition could be shown on the PC screen
by the client.
10 | P a g e
Author-Rajith Karunarathne
Test Case for Inserting 3 rounds results and finding the winners
Test Feature Start Race
Testing Selecting winners
Inputs Round 1 last car Id = C3
Round 2 last car Id = C1
Round 3 last car Id = C5
Expected Outcome Winners Are: [C2, C4, C6]
Actual Outcome Winners Are: [C2, C4, C6]
Tester Name Rajith Karunarathne 2021/10/11 20.23P.M
Test successful Yes/No Yes
11 | P a g e
Author-Rajith Karunarathne
• Catch
• Finally
12 | P a g e
Author-Rajith Karunarathne
Task 3
What is the sorting?
Sorting refers to the operation or technique of arranging and rearranging sets of data in some
specific order.
Types of sorting techniques
Write these sorting techniques (Algorithms, pseudocodes, Operations etc)
Insertion sort/Merge Sort/Radix Sort/Shell Sort/Heap Sort/Selection sort/Bubble sort
13 | P a g e
Author-Rajith Karunarathne
Abstract Datatypes are the datatypes where you can logically work with the datatype, but you
would not know the inner workings of the datatype. There are many different types of
abstract data types in Java. We will talk about them in this article. Simply vertexing, if you
define a datatype with the help of a programming language and then hide its implementation,
then it is an abstract datatype. Java library has Abstract Data Types such as List, Stack,
14 | P a g e
Author-Rajith Karunarathne
Queue, Set, Map as inbuilt interfaces which are being implemented using various data
structures.
The JDK does not provide any direct implementations of this interface. It provides
implementations of more specific sub interfaces like List, Set. This interface is typically used
to pass collections around and manipulate them where maximum generality is desired. But if
we do this using an ADT, we can use a very limited number of variables and store the
relevant data in a single variable until we get the time we need.
What is the encapsulation?
Encapsulation is one of the four fundamental OOP concepts. The other three are inheritance,
polymorphism, and abstraction. Encapsulation in Java is a mechanism of wrapping the data
(variables) and code acting on the data (methods) together as a single unit. In encapsulation,
the variables of a class will be hidden from other classes, and can be accessed only through
the methods of their current class. Therefore, it is also known as data hiding.
Write Advantages of Encapsulations
What is the Data Hiding?
Data hiding is a software development technique specifically used in object-oriented
programming (OOP) to hide internal object details (data members). Data hiding ensures
exclusive data access to class members and protects object integrity by preventing unintended
or intended changes. Data hiding also reduces system complexity for increased robustness by
limiting interdependencies between software components. Data hiding is also known as data
encapsulation or information hiding.
Write Advantages of data hiding
Is Encapsulation and Data hiding being advantage for above scenario?
Definitely, then discuss the valid justifications
What is the OOP?
Advantages of Object-Oriented Programming
What are the imperative Abstract Data types?
In the "imperative" view, which is closer to the philosophy of imperative programming
languages, an abstract data structure is conceived as an entity that is mutable — meaning that
it may be in different states at different times. Some operations may change the state of the
ADT; therefore, the order in which operations are evaluated is important, and the same
operation on the same entities may have different effects if executed at different times — just
like the instructions of a computer, or the commands and procedures of an imperative
language.
Imperative ADTs are basis for object orientation
Yes, the essence of object-oriented programming is procedural data abstraction, in which
procedures are used to represent data and procedural interfaces provide information hiding
and abstraction. This technique is complementary to ADTs, in which concrete algebras are
used to represent data, and type abstraction provides information hiding. The two paradigms
15 | P a g e
Author-Rajith Karunarathne
16 | P a g e
Author-Rajith Karunarathne
Insertion sort works by inserting the set of values in the existing sorted file. It constructs the
sorted array by inserting a single element at a time. This process continues until whole array
is sorted in some order. The primary concept behind insertion sort is to insert each item into
its appropriate place in the final list. The insertion sort method saves an effective amount of
memory. The Selection sort perform sorting by searching for the minimum value number and
placing it into the first or last position according to the order (ascending or descending). The
process of searching the minimum key and placing it in the proper position is continued until
the all the elements are placed at right position.
As the working of selection, sort does not depend on the original order of the elements in the
array, so there is not much difference between best case and worst case complexity of
selection sort. The selection sort selects the minimum value element, in the selection process
all the ‘n’ number of elements are scanned; therefore n-1 comparisons are made in the first
pass. Then, the elements are interchanged. Similarly in the second pass also to find the
second smallest element we require scanning of rest n-1 elements and the process is
continued till the whole array sorted. Among both of the sorting algorithm, the insertion sort
is fast, efficient, stable while selection sort only works efficiently when the small set of
elements is involved or the list is partially previously sorted. The number of comparisons
made by selection sort is greater than the movements performed whereas in insertion sort the
number of times an element is moved or swapped is greater than the comparisons made.
TASK 5 Asymptotic analysis
As we know that data structure is a way of organizing the data efficiently and that efficiency
is measured either in terms of time or space. So, the ideal data structure is a structure that
occupies the least possible time to perform all its operation and the memory space.
Our focus would be on finding the time complexity rather than space complexity, and by
finding the time complexity, we can decide which data structure is the best for an algorithm.
The main question arises in our mind that on what basis should we compare the time
complexity of data structures? The time complexity can be compared based on operations
performed on them. Let's consider a simple example. Suppose we have an array of 100
elements, and we want to insert a new element at the beginning of the array. This becomes a
very tedious task as we first need to shift the elements towards the right, and we will add new
element at the starting of the array.
✓ Worst case: In this case, it defines the input for which the algorithm takes a huge time.
✓ Average case: In this case, it takes average time for the program execution.
✓ Best case: In this case, it defines the input for which the algorithm takes the lowest
time
17 | P a g e
Author-Rajith Karunarathne
18 | P a g e
Author-Rajith Karunarathne
19 | P a g e
Author-Rajith Karunarathne
20 | P a g e