Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 142

QCF BTEC

INTERNAL VERIFICATION – ASSESSMENT DECISIONS


Programme title BTEC L5 HND in computing and Systems Development

Assessor Internal Verifier

Unit(s) Data Structures and Algorithms

Assignment title

Learner’s name

First submission / resubmission?


First Submission
(Only one resubmission allowed, authorised by Lead Internal Verifier)

List which assessment Pass Merit Distinction


and grading criteria
the assessor has √
awarded.

INTERNAL VERIFIER CHECKLIST Comments

Have the learner and assessor confirmed Yes. the learner and assessor confirmed the
Y/N
the authenticity of the evidence? authenticity of the evidence

Do the assessment criteria awarded Yes.The assessment criteria awarded match


Y/N
match those targeted by the brief? those targeted by the brief

Has the work been assessed accurately? Y/N Yes. the work been assessed accurately

Does the assessment feedback to the the assessment feedback to the learner is
learner: Y/N
Link to relevant assessment criteria with appropriate
 Link to relevant assessment criteria? justifications
 Justify each assessment criterion awarded?

Does the assessment decision need No


Y/N
amending?

Assessor signature Date 2019/01/03

Internal Verifier
t Date 2019/01/10
signature

Lead Internal Verifier


Date
signature (if required)

Confirm action completed

Remedial action taken

Assessor signature Date

Internal Verifier
Date
signature

Lead Internal Verifier


Date
signature (if required)

QCF BTEC
INTERNAL VERIFICATION – ASSESSMENT DECISIONS
HND in Computing & Systems Development

Assignment Brief
BTEC Level 4-5 HNC/HND Diploma (QCF)

To be filled by the Learner


Name of the Learner : H.M. Inoka Sandamali
Edexcel No: K954984 Centre: 93104 Batch: 014

Date of Submission : 2018-12-26

Unit Assessment Information


Qualification : Higher National Diploma in Computing and Systems Development
Unit Code & Title : H/601/1456– Unit 34 - Data Structures and Algorithms
Assessment Title & No’s : Understand and implement Data structures and Strings (No 1 of 1)

Learning outcomes and grading opportunities:


LO 01: Understand data structures
√ and algorithms
√ √
Learning Outcomes LO1.1 LO1.2 LO 1.3
LO 02: Be able to implement data structures and algorithms
√ √
Learning Outcomes LO2.1 √ LO2.2 LO 2.3
LO 03: Understand how strings are structured and processed.
Learning Outcomes LO3.1 √ LO3.2 √

Merit and Distinction Descriptor


M1 M2  M3 D1 D2 D3

Assessor :Tharuka Sandamini Internal Examiner (IE) : Tharika Amali


Date Reviewed :2019-01-03 Date of IE : 2019-01-10
Date Issued :2018-09-01 Date Due :2018-12-26

Statement of Originality and Student Declaration


HND in Computing & Systems Development

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 way. I further understand what it means to copy
another’s work.

1. I know that plagiarism is a punishable offence because it constitutes theft.


2. I understand the plagiarism and copying policy of the Edexcel UK.
3. I know what the consequences will be if I plagiaries or copy another’s work in any of the
assignments for this program.
4. I declare therefore that all work presented by me for every aspects of my program, will be
my own, and where I have made use of another’s work, I will attribute the source in the correct
way.
5. I acknowledge that the attachment of this document signed or not, constitutes a binding
agreement between myself and Edexcel UK.
6. I understand that my assignment will not be considered as submitted if this document is not
attached to the attached.

Task 1

A palindrome is a phrase that reads the same forwards as it does backwards. For example, “DAD”,”
MOM”,” madam” are examples for palindrome.
HND in Computing & Systems Development

1.1. Write a program that figures out whether the given string is a palindrome. Use suitable
String operations to avoid white spaces and punctuation (LO3.2) (D3.4)
For example:
"Never a foot too far, even." is a palindrome.
"Top step -- Sara's pet spot." is a palindrome.
1.2. Create an Example Stack class for this problem. Use Array List or an array to
implement the Stack, use suitable stack operations. (LO 2.1)

1.3. Identify and implement opportunities for error handling and reporting. (LO 2.2)

1.4. Prepare a user manual for the developed solution to assist the users to work with it. (M 3.1)

Task 2

‘Read-With-Us’ Library Systems provides book reservation facilities to their members. The reservation
system uses a waiting list or book or other reading material allocation. According to the library
rules and regulations, when possible match between reservation and the book is found the member
is contacted via email or SMS and informed. If member is not responding within the given time
period, she or she is places back of the waiting list and must wait again.
We will simulate this process using a queue, and simplify the rules. We will ignore the realistic
constraints of the members, and simply have each member store a reference number for the book
(a random number). We will also assume that each book, once accepted, will be occupied from a
member ID.
Insert book details through the keyboard. Each book should have Reference number (a random
number ex: 2552)
The book Assignment process should remove a member from the queue if the member “accepts” the
reservation. If the member accepts then delete the member node. If the member rejects the
reservation delete the member, insert him to the back of the queue and compare next member and
repeat. This process repeats until all members find their book
2.1. Write your own implementation of the queue by using a linked list for this problem
with all the queue operations. (LO 1.1)

2.2. Test the above application with a suitable test cases (LO 2.3)

Task 3

3.1 Implement Linear/Binary search using recursive algorithm and non-recursive algorithm,
and compare the performance. (LO 1.3)
HND in Computing & Systems Development
3.2. Sort the array given below with two different algorithms and compare the performance.

{12, 35, 30, 85, 69, 102, 99} (LO 1.2)

3.3. Explain common string operations such as concatenation, substring, etc., also state
their practical applications by giving suitable examples. (LO 3.1) (M1.3)

ACKNOWLEDGEMENT

I would like to offer my special gratitude to our Lecturer, Miss. Tharuka Sandamini who gave
me suggestions and encouragement as well as helped me in writing my project.
HND in Computing & Systems Development

Then, I would like to appreciate all those who gave me the great opportunity to make this
assignment on the topic Data Structures & Algorithms.

Further, I must express my deepest appreciation to the Mr.Damith Pathirana, the head of
Esoft Metro Campus who gave full effort in guiding to complete this project.

I must really remember our lecturer Miss.Tharika Amali, who gave me guidance to complete
this project.

At last, I would like to thank all the staff of Esoft Metro Campus who provided all the
facilities to complete this project. I would also like to thank my parents and my friends who
helped to finalize this project.

Contents

ACKNOWLEDGEMENT.........................................................................................................v

LIST OF FIGURES................................................................................................................viii
HND in Computing & Systems Development

LIST OF TABLES...................................................................................................................xii

Introduction.............................................................................................................................1

Data Structures....................................................................................................................1

Algorithms...........................................................................................................................1

Task 1.........................................................................................................................................2

A palindrome is a phrase that reads the same forwards as it does backwards. For example,
“DAD”,” MOM”,” madam” are examples for palindrome........................................................2

1.1. Write a program that figures out whether the given string is a palindrome. Use suitable
String operations to avoid white spaces and punctuation (LO3.2) (D3.4).................................2

1.2. Create an Example Stack class for this problem. Use Array List or an array to implement
the Stack, use suitable stack operations. (LO 2.1).....................................................................6

Stack Data Structure...............................................................................................................6

Stack Operations..................................................................................................................7

1.3. Identify and implement opportunities for error handling and reporting. (LO 2.2)...........19

Error Handling......................................................................................................................19

Importance of Error Handling and Reporting.......................................................................19

Methods of Error Handling...................................................................................................19

Exceptions Handling.........................................................................................................20

1.4. Prepare a user manual for the developed solution to assist the users to work with it. (M
3.1)...........................................................................................................................................27

Contents................................................................................................................................28

Introduction.......................................................................................................................28

Describing the System.......................................................................................................28

Instructions for User..........................................................................................................28

Conclusion.........................................................................................................................35

Task 2.......................................................................................................................................37

2.1 Write your own implementation of the queue by using a linked list for this problem with
all the queue operations. (LO 1.1)............................................................................................37
HND in Computing & Systems Development

Queue Data Structure............................................................................................................37

Queue Operations..............................................................................................................37

Link List Data Structure.......................................................................................................41

Singly Link List.................................................................................................................41

Doubly Link List...............................................................................................................45

Implementation of “Read with Us” Library System.............................................................51

Login..................................................................................................................................51

Menu..................................................................................................................................54

Reservation........................................................................................................................57

Search................................................................................................................................60

2.2 Test the above application with a suitable test cases (LO 2.3)..........................................70

Content of the Test Plan........................................................................................................71

Introduction.......................................................................................................................71

Purpose of System Testing................................................................................................73

Scope.................................................................................................................................74

Test Objectives..................................................................................................................74

Test Case Template...........................................................................................................74

Testing Procedure..............................................................................................................75

Test Case for Login with Valid Credentials......................................................................76

Test Case for Login with Invalid Credentials....................................................................77

Test Case for Menu...........................................................................................................78

Test Case for Load All Reference No to the Drop down List...........................................79

Test Case for Reservation..................................................................................................81

Test Case for Search..........................................................................................................82

Test Case for Exit..............................................................................................................86

Conclusion.........................................................................................................................87

Task 3.......................................................................................................................................88
HND in Computing & Systems Development

3.1 Implement Linear/Binary search using recursive algorithm and non-recursive algorithm,
and compare the performance. (LO 1.3).................................................................................88

Algorithm..............................................................................................................................88

Search Algorithms................................................................................................................88

Linear Search.....................................................................................................................88

Binary Search....................................................................................................................90

Compare the Performance of Recursive and Non-Recursive Algorithms............................96

3.2. Sort the array given below with two different algorithms and compare the performance.
{12, 35, 30, 85, 69, 102, 99} (LO 1.2)....................................................................................97

Sorting Algorithms...............................................................................................................97

Sorting...............................................................................................................................97

Different Sorting Algorithms............................................................................................97

Compare the Performance of Insertion Sort and Bubble Sort Algorithms......................108

3.3. Explain common string operations such as concatenation, substring, etc., also state their
practical applications by giving suitable examples. (LO 3.1) (M1.3)....................................109

String...................................................................................................................................109

String Operations................................................................................................................110

Concatenation..................................................................................................................110

Examples of Concatenation.............................................................................................110

Length..............................................................................................................................115

Examples of Length.........................................................................................................115

Substring..........................................................................................................................118

Examples of Substring.....................................................................................................118

Trim.................................................................................................................................121

Examples of Trim............................................................................................................122

CompareTo......................................................................................................................124

Examples of CompareTo.................................................................................................124

CONCLUSION......................................................................................................................126
HND in Computing & Systems Development

REFERENCES.......................................................................................................................128

APPENDIX............................................................................................................................133

LIST OF FIGURES

Figure 1 - Palindrome Application.............................................................................................2


Figure 2 - Checking String using Palindrome............................................................................3
Figure 3 - Checking String Using Palindrome...........................................................................4
Figure 4 - Source Code of Palindrome Application...................................................................4
Figure 5 - Code for Reverse a String.........................................................................................5
HND in Computing & Systems Development

Figure 6 - Code for Error Handling............................................................................................5


Figure 7 - Code for Clear Inputs................................................................................................5
Figure 8 - Code for Exit from the System..................................................................................5
Figure 9 - Stack Data Structure..................................................................................................6
Figure 10 - Push Operation........................................................................................................7
Figure 11 - Code of Push...........................................................................................................8
Figure 12 - Pop Operation..........................................................................................................9
Figure 13 - Stack Class with Stack Operations........................................................................11
Figure 14 - Making Objects.....................................................................................................12
Figure 15 - Push Operation......................................................................................................13
Figure 16 - Pop Operation........................................................................................................14
Figure 17 - IsEmpty Operation................................................................................................15
Figure 18 - String is a Palindrome...........................................................................................16
Figure 19 - String is Not a Palindrome....................................................................................17
Figure 20 - Input is a Palindrome.............................................................................................18
Figure 21 - Arithmetic Expression Example............................................................................21
Figure 22 - ArrayIndexOutBound Exception...........................................................................21
Figure 23 - FileNotFoundException........................................................................................22
Figure 24 - NullPointerException............................................................................................22
Figure 25 - Try Catch...............................................................................................................24
Figure 26 - The Throws............................................................................................................25
Figure 27 - Throws...................................................................................................................25
Figure 28 – Throws..................................................................................................................26
Figure 29 - Handling NullPointerException............................................................................26
Figure 30 - Palindrome Application.........................................................................................29
Figure 31 - Enter String in the Palindrome..............................................................................30
Figure 32 - String is a Palindrome...........................................................................................31
Figure 33 - String is not a Palindrome.....................................................................................32
Figure 34 - Enter Numeric String.............................................................................................33
Figure 35 - Exception Handling...............................................................................................34
Figure 36 - Exit........................................................................................................................35
Figure 37 – Queue....................................................................................................................37
Figure 38 - Enqueue and Dequeue Operation..........................................................................39
Figure 39 - Link List................................................................................................................41
HND in Computing & Systems Development

Figure 40 - Singly Link List.....................................................................................................41


Figure 41 - Traversing..............................................................................................................42
Figure 42 Insert a Node at the Start of the List........................................................................43
Figure 43 - Insert a Node at the Middle Position of the List....................................................43
Figure 44 - Insert a Node at the End of the List.......................................................................44
Figure 45 - Delete a Node from a List.....................................................................................44
Figure 46 - Doubly Linked List...............................................................................................45
Figure 47 - Doubly Linked List Node......................................................................................45
Figure 48 - Insert a Node at the Front......................................................................................46
Figure 49 - Insert a Node after Given Node.............................................................................47
Figure 50 - Insert a Node at the End........................................................................................49
Figure 51 - Deletion in Doubly Linked List.............................................................................50
Figure 52 - Code of Deletion of a Node...................................................................................50
Figure 53 – Login.....................................................................................................................51
Figure 54 - Code of Login........................................................................................................52
Figure 55 - Main Method.........................................................................................................52
Figure 56 - Invalid Login.........................................................................................................53
Figure 57 - Successful Login...................................................................................................54
Figure 58 – Menu.....................................................................................................................54
Figure 59 - Menu Functions.....................................................................................................55
Figure 60 - Code of Menu Interface.........................................................................................55
Figure 61 - MDI Form Creation...............................................................................................56
Figure 62 - Reserve Book........................................................................................................57
Figure 63 - Code of Reserve Book...........................................................................................58
Figure 64 - Code of Reserve function......................................................................................59
Figure 65 - Code of Object Creation........................................................................................60
Figure 66 - Search Reservation................................................................................................60
Figure 67 - Search function......................................................................................................61
Figure 68 - Search Function.....................................................................................................61
Figure 69 - Search Function.....................................................................................................62
Figure 70 - Search Function.....................................................................................................63
Figure 71 - Search Function.....................................................................................................63
Figure 72 - Search method.......................................................................................................64
Figure 73 - Code of Search Function.......................................................................................65
HND in Computing & Systems Development

Figure 74 - Code of Queue Class.............................................................................................66


Figure 75 - Code of Dequeue Method......................................................................................67
Figure 76 - Code of Search and Get Member Details..............................................................68
Figure 77 - Code of QueueNode Class....................................................................................69
Figure 78 - Login Interface......................................................................................................76
Figure 79 - Invalid Login........................................................................................................77
Figure 80 – Menu.....................................................................................................................78
Figure 81 - Reserve Book........................................................................................................79
Figure 82 - Load Reference No in the Combo Box.................................................................80
Figure 83 - Reserve Book........................................................................................................81
Figure 84 - Search Function.....................................................................................................83
Figure 85 - Search Function.....................................................................................................83
Figure 86 - Search Function.....................................................................................................84
Figure 87 - Search Function.....................................................................................................85
Figure 88 - Search Function.....................................................................................................86
Figure 89 - Linear Search.........................................................................................................89
Figure 90 - Linear Search.........................................................................................................89
Figure 91 - Linear Search.........................................................................................................89
Figure 92 - Linear Search.........................................................................................................90
Figure 93 - Pseudo Code for Binary Search.............................................................................92
Figure 94 - Binary Search using Recursive Algorithms..........................................................94
Figure 95 - Binary Search using Recursive Algorithms..........................................................95
Figure 96 - Process of Insertion Sort........................................................................................98
Figure 97 – Representation of Selection Sort........................................................................102
Figure 98 - Selection Sort......................................................................................................103
Figure 99 - Represent of Quick Sort......................................................................................104
Figure 100 - Pseudo Code for Quick Sort..............................................................................105
Figure 101 - Implementation of Insertion Sort Algorithm.....................................................106
Figure 102 - Implementation of Bubble Sort Algorithm.......................................................107
Figure 103 - Syntax of String is an Array Characters............................................................110
Figure 104 - Example for String Concatenation....................................................................111
Figure 105 - Example of String Concatenation......................................................................112
Figure 106 - Example of String Concatenation......................................................................112
Figure 107 - Example of String Concatenation......................................................................113
HND in Computing & Systems Development

Figure 108 - Interface of Concatenation................................................................................114


Figure 109 - Code of Concatenation......................................................................................114
Figure 110 - Example of String Length.................................................................................115
Figure 111 - Example of String Length.................................................................................116
Figure 112 - Interface for String Length................................................................................117
Figure 113 - Code of String Length.......................................................................................117
Figure 114 - Example of Substring........................................................................................118
Figure 115 - Example of Substring........................................................................................119
Figure 116 - Interface of Substring........................................................................................120
Figure 117 - Code of Substring..............................................................................................120
Figure 118 - Represent of Trim..............................................................................................121
Figure 119 - Example of Trim...............................................................................................122
Figure 120 - Example of Trim...............................................................................................122
Figure 121 - Interface of Trim...............................................................................................123
Figure 122 - Code of Trim.....................................................................................................123
Figure 123 - Example of CompareTo....................................................................................124
Figure 124 - Example of CompareTo....................................................................................125
Figure 125 - Gantt chart.........................................................................................................133

LIST OF TABLES

Table 1 - Test Case Template...................................................................................................74


Table 2 - Testing Procedure.....................................................................................................75
Table 3 – Test Case for Login with Valid Credentials.............................................................76
Table 4 - Test Case for Invalid Login......................................................................................77
Table 5 - Test Case for Menu...................................................................................................78
Table 6 - Load All Reference No to the Drop down List.........................................................79
Table 7 - Test Case for Reservation.........................................................................................81
Table 8 - Test Case for Search.................................................................................................82
HND in Computing & Systems Development

Table 9 - Test Case for Exit.....................................................................................................86


HND in Computing & Systems Development

Task 01
HND in Computing & Systems Development

Introduction
Computers store, retrieve and process large amount of data. The data can be retrieved very
quickly for processing that further decreases the feature and the user is supplied fast response
if the data is stored in well-organized way on storage media and in computer’s memory.
Data Structures
A specific way of organizing data in a computer as it can be used efficiently is known as
Data Structure. It is about execution data elements according to some relationship for better
organization and storage. (Developerinsider, 2018) This data structures can be seen as a
logical concept that should give solution for two fundamental concerns such as how the data
will be stored and what operations will be performed on it. This is method of data schema.
And also, it should be independent of its implementation. ADT (Abstract Data Type) is
functional definition of a data structure that is independent of implementation. Examples of
several common data structures are arrays, linked lists, queues, stacks, binary trees, and hash
tables. There are two types of data structures such as Primitive Data Structures and Non-
primitive Data Structures.
Algorithms
A limited set of instructions or logic written in order to accomplish a certain predefined task
is known as an algorithm. It not a complete program or code. Algorithm is just the core
solution (logic) of a problem that can be expressed both as an informal high level explanation
as pseudo code or using a flowchart. (Studytonight, 2018)
Commonly, the algorithms are useful for searching for a specific data item and sorting the
data. And also, it is a step by step process of solving problems. The algorithms are
implemented in form of methods or functions or routines. The performance of the algorithms
are used to measure two basic properties such as,
 Time Complexity
 Space Complexity
Time Complexity is used to define the amount of time need by the program to run till its
completion. Normally, it is a better practice to try to keep the time required minimum.
Therefore, the algorithm completes its execution in the minimum time possible.
Space Complexity is the amount of memory space need by the algorithm in the sequence of
its execution. This can be taken for multi-user systems and in occasions where limited
memory is available.
HND in Computing & Systems Development

Task 1

A palindrome is a phrase that reads the same forwards as it does backwards. For
example, “DAD”,” MOM”,” madam” are examples for palindrome.

1.1. Write a program that figures out whether the given string is a palindrome. Use
suitable String operations to avoid white spaces and punctuation (LO3.2) (D3.4)
The author has implemented a Palindrome Application to check whether the any string is a
palindrome or not. The author has used Netbeans IDE to implement this application. And
also, Java Programming Language is used to implement this application. It can identify any
string is a palindrome or not by using this application. Below show the palindrome
application.

Figure 1 - Palindrome Application


(Author, 2018)
HND in Computing & Systems Development

When entering a string, it shows that string is a palindrome or not as in the below. Below
figure shows the entering string is a palindrome.

Figure 2 - Checking String using Palindrome


(Author, 2018)
HND in Computing & Systems Development

Below shows the entering string is not a palindrome.

Figure 3 - Checking String Using Palindrome


(Author, 2018)

The source code related to that application is shown in the below. It shows the code that is
written for the CHECK button.

Figure 4 - Source Code of Palindrome Application


(Author, 2018)
HND in Computing & Systems Development

In this application, when entering a string and press CHECK button, it shows the reverse of
that string. In the below code shows the code lines of that makes the reverse of string.

Figure 5 - Code for Reverse a String


(Author, 2018)

In here, the author has made the exception handling in this application. The author has avoid
the NullPointerException by using this code lines.

Figure 6 - Code for Error Handling


(Author, 2018)

Below shows the code of CLEAR button. This code is used to clear inputs in the text fields.

Figure 7 - Code for Clear Inputs


(Author, 2018)
Below shows the code lines that is used to implement the exit of the application.

Figure 8 - Code for Exit from the System


(Author, 2018)
HND in Computing & Systems Development

1.2. Create an Example Stack class for this problem. Use Array List or an array to
implement the Stack, use suitable stack operations. (LO 2.1)
Stack Data Structure
Stack is simple data structure. It is an abstract data type with a predefined size. Stack can
adding and removing elements in a certain order. When an element is added to a stack, every
time it goes on the top of the stack and when removing also, it has to remove element form
the top. (Studytonight, 2018) Stack is behaved according to the LIFO principle. It means,
Last in First Out. There are two main functions in Stack data structure such as push function
and pop function. Push function is used to add new element in to the stack. Pop is used to
eliminate an element from the stack. Elements can be added and eliminated from the stack
only at the top. Therefore, a stack is a limited access data structure.

Figure 9 - Stack Data Structure


(Tutorialspoint, 2018)
HND in Computing & Systems Development

Stack Operations
Mainly, there are two operations allowed in the stack data structure.
1. Push Operation – Inserting an element in to the stack
2. Pop Operation – Eliminating an element from the stack
Push Operation
Pushing or storing an element to the stack. A new element is added at the top of the stack at
every time. It needs the item and no return value when pushing an element to the stack. When
inserting an element to the stack, it should be inserted from the top of the stack.
There are five steps are taken in to consideration in push operation.
1. Step 01 - Check whether the stack is full or not
2. Step 02 - Produces an error and exit, if the stack is full
3. Step 03 - Increments top to point next empty space, if the stack is not full
4. Step 04 - Insert an element to the stack location where top is pointing
5. Step 05 - Returns success
(Tutorialspoint, 2018)

Figure 10 - Push Operation


(Tutorialspoint, 2018)

The algorithm for Push operation is shown in the below.


HND in Computing & Systems Development

(n is a maximum size of the stack)


Begin
If top = n - 1 then stackfull;
Top = top + 1;
Stack (top) = item;
End
An example code for the push operation is shown in the below.

Figure 11 - Code of Push


(Tutorialspoint, 2018)

Pop Operation
Removing or eliminating an element from the stack. First element is removed from the top of
the stack at every time. It needs no parameters and returns the item. When removing an
element from the stack, the stack is modified. When removing an element from the stack, it
should be removed from the top of the stack.
A pop operation can be consider in five steps such as,
1. Step 01 – Check whether the stack is empty
2. Step 02 – Produces an error and exit, if the stack is empty
3. Step 03 – Remove an element at which top is pointing, if the stack is not empty
4. Step 04 – Reduces the value of top by 1
5. Step 05 – Returns Success
(Tutorialspoint, 2018)
HND in Computing & Systems Development

Figure 12 - Pop Operation


(Tutorialspoint, 2018)

The algorithm for Pop operation is shown in the below.


Begin
If top = -1 then stackempty;
Item = stack (top);
Top = top – 1;
End
Other than these operations, some functionalities are added to stack. It need to check the
status of stack as well, to use the stack efficiently. These functionalities are,
 Peek ()
 isFull ()
 isEmpty ()
HND in Computing & Systems Development

Peek ()
In here, remove the top item from the stack but does not remove it. Only the copy of that
element is removed. It needs no parameters. The stack is not modified as it does not make a
change here. The algorithm of peek () function is shown in the below.
Begin procedure peek
Return stack [top];
End procedure
IsFull ()
In this function, it tests to see whether the stack is full. It needs no parameters and returns a
Boolean value (true or false). The algorithm is shown in the below.
Begin procedure isFull
If top equals to MAXSIZE;
Return true;
Else
Return false;
Endif
End procedure
IsEmpty ()
This checks to see whether the stack is empty. It needs no parameters and returns a Boolean
value. The algorithm is shown in the below.
Begin procedure isEmpty
If top less than 1;
Return true;
Else
Return false;
Endif
End procedure
HND in Computing & Systems Development

The author has used Stack class also to create this palindrome application that is used to
check the string is a palindrome or not using the Stack operations such as Push, Pop, and
IsEmpty.
In here, the author has first create a Stack class as below.

Figure 13 - Stack Class with Stack Operations


(Author, 2018)

Figure 14 - Making Objects


(Author, 2018)
HND in Computing & Systems Development

Then, this stack class call in the button of the palindrome application by making objects as
shown in the figure.

Then, stack operations such as Push, Pop and IsEmpty are called using object name.

Figure 15 - Push Operation


(Author, 2018)
HND in Computing & Systems Development

Figure 16 - Pop Operation


(Author, 2018)
HND in Computing & Systems Development

Figure 17 - IsEmpty Operation


(Author, 2018)
HND in Computing & Systems Development

However, palindrome application are performed using Stack class with Stack operations.

Figure 18 - String is a Palindrome


(Author, 2018)
HND in Computing & Systems Development

Figure 20 - Input is a Palindrome


(Author, 2018)
HND in Computing & Systems Development

1.3. Identify and implement opportunities for error handling and reporting. (LO 2.2)
Error Handling
In Error handling, it mentions to the expectation, finding, and resolving errors of
programming, application, and communications. Some applications have presented
specialized programs, it means error handlers. It can recover the error when the error occur
without ending the application or gracefully end an affected application and then save the
error information to a log file. (Techtarget, 2018)
When developing systems and scripts, error handling is mostly important part. Appropriate
error handling is mostly essential for the software systems to reduce the number of errors in
the code.
Importance of Error Handling and Reporting
Error handling and reporting is very important to end users of the code. It makes very easier
for them to use the code correctly. And also, error handling makes easy to maintain the code.
Then, it will made easier to insert input specifications into the code. Therefore, the users
don’t have to look up the design when they write and later maintain the code.
The program will likely continue to function after an error, the customers can likely continue
working and it can supply a report of accurately how the bugs happened. Therefore, it can fix
the errors. If they handle their errors.
But, it does not handle the errors in the program, the program may crash. Therefore, error
handling is mostly important for programming.
Methods of Error Handling
Due to all the above things, there are some error handling method in programming. Some of
them are,
 Exceptions Handling
 Debugging
HND in Computing & Systems Development

Exceptions Handling
Exceptions
The mechanisms that used to reporting and handling errors, sudden or exceptional conditions
that can occur during the execution of an object’s methods are known as exceptions. The
code that discovers the error or condition “throws” an exception, when such a situation
occurs. The client of the code that threw the exception may “catch” the exception and handle
it or propagate the exception. Exception supply a method to change the program’s execution
path for times when unexpected behaviour occurs. (Dccc, 2018)
When a program is running, the process of responding to exceptions are known as exception
handling. It means, the errors that occurred in the run time of the program is called as an
exception. An exception happens, when an unexpected incident happens that requires special
processing. When a user giving irregular input or not giving an input, a system error being
met when trying to read or write a file. It means, the system gets stuck. Exception handling
tries to handle these conditions. It that occasions, it needs to give a considerable response to
the user. Therefore, the program does not crash/stuck.
Types of Exceptions
There are many exceptions that can occurred in a program. Some of them are,
 Arithmetic Exception
 ArrayIndexOutOfBound Exception
 FileNotFound Exception
 NullPointer Exception
(Study, 2018)

Arithmetic Exception
This can be occurred when an exceptional condition has occurred in an arithmetic operations.
Below shows the code of handling of arithmetic exception.
HND in Computing & Systems Development

Figure 21 - Arithmetic Expression Example


(Geeksforgeeks, 2018)

ArrayIndexOutOfBound Exception
This exception can occur to show that an array has been retrieved with an illegal index. Either
the index is negative or greater than or equal to the size of the array.
Below figure shows program of handling Arrayindexoutofbound exception.

Figure 22 - ArrayIndexOutBound Exception


(Geeksforgeeks, 2018)
HND in Computing & Systems Development

FileNotFound Exception
When a file is not accessible or does not open, this exception can be occurred.

Figure 23 - FileNotFoundException
(Geeksforgeeks, 2018)

NullPointer Exception
This exception is occurred when referring to the members of a null object. Null means empty.
Below shows a code for handling nullpointer exception.

Figure 24 - NullPointerException
(Geeksforgeeks, 2018)

Method of Handling Exceptions


There are some methods used to handle exceptions in programs such as,
HND in Computing & Systems Development

 Try-Catch Block
 The throws

Try-Catch Block
The try-catch block is situated in the code that could be occurred an exception. The code
inside the try-catch block is denoted to as protected code. The try-catch block syntax is
shown in the below.
Try {

Code

} Catch (ExceptionName e1) {

Catch Block
}

It is placed in the try block that the code which is prone to exceptions. The exception that is
occurred when an exception occurs. Each and every try block is consists of either by a catch
block or finally block.
The catch includes stating the type of exception that is trying to catch. The catch block that
followed the try is tested if an exception occurs in the protected code. The exceptions is
passed to the catch block much as an argument is passed into a method parameter, if the type
of exception that occurred is listed in a catch block.

The author has used try-catch blocks in this application. Examples of try-catch block used in
this code is shown in the below.
HND in Computing & Systems Development

The throws
It can throw an exception, either a newly prepared one or an exception that just caught by
using the throws. Throw is used to appeal an exception clearly.

Some examples are shown in the below.

Figure 26 - The Throws


(Tutorialspoint, 2018)
HND in Computing & Systems Development

Figure 27 - Throws
(BeginnersBook, 2018)

Figure 28 – Throws
(Tutorialspoint, 2018)
According to this palindrome application, the author has handled NullPointer Exception. This
exception is occurred if the user clicks the CHECK button without entering an input. That is
the exception that can occurred in this application. Therefore, the author has handled this
exception properly. Below shows the source code of handling nullpointer exception.

Figure 29 - Handling NullPointerException


(Author, 2018)
HND in Computing & Systems Development

1.4. Prepare a user manual for the developed solution to assist the users to work with it.
(M 3.1)

USER MANUAL FOR


THE
PALINDROME
APPLICATION

Prepared By: H.M.Inoka Sandamali


HND in Computing & Systems Development

Contents
1. Introduction
 What is a User Manual
 Purpose of User Manual
2. Describing the System
3. Instructions for User
4. Conclusion

Introduction
User Manual
User Manual is a document that is written to help people understand a software application or
IT system. When writing a User Manual, use simple language with short sentences. This
simple writing style helps the user understand the application. By using this document, the
user can get clear understanding about the application. The User Manual includes all
information for the user about full use of the application. It contains a description of the
system functions and step by step procedures for system access and use.

Purpose of the User Manual


Purpose of the capabilities User Manual is to provide information to a user. They well
organized and very easy to understand and very simple to understand. User Manual is give
someone instructions on how to do something correctly. It provides an overview describing
the best practices, activities, information about system using.
Describing the System
This is a Palindrome Application. Mainly this application is used to identify whether any
string is palindrome or not. When entering any string as the input, it show whether that string
is a palindrome or not.
Instructions for User
Below it shows the clear instructions about how to use this application. By following these
instructions, the user can handle the application well. It shows the instructions very clearly. It
can understand by everyone. The author has used simple English to give these instruction to
understand the user.
HND in Computing & Systems Development

In this Palindrome Application, the user can see below interface at first.

Figure 30 - Palindrome Application


(Author, 2018)
HND in Computing & Systems Development

Then, the user has to enter the string that need to check for palindrome as in the below.

Figure 31 - Enter String in the Palindrome


(Author, 2018)

Then the user has to press CHECK button. After that the user can see whether that string is a
palindrome or not as in the below figure.

After pressing CHECK button, this shows the Reverse of the String in the field. And also, the
Result is shows in the field as in the below.
HND in Computing & Systems Development

Other than the Result showing in the field, the application gives the result from the message
dialog box also.

Figure 32 - String is a Palindrome


(Author, 2018)
HND in Computing & Systems Development

If the user has entered different strings, as in the below the application shows that string is not
a palindrome. The user can see this message from a message dialog box also. The result is
proved well as this message dialog box.

Figure 33 - String is not a Palindrome


(Author, 2018)
HND in Computing & Systems Development

When the user entering a string consists of numbers, as the below it shows the results.
Numbers also falls under the strings.

Figure 34 - Enter Numeric String


(Author, 2018)
HND in Computing & Systems Development

If the user has pressed CHECK button without entering a string, a message will automatically
come as in the below by informing the message “Please Insert String Value”.

Figure 35 - Exception Handling


(Author, 2018)
HND in Computing & Systems Development

After finishing the checking for palindromes, the user can exit from the application. The user
can exit from the application by pressing Exit button as shown in the below.

Figure 36 - Exit
(Author, 2018)

Conclusion
In this document, it can get the clear understanding about the User Manual. It clearly shows
how to write a user Manual for usage of users. User Manual is very important and essential
document for users as they can get clear knowledge about the application and how it works.
In the earlier, the author does not has much enough knowledge about how to write a User
Manual. At present the author has better knowledge about the User Manual. User Manual
includes all the instructions essential for the user about use of the application. In here, it has
mentioned about how perform the Palindrome Application. In here, it has mentioned easily
understandable steps. However, this document is mostly important for the users who use this
Palindrome Application. Finally, it can conclude that the User Manual is a very essential to
HND in Computing & Systems Development

the user to get the idea about the application. The User Manual is definitely prepared for the
user after developing an application.

Task 02
HND in Computing & Systems Development

Task 2

2.1 Write your own implementation of the queue by using a linked list for this problem
with all the queue operations. (LO 1.1)
Queue Data Structure

Queue is a linear data structure or abstract data type. It is also like stack data structure. The
first element that is inserted from one end is known as Rear or Tail. The other end that the
removable of existing element takes place is known as Front or Head. This data structure is
behaved according to the FIFO (First in First Out) principle. It means, when the element is
inserted first, it will be removed first. (Studytonight, 2018) The queue data structure is also an
ordered list of elements with same data types. New element is inserted in to the rear of the
queue when inserting new element in to a queue. To remove an element from the queue, all
the elements before the removing element should be removed in the queue.

Figure 37 – Queue
(Studytonight, 2018)

Queue Operations
When considering the queues, there are basic queue operations can be identified.
1. Enqueue – Insert an item to the queue
HND in Computing & Systems Development

2. Dequeue – Remove an item from the queue


Enqueue Operation
When considering queues, there are two data pointers like Front and Rear. Data is inserted in
to the rear of the queue in the Enqueue operation. Rear means the back of the queue. There
are some steps to follow when inserting data item to the rear of the queue.
1. Step 01 – See whether the queue is full or not
2. Step 02 – Produce excess error and exit, if the queue is full
3. Step 03 – Increase rear pointer to point the next empty space, if the queue is not full
4. Step 04 – Insert data to the queue location where the rear is pointing
5. Step 05 – Return Success
(Tutorialspoint, 2018)
Algorithm for Enqueue operation is shown in the below.
Begin
If queue isFull;
Return overflow;
Endif
Rear = rear + 1;
Queue [rear] = item;
Return true;
End
Dequeue Operation
In here, removing an item from the front in the queue is happened. When removing an item
from the front, following steps should be taken in to consideration.
1. Step 01 – See whether the queue is empty or not
2. Step 02 – Produce overflow error and exit, if the queue is empty
3. Step 03 – Remove the data where front is pointing, if the queue is not empty
4. Step 04 – Increase front pointer to point to the next available data element
5. Step 05 – Return Success
(Tutorialspoint, 2018)
HND in Computing & Systems Development

The algorithm related to Dequeue operation is shown in the below.

Begin
If queue isEmpty;
Return underflow;
Endif
Item = queue [front];
Front = front + 1;
Return true;
End
It can understand about the Enqueue and Dequeue operations using below figure.

Figure 38 - Enqueue and Dequeue Operation


(Hackerearth, 2018, 2018)
HND in Computing & Systems Development

There are some supportive functions of the queue as in the stack data structure. These
functions make the queue operations efficient.
 Peek () – Take the item at the front of the queue without removing it. Only like a copy
of the item taken.
Algorithm is shown below for this function
Begin procedure peek
Return queue [front];
End procedure

 IsFull () – Checks the queue is full


Algorithm of isFull () is shown in the below
Begin procedure isFull
If rear equals to MAXSIZE;
Return true;
Else
Return false;
Endif
End procedure

 IsEmpty () – Checks if the queue is empty


Below shows the algorithm of isEmpty ()
Begin procedure isEmpty
If front < MIN or front > rear;
Return true;
Else
Return false;
Endif
End procedure
HND in Computing & Systems Development

Link List Data Structure


Link list is an arrangement of data structures that are connected together through links.
Actually it is an arrangement of links that contains items. Every link includes a connection to
another link. After the array, this data structure is the most used one. (Tutorialspoint, 2018)
Link list can be represent as a series of nodes. Each node points to the next node.

Figure 39 - Link List


(Tutorialspoint, 2018)

There are two types of Link List data structure.


1. Singly Link List
2. Doubly Link List
Singly Link List
Each element has some data and a link to the next element, which allows to keep the structure
in Singly Link List. (Algolist, 2018) Every element is called as a Node. The first node can be
identified as Head. It can access other nodes in the list by considering the head node. Every
node points to the next node present in the order. Always, last node is pointed to NULL.
This link list is traversed only for one direction. It means, there is only one next pointer.
Therefore, it can’t traverse the singly list to the reverse direction.

Figure 40 - Singly Link List


(Geeksforgeeks, 2018)
HND in Computing & Systems Development

Traversing
Traversing is the process of start with the head and access each node until reach null. It does
not change the head reference. (Cs.cmu, 2018) Simply this means, moving through node by
node sequentially. The main pattern of processing the data element of a node can be shown as
follows.
 Start at the first node
 Repeat until there are no more nodes
 Process the existing node
 Move to the next node
This pattern of process is the standard sequential processing. Links are involved in each step.
It need to use link variables to access every node in the data structure. As it moving every
node, update this link to keep up with the current place in the data structure.
This process can be mostly understand by using the below figure.

Figure 41 - Traversing
(Sqa, 2018)
Operations
Mainly, it can perform these functions using singly link list.
1. Insert
2. Delete
Insert
This insert operation is used to add new node to the link list. Insert can be happened in three
ways. (Tutorialride, 2018)
1. At the Start of the list
2. At the Middle position of the list
3. At the End of the list
At the Start of the list
HND in Computing & Systems Development

In here, to insert a new node to the start, it means to the head of the list, a new node need to
add head and the first data node. The steps are,
1. Form a new node using the data to be added.
2. Set new node to the first data node, the head is pointing.
3. Set head to the new node
Inserting a new node to begin of the list can be shown in below figure.

Figure 42 Insert a Node at the Start of the List


(Cs.cmu, 2018)

At the Middle position of the list


In here, this means adding a new node at the middle of the link list. In this process, below
steps can be followed.
1. Observe through the list until the node before the required insertion point is found.
2. Form a new node using the data to be added.
3. Set the new node’s next reference to the same as the next reference of the node before
the insertion point.
4. Set the node before the insertion point’s next reference to the new node.
The following figure shows this process clearly.

Figure 43 - Insert a Node at the Middle Position of the List


(Tutorialride, 2018)

At the End of the list


HND in Computing & Systems Development

The following steps can be followed when adding a new node at the end of the link list.
1. Observe through the list until the final node is met.
2. Form a new node using the data to be added.
3. Set the new node’s next reference to null.
4. Set the end node’s next reference to the new node.
Using the below figure, it can understand the process of inserting a new node at he end of the
list.

Figure 44 - Insert a Node at the End of the List


(Cs.cmu, 2018)

Delete
Delete operation can be used to delete a node from the list. When considering the deleting a
node from the link list, according to the below figure find the required node and delete it from
the list.
In the below figure, it has deleted a node with X.

Figure 45 - Delete a Node from a List


(Tutorialride, 2018)
HND in Computing & Systems Development

Doubly Link List


Variation of linked list in which navigation is possible in both ways, both forward and
backward easily compared to single link list is known as doubly link list. (Tutorialspoint,
2018)
Every node consist of two fields called links that are references to the previous and to the
next node in the sequence of nodes. It need to change more links than the same operations on
a singly link list while adding or removing a node in a doubly linked list.
Below shows the figure view of doubly link list.

Figure 46 - Doubly Linked List


(Programiz, 2018)

It can represent doubly link list node.

Figure 47 - Doubly Linked List Node


(Javatpoint, 2018)
HND in Computing & Systems Development

Operations
Mainly, it can identify two operations using doubly link list.
1. Insertion
2. Deletion
Insertion
In here, the insertion it means add node can be done in three ways.
1. Insert a node at the front
2. Insert a node after given node
3. Insert a node at the end
Insert a node at the front
In this process, a new node is inserted before the head of the link list. Then, newly inserted
node becomes the new head of the doubly link list. Then, call the push () function that adds a
node at the front of the list. Function push () must obtain a pointer to the head pointer since
push must change the head pointer to point to the new node.
Below figure shows a this process.

Figure 48 - Insert a Node at the Front


(Geeksforgeeks, 2018)

Five steps to add node at the front is shown in the below.


public void push (int new_data)
{
1. Allocate node 
2. Put in the data
    Node new_Node = new Node (new_data);
3. Make next of new node as head and previous as NULL
    new_Node.next = head;
HND in Computing & Systems Development

    new_Node.prev = null;
4. Change prev of head node to new node
    if (head! = null)
        head.prev = new_Node;
5. Move the head to point to the new node
    head = new_Node;
}

Insert a node after given node


It has given pointer to a node as prev_node and new node is added after the given node.
Process is same as the above inserting a node at the front.
This process is shown in the below figure.

Figure 49 - Insert a Node after Given Node


(Geeksforgeeks, 2018)

It needs two steps extra to change previous pointer of new node and previous pointer of new
node’s next node.
public void InsertAfter (Node prev_Node, int new_data)
{
1. Check if the given prev_node is NULL
    if (prev_Node == null) {
        System.out.println ("The given previous node cannot be NULL ");
        return;
    }   
2. Allocate node 
HND in Computing & Systems Development

3. Put in the data


    Node new_node = new Node (new_data);
4. Make next of new node as next of prev_node
    new_node.next = prev_Node.next;
5. Make the next of prev_node as new_node
    prev_Node.next = new_node;
6. Make prev_node as previous of new_node
    new_Node.prev = prev_Node;
7. Change previous of new_node's next node
    if (new_node.next != null)
        new_node.next.prev = new_node;
}

Insert a node at the end


In here, a newly node is inserted after the last node of the link list. It needs to traverse the link
list until end. Then, change the next of last node to new node.

Figure 50 - Insert a Node at the End


(Geeksforgeeks, 2018)
Following are seven steps to insert a node at the end.
HND in Computing & Systems Development

void append (int new_data)


{
1. Allocate node 
2. Put in the data
    Node new_node = new Node (new_data);   
    Node last = head; Used in step 5
3. This new node is going to be the last node, so make next of it as NULL
    new_node.next = null;
4. If the Linked List is empty, then make the new node as head
    if (head == null) {
        new_node.prev = null;
        head = new_node;
        return;
    }   
5. Else traverse till the last node
    while (last.next!= null)
    last = last.next;
6. Change the next of last node
    last.next = new_node;
7. Make last node as previous of new node
    new_node.prev = last;
}
Deletion
Delete a node from the list using the key. Below shows the figure of deleting a node in the
middle of a doubly linked list.

Figure 51 - Deletion in Doubly Linked List


(Java2novice, 2018)
HND in Computing & Systems Development

It has represented a code of deletion of a node at the beginning of a doubly linked list.

Figure 52 - Code of Deletion of a Node


(Tutorialspoint, 2018)

Implementation of “Read with Us” Library System


In here, this system has implemented for “Read with Us” Library. According to the
requirements of the library, this system has implemented. The author has used NetBeans IDE
8.2 software to create this Library System. This system has implemented using the concept of
Data Structures. In this case, the author has used Queue and Link List Data Structures when
implementing this system. The author has used queue operations such as Enqueue and
Dequeue and more while using link list operations. According to this system, mainly it helps
to perform the book reservation facilities to the members.
HND in Computing & Systems Development

Login
Below shows an interface of login. It can login to the system using this interface.

Figure 53 – Login
(Author, 2018)

Figure 54 - Code of Login


(Author, 2018)
The source code that is used to implement the login function is shown in the below. In here, it
has mentioned the system exit code also that is written for the Exit button.

This system is run from the below code. It means, it starts run the system from the main
method.
HND in Computing & Systems Development

If it has

Figure 55 - Main Method


(Author, 2018)

Figure 56 - Invalid Login


(Author, 2018)
entered an incorrect username or password, error message can be seen as in the below.

By entering correct username and password, welcome message can be seen as in the below.
HND in Computing & Systems Development

Figure 57 - Successful Login


(Author, 2018)

Menu
It can enter to the Menu page by successful login.

Figure 58 – Menu
(Author, 2018)
HND in Computing & Systems Development

In this interface, it can perform functions related to the library. It can perform Book
Reservation and Search Book as in the below figure.

Figure 60 - Code of Menu Interface


Figure (Author,
59 - Menu
2018)
Functions
(Author, 2018)
The source code related to above interface is shown in the below.
HND in Computing & Systems Development

Unlike the other system, this system is implemented using MDI form concept. Then, it can
perform several functions at once. MDI method means, it can open several interfaces and
perform the task as in the below.

Figure 61 - MDI Form Creation


(Author, 2018)
HND in Computing & Systems Development

Reservation
This interface used to make book reservation. Member can reserve book using this. In here,
load the Reference No in the drop down list automatically. Then, it can select Reference No
using this list. After that, it fills the Member ID field automatically related to that Reference
No. The reason is when implementing the system, it has inserted book details through
keyboard. Then, that details automatically filled. By pressing Reserve button, it can reserve a
book successfully as in the below. Successful message also comes.

Figure 62 - Reserve Book


(Author, 2018)
HND in Computing & Systems Development

Below shows the code lines of reservation function. It has used integer type variables to store
Reference No and Member ID. Then, takes values from the fields and call to the Enqueue
method by making objects related to the Enqueue method in this class as in the code.

Figure 63 - Code of Reserve Book


(Author, 2018)

According to this system, all the Reference No are load to the drop down list. Due to this
code, this process is happened. Switch case control structure is used to perform this process
as in the figure. According to this, when selecting the Reference No from the Drop down list,
the Member ID is fills automatically in the field related to that Reference No.
HND in Computing & Systems Development

In the below, it has shown object that create in the reservation class to join with Queue class.

Figure 65 - Code of Object Creation


(Author, 2018)
Search
This interface can be used to search reservation. By entering Reference No and pressing
SEARCH button, it performs the function.

Figure 66 - Search Reservation


(Author, 2018)
HND in Computing & Systems Development

By pressing SEARCH button, message has come as in the below.

Figure 67 - Search function


(Author, 2018)
Figure 68 - Search Function

(Author, 2018)
If it will pressed Yes, show message again as in the figure.
If it is given Yes, reservation can be accessed. Message is shown in the figure.

Figure 69 - Search Function

(Author, 2018)
HND in Computing & Systems Development

There is no response from the member, the reservation will cancelled as in the below.
Figure 70 - Search Function
(Author, 2018)

Figure 71 - Search Function


(Author, 2018)
If it does not need to inform to the member, the reservation is hold until the member is
responding.
HND in Computing & Systems Development

The source code related to this function is shown in the below.


In here, object is created to connect with Queue class. And method is created as Search in the
search class. This Search method is defined to Enqueue Member ID and the Reference No as
in the figure.

Figure 72 - Search method


(Author, 2018)
HND in Computing & Systems Development

Search is happened using Reference No. Details are get from the earlier made New_Object. If
it happen a reservation, the Enqueue details are Dequeue from the list. Message dialogue
boxes are used for show this process.

Figure 73 - Code of Search Function


(Author, 2018)
HND in Computing & Systems Development

Mainly, this system performs according to the implementing this Queue Class. Whole process
is happened according to this class. Inside this class. It has includes all the methods such as
inserting and deleting details from the list. It means like Enqueue, Dequeue functions and
same as insert, delete functions using linked list.
Below shows the Enqueue function and variable declaration for head, front and rear.

Figure 74 - Code of Queue Class


(Author, 2018)

This shows a Dequeue function.


HND in Computing & Systems Development

Below shows the functions of search and get member details.

Figure 76 - Code of Search and Get Member Details


(Author, 2018)
HND in Computing & Systems Development

QueueNode class is shown in the below. Integer type variables are defined in here and made
these as public so as to use these variables in any method.

Figure 77 - Code of QueueNode Class


(Author, 2018)
HND in Computing & Systems Development

2.2 Test the above application with a suitable test cases (LO 2.3)

TEST PLAN
FOR THE
“READ WITH US”
LIBRARY SYSTEM

Prepared For: “Read With Us” Library


Prepared By: H.M.Inoka Sandamali
HND in Computing & Systems Development

Content of the Test Plan


1. Introduction
 What is System Testing?
 Black Box Testing
 White Box Testing
2. Purpose of System Testing
3. Scope
4. Test Objectives
5. Test Case Template
6. Testing Procedure
7. Conclusion

Introduction
“Read with Us” Library System can use to reserve book to their members. In here, this
system performs a waiting list or book or other reading material allocation. A member is
contacted through email or SMS and informed if the possible match between reservation and
the book is found. Author has used Queue Data Structure with Linked list to develop this
system. Author has used test plan to test this system.

System Testing
Testing of a complete and fully integrated software product is the System Testing. Generally,
software is only one element of a larger computer based system. This testing is really a series
of different tests whose single purpose is to exercise the full computer based system.
(guru99, 2018)
HND in Computing & Systems Development

There are two types of System Testing.

1. Black Box Testing


2. White Box Testing

Black Box Testing


Normally, System Test falls under the Black Box Testing. This is used to test functionality of
the program without knowing the internal structure of the application. It means the tester
checks the system architecture without accessing to the source code of it.

Advantages of Black Box Testing:

 Source code is not required


 Mostly suited and effective for large code segments
 Testers can test the application with no knowledge of implementing or programming
language.
 Tests are done from user’s viewpoint

Disadvantages of Black Box Testing:

 Limited test cases can be executed


 The tester cannot target specific code segments or error areas, it affect for the blind
coverage
 It is difficult to design the test cases
 Quality of coding and standards will be unidentified

(Tutorialspoint, 2018)

White Box Testing


Testing of the internal working or code of a software application is the White Box Testing. It
means this is used to test internal structure of the application. In here, tester tests functional
flow, variable values and calculations of the source code to identify that output is expected or
not.
HND in Computing & Systems Development

Advantages of White Box Testing:

 It tells errors in hidden codes


 Helps to optimize the code
 Can remove extra lines of the code that can bring in hidden defects
 It is very easy to find which kind of data can help to test the application effectively
due to the tester has knowledge of source code

Disadvantages of White Box Testing:

 Skilled testers are required to perform white box testing, the cost is increased
 Specialized tools are needed such as code analyser and debugging tools
 It needs specialized tools like code analyser and debugging tools for white box
testing. Therefore, it is difficult to maintain white box testing

(Tutorialspoint, 2018)

Purpose of System Testing


Testing is very important part of the system developing. Mainly, the author has used testing
for test the quality of the system and different factors such as security, efficiency, usability
and maintainability. It must be done before it give to the user. System testing is done to check
the behaviour of a completed and fully combined application. The main aim of testing is
evaluate end user requirements. This testing is used to find bugs based on application
behaviour, design and expectation of end users. It can be used to validate and verify the
system. System testing is used to ensure that the system will function correctly and properly
when all functions are bundled as a whole. Finally, system testing is very useful for give
better product for the user. By considering all these facts, the author has tested this
application.
HND in Computing & Systems Development

Scope
In here, this system performs a waiting list or book or other reading material allocation. A
member is contacted through email or SMS and informed if the possible match between
reservation and the book is found. Before hand over the output to the user, the testing should
be done to the whole system.
Author has created different test cases to system testing. In here, the author has check the
actual results and expected results and compare both results. By using sample data, the author
has checked whether actual results has been come or not. The author has tested whether all
records are deal with system properly or not.
Test Objectives
System test expects to verify all the functions are performed properly. System testing make
sure that all the user requirements are meet. It is very useful to find errors and minimize
them. System test is used to find incorrect and missing function. It shows the errors in code
also. It is easy to identify performance errors also using system testing. System tests expects
confidence in and supplying information about the level of quality.

Test Case Template

Expected Actual Test Outcome


Test Case Input Data
Results Results (Pass/Fail)

Table 1 - Test Case Template


(Author, 2018)
HND in Computing & Systems Development

Testing Procedure
In here, author has gave the system to test others as the testing procedure. Author has selected
some persons and test the system. Then the author can identify all errors in the system. And
also, the user can identify the efficiency, performance, speed, accuracy and all other things in
the system by this testing procedure.

Test Case No Description Tester Name Test Date

Login with Valid


01 Supun Kaushalya 23rd of November 2018
Credentials

Login with Invalid


02 Prinsi Prabodha 23rd of November 2018
Credentials

03 Main Menu Lihini Lakma 23rd of November 2018

Load Reference No to the


04 Udara Madusanka 24th of November 2018
Drop Down List

05 Reservation Malindu Darshana 24th of November 2018

06 Search Sonali Vidusha 27th of November 2018

07 Exit Dilshan Gamage 27th of November 2018

Table 2 - Testing Procedure


(Author, 2018)

Test Case for Login with Valid Credentials


Test Case: 01

Test Case Name: Login with Valid Credentials


HND in Computing & Systems Development

Tested By: Supun Krishantha

Input Status
Test Case Expected Results Actual Results
Data (Pass/Fail)

Login with Valid Display Success Display Success


Credentials Message Message
“WELCOME” “WELCOME”
1. Username
Librarian Pass

2. Password
123

Test Case for Login with Invalid Credentials


Test Case: 02

Table 3 – Test Case for Login with Valid Credentials


(Author, 2018)

Figure 78 - Login Interface


(Author, 2018)

Test Case Name: Login with Invalid Credentials

Tested By: Prinsi Prabodha

Test Case Expected Results Actual Results


Input Status
HND in Computing & Systems Development

Data (Pass/Fail)

Login with Invalid Display Error Display Error


Credentials Message “Wrong Message
Username or “Wrong
1. Username Librarian
Password” Username or Pass
Password”
2. Password

12456

Test Case for Menu


Test Case: 03

Test Case Name: Menu

Tested By: Lihini Lakma


Status
Expected
Test Case Input Data Actual Result (Pass/Fail
Result
)

Menu
Show
1. Press Reservation Reservation and Show Reservation
Pass
2. Press Search Search and Search Interfaces
Table 4 - Test Case for Invalid Login
Interfaces
(Author, 2018)
HND in Computing & Systems Development

Test Case for Load All Reference No to the Drop down List
Test Case: 04

Test Case Name: Load All Reference No to the Drop down List

Tested By: Udara Madusanka

Input Status
Test Case Expected Results Actual Results
Data (Pass/Fail)

Load All Reference Shows a Not Shows a


No to the Drop down Reference No list Reference No
List 5 - Test Case for Menu
Table list
Drop
Down Box
1. (Author,
Click On2018)
Fail

According to above case, the author has prepared this function to show all the Reference
Numbers in the drop down list when click on the Combo Box. But, when testing the system it

Table 6 - Load All Reference No to the Drop down List


(Author, 2018)

Figure 81 - Reserve Book


(Author, 2018)

Figure 82 - Load Reference No in the Combo Box


(Author, 2018)
HND in Computing & Systems Development

has not worked properly as in the above. The author has prepared this issue by making
changes to the source code. Finally, this function is worked properly as in the below figure.
The author would be able to identify this problem due to the testing the system. The author
could be able to understand the importance of the system testing due to this problem.

Test Case for Reservation


Test Case: 05

Test Case Name: Reservation

Tested By: Malindu Darshana

Input Status
Test Case Expected Results Actual Results
Data (Pass/Fail)

Login with Invalid Display Message Display Message


Credentials “Book Reserved” “Book
1003 Reserved”
1. Reference No
Pass
2. Member ID 30
HND in Computing & Systems Development

Test Case for Search


Test Case: 05

Test Case Name: Search

Tested By: Malindu Darshana

Input Status
Test Case Expected Results Actual Results
Data (Pass/Fail)

Search Display Question Display Question


Message “Do You Message “Do You
Table1.7 -Reference
Test Case for Reservation
1002
Want to Inform to the Want to Inform to
No
(Author, 2018)
Member 20?” and the Member 20?” Pass
proceed the messages and proceed the
messages

Figure 84 - Search Function


(Author, 2018)

Table 8 - Test Case for Search


(Author, 2018)

Figure 85 - Search Function


(Author, 2018)
HND in Computing & Systems Development

Figure 86 - Search Function


(Author, 2018)
HND in Computing & Systems Development

Figure 87 - Search Function


(Author, 2018)

Figure 88 - Search Function


(Author, 2018)
HND in Computing & Systems Development

Test Case for Exit


Test Case: 08

Test Case Name: Exit

Tested By: Dilshan Gamage

Status
Test Case Input Data Expected Results Actual Results
(Pass/Fail)

Exit. View exit from the View exit from the


system system
Press Exit

Pass

Conclusion

The author has tested interfaces in this system properly. In here, the author can be able to
identify how to make a test case for the testing a system. It can be able to identify if there is
any error in the system. By testing the system, it can give proper output to the user. It means,
user can get quality system to perform their tasks easily. When testing these things, the author
can get practical knowledge and the clear idea about how to testing a system and what are the
errors can occur during development of this system.

Table 9 - Test Case for Exit In most of test cases, both expected result and the actual result
are matched successfully. It means it can conclude that there is
(Author, 2018)
no considerable error in the system. But, in some cases one of
the test case found with Fail. Then, the author has fixed it by changing the source code and
making interfaces suitably.
Furthermore, the author has got better experience about the system testing. However, in the
above most of test cases, both expected result and the actual result are matched successfully.
Some issues are solved properly. Finally, it can conclude that there are no considerable errors
in the functions that have tested in the above.
HND in Computing & Systems Development

Task 3

3.1 Implement Linear/Binary search using recursive algorithm and non-recursive


algorithm, and compare the performance. (LO 1.3)
Algorithm
A step-by-step procedure or method for solving a problem by a computer in a finite number
of steps can be defined as an Algorithm. (Cs-fundamentals, 2018) Steps of algorithms are
written in human understandable language. And those steps are independent from any
programming language. It can implement an algorithm in any programming language of our
selection. An algorithm should include some features such as,
1. Input – Algorithm have zero or more inputs
2. Output – Algorithm have one or more outputs and should obtain desired output
3. Finiteness – Algorithm must terminate after a finite number of steps
4. Feasibility – Algorithm should be feasible with the available resources
5. Independent – Algorithm should have step-by-step directions that should be
independent of any programming code
(Tutorialspoint, 2018)
Search Algorithms
Searching is a way of identifying or finding a specific record. Searching is very easy and
efficient, if the data is made in sorted order properly. Actually, the searching is a technique
HND in Computing & Systems Development

that used to find the real place of a given element or value in the list. There are some
searching techniques are used in the data structure. These standard techniques are,
1. Linear Search
2. Binary Search
Linear Search
The basic search algorithm used in data structure is Linear Search. It’s also known as
Sequential Search. This linear search is used to find a specific element in an array. It is not
need to arrange the array in ascending or descending order compulsory. (Codeburst, 2018)
Linear Search is mostly used for short lists since this algorithm is simple and need minimum
code to implement.
In a list, the best case is when the value is equal to the first element of the list, in which case
only one comparison is needed. The poorest case is when the value is not in the list or occurs
only once at the end of the list, in which number of elements in the list comparisons are
needed.

As an example, it can consider following list of element. In here the Search element is 33.

Figure 89 - Linear Search


(Tutorialspoint, 2018)

Figure 90 - Linear Search


(Tutorialspoint, 2018)
Then, it compared search element 33 is compared with first element 10.

Both elements are not matching. Therefore, check the next element. Likewise, move near to
the elements and check those elements are matched with the search element.

Figure 91 - Linear Search


(Tutorialspoint, 2018)
HND in Computing & Systems Development

Finally, search element 33 is matched with an element 33 in the list. Therefore, stop
comparing and display element as the output.

The Pseudo Code of the Linear Search is shown in the below.


Procedure linearsearch (list, value)
For each element in the list
If match element == value
Return the element’s location
End if
End for
End procedure

Binary Search
Very efficient and the fast searching techniques is the Binary Search. It compulsory need the
list to be in sorted order in the Binary Search. (W3schools, 2018) It can compare the element
with the present element at the center of the list when searching an element. The search is
success, if the element is matches. Otherwise, the element list is divided in to two parts. One
part is zero to the middle element. Other part from middle element to the last element. This
binary search is continues from either of the two parts depending upon whether the required
element is smaller or greater than the central than the middle element. Searching is done in
the first part, if the element is smaller than the middle element. Otherwise, searching is done
in the second part.
As an example, it can consider following array. The array should be sorted in the binary
search. In here, Search element is 23.

2 5 8 12 16 23 38 56 72 91

Then, it has to find the mid value first. According to this example, the mid value is the 16. If
the value of the search element is less than mid value, it narrow the lower half of the array.
HND in Computing & Systems Development

Otherwise, it narrow the upper half of the array. This process is happened repeatedly until the
value is found as in the below figure.

23 is higher than 16. Therefore, this narrows upper half of the array.
Lower Upper

2 5 8 12 16 23 38 56 72 91
0 1 2 3 4 5 6 7 8 9
23 is lesser than 56. Therefore, this narrows lower half.
Lower Upper
2 5 8 12 16 23 38 56 72 91
0 1 2 3 4 5 6 7 8 9

Finally, found the element 23. 23 is stored in the location 5.

Lower Upper

02 15 28 12
3 16
4 23
5 38
6 56
7 72
8 91
9

The Pseudo Code of the Binary Search is shown in the below.

Figure 93 - Pseudo Code for Binary Search


HND in Computing & Systems Development

There are two ways of implementation of Binary Search.


1. Recursive Binary Search
2. Non-Recursive Binary Search

Recursive Binary Search


The author has implemented Binary Search using recursive and non-recursive algorithms. In
the below, it has shown the implementation of Binary Search using Recursive Algorithms.
HND in Computing & Systems Development

Figure 94 - Binary Search using Recursive Algorithms


(Author, 2018)
HND in Computing & Systems Development

Non-Recursive Binary Search


Below shows the implementation of Binary Search using Non-Recursive Algorithms.

Figure 95 - Binary Search using Recursive Algorithms


(Author, 2018)
HND in Computing & Systems Development

Compare the Performance of Recursive and Non-Recursive Algorithms

Normally, recursive means that a function calls itself. This may not be planned. Planned
recursion, where a function performs part of an operation, then calls itself to perform the
remaining part, is often a useful programming paradigm. Mainly, recursion can be used to
replace "repetition" (loops) and to replace associated array allocations (with variables local to
the function body). But not each iterative or array-using function can be effectively converted
to its recursive equivalent.

It can often write a recursive version that is about equivalent in execution efficiency to the
non-recursive version, maybe slightly better or worse depending on how efficient the call
mechanism is compared to looping and array indexing in the language/compiler, if the
problem is suitable for recursion In terms of storage, recursion is rarely more efficient, but it
benefits from not having to pre-allocate (and pre-know the size of the allocation) for the
particular problem at hand.

Mostly recursion is better than non-recursive (when it actually is) because it makes an
implementation much simpler and less error-prone, and errors are by far the biggest cost in
computing. (And of course improperly done it can cost you big time as well.)

By considering above few facts, it can conclude that the recursive algorithm is better than
non-recursive algorithm.
HND in Computing & Systems Development

3.2. Sort the array given below with two different algorithms and compare the
performance. {12, 35, 30, 85, 69, 102, 99} (LO 1.2)

Sorting Algorithms
Sorting
Sorting is an arrangement of data in a particular format. Sorting algorithms state the way of
arranging in a particular order. Order can be taken as ascending or descending order. Sorting
is very useful to show data in a more readable formats. (Tutorialspoint, 2018)
In the real life, it need to search for many things such as records in database, telephone
numbers in telephone directory, particular pages in a book and more. These things get
difficult, if the data was kept unsorted or unordered way. Sorting concept came into existence
fortunately. It makes easy to arrange data in an order. Therefore, it makes easy to search data.
Data is arrange in an order in sorting that makes easier to search. There are different
algorithms to sort data.
Different Sorting Algorithms
Different techniques can be seen for sorting. These techniques are different from their
efficiency and space requirements. Some of the sorting techniques are,
1. Insertion Sort
2. Bubble Sort
3. Selection Sort
4. Quick Sort
Insertion Sort
This is a simple sorting algorithm. It makes the final sorted array one element at a time.
Insertion sort is less efficient on large lists than other sort algorithms. (Java2novice, 2018)
Insertion sort is efficient for smaller data sets. It can follow following steps in insertion sort.
 First element is already sorted. It returns 1.
 It can start by making the second element of the given array, element at index 1, the
key.
 Compare the key element with the element before it, in this case, element at index 0.
Insert the key element before the first element, if the key element is less than the first
element. And insert it after the first element, if the key element is greater than the first
element.
 Then, it takes third element of the array as key and it will compare with elements and
insert it at the correct position.
HND in Computing & Systems Development

 Repeat this process until the full array is sorted.


It represents a process of insertion sort in the below figure.

Figure 96 - Process of Insertion Sort


(Studytonight, 2018)
HND in Computing & Systems Development

Bubble Sort
Bubble sort is also a simple algorithm that compares the first element of the array to the next
one. The elements are swapped, if the current element of the array is numerically greater than
the next one. This process will happen repeatedly through the entire elements of the array.
(Guru99, 2018)
If any array need to be sorted in ascending order, bubble sort will start by comparing the first
element of the array with the second element. Both elements are swap, if the first element is
greater than the second element. Then take second and third elements and compare. Proceed
this process until the array is sorted.
Overall, the sorting is happened by stepping through all the elements one-by-one and
compare it with the nearby element and swapping them if necessary.
When considering the below array, it can sort by using bubble sort.

40 20 60 10 50 30

Above array can be sort using bubble sort as in the below steps.
In the bubble sort, compare nearby elements and swap them if they are out of order. In each
situation, largest element will be moved as its suitable place.
In the above array, firstly 20 and 40 compared. Check 40>20. Condition is true. Therefore, 40
and 20 will be swapped. Then, 40 and 60 will be compared, check 40>60. Condition is false.
Therefore, not need to swap and go ahead.

Then, 60 and 10 will be compared, check 60>10. Condition is true. Therefore, 60 and 10 will
be swapped.
HND in Computing & Systems Development

Then, 60 and 30 will be compared, check 60>30. Condition is true. Therefore, 60 and 30 will
be swapped and largest element 60 bubbled up at its suitable place.

Repeat the steps for remaining unsorted sub array and every situation through the array places
the next largest value in its suitable place.

(Javabypatel, 2018)
HND in Computing & Systems Development

Selection Sort
In the Selection sort, it sorts an array by repeatedly finding the smallest element (considering
ascending order) from unsorted part and placing it at the beginning. (Geeksforgeeks, 2018) In
this sorting technique, the algorithm contains two sub arrays in a given array.
1. Already sorted sub array
2. Unsorted remaining sub array
In the selection sort, the smallest element (considering ascending order) from the unsorted
sub array is picked and moved to the sorted sub array.
It can understand the selection sort by using below example.
It can consider below array.
arr [] = 63 24 13 23 10

First, find the smallest element in arr [0...4] and place it at beginning
10 24 13 23 63

And, find smallest element in arr [1…4] and place it at beginning of arr [1…4]
10 13 24 23 63

Find smallest element in arr [2…4] and place it at beginning of arr [2…4]
10 13 23 24 63

Find smallest element in arr [3…4] and place it at beginning of arr [3…4]
10 13 23 24 63

Finally, it can see that the array is already sorted.


10 13 23 24 63

Below figure also shows how it works in the selection sort.


HND in Computing & Systems Development

Figure 97 – Representation of Selection Sort


(W3School, 2018)
HND in Computing & Systems Development

It can consider about a program that is written to sort an array using selection sort.

Figure 98 - Selection Sort


(Java2novice, 2018)
Output: 2, 7, 10, 34, 42, 56, 67, 88
HND in Computing & Systems Development

Quick Sort
Quick sort is widely used sorting algorithm technique. It is based on Divide and Conquer
concept. In this sort, every heavy work is done while dividing the array into sub arrays. This
sort is known Partion-exchange sort also. (Studytonight, 2018)
Some steps have to follow in the quick sort.
 An element is selected from a given array. This selected element is named as “Pivot
Element”. As an example, select the middle element of the array.
 Then, place all the elements which are smaller than the pivot element in one array and
larger all elements placed in another array.
 Then, apply quick sort to them and sort both arrays.
 Finally, combine sorted arrays.
Using below figure, it can get clear idea about the quick sort.

Figure 99 - Represent of Quick Sort


(Tekmarathon, 2018)

Pseudo code for the quick sort is given below.


HND in Computing & Systems Development

Figure 100 - Pseudo Code for Quick Sort


(Geeksforgeeks, 2018)

The author has sort this array {12, 25, 30, 85, 69, 102, 99} using Insertion Sort and Bubble
Sort.

Implementation of Insertion Sort Algorithm to Sort the Array {12, 25, 30, 85, 69, 102,
99}
HND in Computing & Systems Development

The author has sort the above array using insertion sort algorithm. It has shown the algorithm
that is used to sort above array in the below.

Figure 101 - Implementation of Insertion Sort Algorithm


(Author, 2018)

Implementation of Bubble Sort Algorithm to Sort the Array {12, 25, 30, 85, 69, 102, 99}
HND in Computing & Systems Development

The author has sort above array using bubble sort algorithm also. In the below shows the
algorithm.

Figure 102 - Implementation of Bubble Sort Algorithm


(Author, 2018)
HND in Computing & Systems Development

Compare the Performance of Insertion Sort and Bubble Sort Algorithms


Performance of any algorithm depends on the number of comparison and number of times
taken to swap of list elements. Performance differ from algorithm to algorithm. The best case
for insertion sort occurs when the list is already sorted. In here, insertion sort has a linear
running time (O (N)). During every repetition, the first remaining node of the input is only
compared with the right most element of the sorted part of the array. The worst case for
insertion sort occurs an array sorted in reverse order. The collection of all worst case inputs
contains of all arrays where every element is the lowest or second lowest of the elements
before it. In this case, insertion sort has a quadratic running time (O (N 2)). The
average case is also has a quadratic. Insertion sort is a fast algorithms for sorting very small
arrays. Insertion sort is mostly similar to the Bubble sort. The performance between the
Bubble sort and the Insertion sort is depend on how many times element is swapped and the
no of comparisons. In here, bubbles sort performs more swaps in every pass, it will complete
the sorting the list quickly than insertion sort. Bubble sort will always compare two
sequential elements in the list. And if the element are out of order, they will swap. If we
starting at the beginning of the list, that at every pass through the algorithm, the biggest
remaining element in the list will be placed at its suitable place in the list.
When the list is already sorted, the best case for bubble sort occurs. In here, bubble sort
makes one pass over the list, performing no swaps and N-1 comparisons. When the list is in
reverse order, the worst case for bubble sort occurs. In here, each element will have to be
swapped with every other item on every pass over the algorithm. There will be O (N2)
comparisons in the bubble sort. There are O (N2) swaps in bubble sort. The average case of
the bubble sort looks like the worst case, O (N2) comparisons and O (N2) swaps. The trade-
off is that it may be able to do half as many repetitions, on average. However, it can conclude
that the bubble sort performs better than insertion sort in terms of the number of comparisons,
when considering above facts.
HND in Computing & Systems Development

3.3. Explain common string operations such as concatenation, substring, etc., also state
their practical applications by giving suitable examples. (LO 3.1) (M1.3)
String
String is an object that represents a series of characters. (Eureka, 2018) Mainly, String is an
array of characters. There some syntax example of String shown in the below.
 Syntax that represented as String is an array of characters.

Figure 103 - Syntax of String is an Array Characters


(Guru99, 2018)

 Syntax that represented as String is not an array


String str = “JAVA”;

String Operations
String operations allow to perform different manipulations on a String. It can identify various
String Operations. Some of them are,
1. Concatenation
2. Length
3. Substring
4. Trim
5. CompareTo
Concatenation
Simply, concatenation is combining of two or more Strings together. Joins a string to the end
of another string. Finally, returns a combined string. (Edureka, 2018) Concatenate string act
as a new another string. It can concat string in two ways such as by + operator and by concat
() method.
HND in Computing & Systems Development

Examples of Concatenation
By using + operator, it can add strings. It means concat strings. Concatenation operator (+)
can concat both string and primitive values. As an example,
Example 01:

Figure 104 - Example for String Concatenation


(BlogSpot, 2018)

Output: Virat Kohli

By using concat () method, it can concat strings. In this method, concat the specified string to
the end of existing string.
HND in Computing & Systems Development

Example 02:

Figure 105 - Example of String Concatenation


(Janbasktraining, 2018)

Output: welcomeback

Example 03:

Below shows another example of concatenation of string using concat () method.

Figure 106 - Example of String Concatenation


(BeginnersBook, 2018)
HND in Computing & Systems Development

Output: Welcome to String Handling


This is just a String

When comparing with Example 02, it can clearly see the concatenating multiple strings can
be done in one line also as in the Example 03. It reduces the number of lines of the program.
It is easily write using few lines.
Example 04:
Below example is used to concat spaces and special symbols. It means, it makes the space
among strings when concatenating the strings.

Figure 107 - Example of String Concatenation


(Javatpoint, 2018)
Output: Hello Javatpoint Reader
Hello!!!
Hello@Javatpoint

It can use this string operations practically. The author has create some simple applications to
show how these operations are performed.
HND in Computing & Systems Development

Below shows an application that is created to show the Concatenation and Length string
operations. In here, according to this application when entering two different string values
and pressing the Concatenation button, the result string is shown in the message box as in the
below figure by concatenating these two entering values.

Figure 108 - Interface of Concatenation


(Author, 2018)

The source code for the above application is shown in the below.

Figure 109 - Code of Concatenation


(Author, 2018)

Length
To returns a length of a String, it can use String length () method. Length of any string is
equal to the number of 16-bit Unicode characters in the String.
HND in Computing & Systems Development

Examples of Length
Example 01:

Figure 110 - Example of String Length


(Tutorialspoint, 2018)
Output: String Length: 29
String Length: 9

According to above example, Str1, Str2 are String objects that declare in the program. Length
() method is returns a length of Str1 and Str2. Therefore, 29 is the length of String “Welcome
to Tutorialspoint.com” and 9 is the length of String “Tutorials”.

Example 02:
When comparing this example with the example 01, this is different. In here, it consider
about the condition also. String variable is declared and assign it to a value. Then, check
string is empty or not. It means, the length is greater than 0. If it is, print the length.
Otherwise, check the value is equal to 0. If it is, print output as 0. It means, the length is 0.
HND in Computing & Systems Development

Figure 111 - Example of String Length


(Javatpoint, 2018)
Output: String is not empty and length is: 10
String is empty now: 0

This operation is also can be used as a practically as in the below application. Same as the
concatenation, in here by entering string value and pressing the button, it can obtain the
length of the string as the result in the message dialog box.
HND in Computing & Systems Development

Figure 112 - Interface for String Length


(Author, 2018)

The source code is shown in the below related to this application.

Figure 113 - Code of String Length


(Author, 2018)

Substring
This is used to get a substring of a particular String. (BeginnersBook, 2018) Substring ()
method has two forms.
1. String substring (int beginIndex)
HND in Computing & Systems Development

2. String substring (int beginIndex, int endIndex)


String substring (int beginIndex)
In here, returns the substring beginning from the definite index (beginIndex) until the
completion of the string. As an example,
String str = "Beginners";
System.out.println (str.substring (2));
Output: eginners
String substring (int beginIndex, int endIndex)
It returns the substring beginning from the given index (beginIndex) until the specified index
(endIndex). As an example,
String str = “Beginners ";
System.out.println (str.substring (2, 6));
Output: engin
Examples of Substring
Example 01:

In

Figure 114 - Example of Substring


(Geeksforgeeks, 2018)
the above example, declare Str string object and then get substring using substring () method.
Returns the output as follows.
Output: geeksforgeeks
HND in Computing & Systems Development

Example 02:

Figure 115 - Example of Substring


(Jquery-az, 2018)
Output: geeksforgeeks

The author has created an application to show the practical situation of using substring
operation as in the below. It has already mentioned what is substring operation about. Using
below it can understand, how this operation used practically. By entering string value and
begin index as the value field, the result can be taken by pressing Result button.
HND in Computing & Systems Development

The implementing code can be shown as follows for this application.

Figure 117 - Code of Substring


(Author, 2018)

Trim
This is used to take a string which value is this string, with any leading and irregular
whitespace removed. If a string object denotes an empty character order or the first and last
characters of character arrangement denoted by this string object both have codes greater than
'\u0020' (the space character), then a mention to this string object is returned.
Then, a string object denoting an empty string is returned, if there are no characters with a
code greater than '\u0020' in the string. (W3resource, 2018)
HND in Computing & Systems Development

It can understand about the trim using below figure.

Figure 118 - Represent of Trim


(Geeksforgeeks, 2018,)

In simply, in the trim it checks the Unicode value of space character (‘\u0020’) before and
after the string. If the value exists, then removes the spaces and return the omitted string.

Examples of Trim
Example 01:

In here, it removes the spaces and return and print the omitted string as in the below figure.

Figure 119 - Example of Trim


(Edureka, 2018)
HND in Computing & Systems Development

Output: hello how are you


hellohowareyou

Example 02:

Below example is somewhat different than above one. In here, removes all the trailing spaces
as well as the length of string also reduces.

Figure 120 - Example of Trim


(Javatpoint, 2018)

Output: 22
hello java string
17
hello java string
Below application shows how it perform in the trim sting operation in practically. By
entering string value and press Result button, it can get the result of the string. The author has
explained about the trim string operation earlier. Therefore, it can understand what happened
in this application.
HND in Computing & Systems Development

Figure 121 - Interface of Trim


(Author, 2018)

The source code is shown in the below.

Figure 122 - Code of Trim


(Author, 2018)

CompareTo
According to this operation, it compares current string with a given string. Then returns a
positive number, negative number or 0. This compares strings on the beginning of Unicode
value of every character in the strings. (Javatpoint, 2018)
HND in Computing & Systems Development

In here, it returns positive number (difference of character value), if the first string is greater
than second string. And also, it returns negative number, if first string is less than second
string. First string is equal to second string, it returns 0.
Examples of CompareTo
Example 01:

According to below example, it has considered about three strings and comparing them each
other by using CompareTo () method.

Figure 123 - Example of CompareTo


(Beginnersbook, 2018)

Output: str1 & str2 comparison: -16


str1 & str3 comparison: 0
str2 & string argument comparison: 0

Example 02:
HND in Computing & Systems Development

This example is different from above example. It means, it has considered about empty string
also when comparing. If anyone compares string with empty string, it returns a length of the
string. The result will be positive, if the second string is empty. And also, the result will be
negative, if the first string is empty.

Figure 124 - Example of CompareTo


(Javatpoint, 2018)
Output: 5
-2

CONCLUSION
This study is based on Data Structures and Algorithms. In this case, the author has
implemented a palindrome application. In the earlier, the author does not has a clear idea
HND in Computing & Systems Development

about a palindrome application. But, when developing this application the author could be
able to get clear knowledge about the palindrome application. The author has used both in
build class in the java and create stack class with stack operations. Therefore, it could be able
to get well experience of using stack operations. The author has given attention for the error
handling also when developing this application. It has handled the null pointer exception in
this application. In here, author has study about types of exceptions and methods of handling
exceptions. Practically, the author has used try catch block to handle exceptions. Not only
that, the author has prepared user manual for this application. It helps to the user to
understand how to use this application.
According to this study, the author has to implement a Library System using queue and
linked list data structures. Mainly, this system provides a book reservation facility for
members. In this case, queue operations and linked list operations are used. Queue and linked
list operations are used to create functions and classes of this system. The author could be
able to get clear knowledge about queue and linked list data structures. After implementing
the system, the author has tested this system separately. By using the testing, the author can
understand what are the errors can occur in the system and how to fix them. It has get good
practical experience about the system that was made from data structures. The author has
realized that the testing is important and essential thing when implementing a system. When
testing the system, the author has get some fail test cases also. It was a mistake of the author.
As an example, in this system, it has not loading the data when clicking. It was an issue
identified by the testing. The author has prepared this issue by making changes to the source
code. Then, this function works properly.
In here, the author has implement a binary search using recursive and non-recursive
algorithms. The author has made a study about searching algorithms. It means linear search
algorithms and binary search algorithms. And the author has compare performance of these
algorithms. Not only that, the author has get clear knowledge about sorting algorithms also
using this study. It has study different soring algorithms such as insertion sort, bubble sort,
selection sort and quick sort and compare performance of some of those algorithms.

Finally, in this study, the author could be able to study about common string operations such
as concatenation, length, substring, trim, compareto. The author shows examples for these
operations by making practical applications. The author has suggest some improvements to
these application such as palindrome application and library system. It can suggest to
improve the palindrome application as to get the longest palindrome string among set of
HND in Computing & Systems Development

palindrome strings. It means, by entering set of palindrome strings, it will able to show what
the longest palindrome word as the output. Not only that, it can suggest to improve this
application as to see whether the numbers are palindrome or not. In here, it does not checks
strings. It has only check the palindrome numbers. For the library system, it can suggest to
improve other function as View member. It means, it can see all the members who making
reservation in table. It can get members enters to the queue when reserving a book. By
improving the above improvements, the author can improve this system much more effective
and high performance in the future.

REFERENCES

Algolist.net (2018) singly linked list [online]. Available at:


http://www.algolist.net/Data_structures/Singly-linked_list [Accessed on 14th of November
2018]
HND in Computing & Systems Development

Beginnersbook.com (2018) java string compareto method example [online]. Available at:
https://beginnersbook.com/2013/12/java-string-compareto-method-example/ [Accessed on
04th of December 2018]
Beginnersbook.com (2018) java string concat method example [online]. Available at:
https://beginnersbook.com/2013/12/java-string-concat-method-example/ [Accessed on 04th of
December 2018
Beginnersbook.com (2018) java string substring method example [online]. Available at:
https://beginnersbook.com/2013/12/java-string-substring-method-example/ [Accessed on 04th
of December 2018]
Beginnersbook.com (2018) java throws [online]. Available at:
https://beginnersbook.com/2013/04/java-throws/ [Accessed on 09th of November 2018]
Codeburst.io (2018) searching and sorting algorithms [online]. Available at:
https://codeburst.io/algorithms-i-searching-and-sorting-algorithms-56497dbaef20 [Accessed
on 28th of November 2018]
Cs.cmu.edu (2018) linked list [online]. Available at: https://www.cs.cmu.edu/~adamchik/15-
121/lectures/Linked%20Lists/linked%20lists.html [Accessed on 15th of November 2018]
Cs-fundamentals.com (2018) what is an algorithm [online]. Available at: http://cs-
fundamentals.com/tech-interview/dsa/what-is-an-algorithm.php [Accessed on 28th of
November 2018]
Dccc.edu (2018) exception handling [online]. Available at:
https://www.dccc.edu/sites/default/files/faculty/william_manley/exception-handling.pdf
[Accessed on 09th of November 2018]
Developerinsider.co (2018) introduction to data structures and algorithms [online].
Available at: https://developerinsider.co/introduction-to-data-structures-and-algorithms/
[Accessed on 04th of November 2018]
Edureka.co (2018) java string [online]. Available at: https://www.edureka.co/blog/java-
string/ [Accessed on 04th of December 2018]
Edureka.co (2018) java string [online]. Available at: https://www.edureka.co/blog/java-
string/ [Accessed on 04th of December 2018]
Edureka.co (2018) java strings [online]. Available at: https://www.edureka.co/blog/java-
string/ [Accessed on 04th of December 2018]
Geeksforgeeks.org (2018) linked list [online]. Available at:
https://www.geeksforgeeks.org/data-structures/linked-list/ [Accessed on 14th of November
2018]
HND in Computing & Systems Development

Geeksforgeeks.org (2018) quick sort [online]. Available at:


https://www.geeksforgeeks.org/quick-sort/ [Accessed on 03rd of December 2018]
Geeksforgeeks.org (2018) selection sort [online]. Available at:
https://www.geeksforgeeks.org/selection-sort/ [Accessed on 01st of December 2018]
Geeksforgeeks.org (2018) substring in java [online]. Available at:
https://www.geeksforgeeks.org/substring-in-java/ [Accessed on 04th of December 2018]
Geeksforgeeks.org (2018) types of exceptions in java with examples [online]. Available at:
https://www.geeksforgeeks.org/types-of-exception-in-java-with-examples/ [Accessed on 09th
of November 2018]
Guru99.com (2018) bubble sort java [online]. Available at: https://www.guru99.com/bubble-
sort-java.html [Accessed on 01st of December 2018]
Guru99.com (2018) java strings [online]. Available at: https://www.guru99.com/java-
strings.html [Accessed on 04th of December 2018]
Guru99.com (2018) system testing [online]. Available at: https://www.guru99.com/system-
testing.html [Accessed on 24th of November 2018]
Hackerearth.com (2018) basics of queues [online]. Available at:
https://www.hackerearth.com/practice/data-structures/queues/basics-of-queues/tutorial/
[Accessed on 14th of November 2018]

Janbasktraining.com (2018) java-string-functions-methods-examples [online]. Available at:


https://www.janbasktraining.com/blog/java-string-functions-methods-examples/ [04th of
December 2018]

Java2novice.com (2018) doubly linked list [online]. Available at:


http://www.java2novice.com/data-structures-in-java/linked-list/doubly-linked-list/ [Accessed
on 16th of November 2018]
Java2novice.com (2018) insertion sort [online]. Available at:
http://www.java2novice.com/java-sorting-algorithms/insertion-sort/ [Accessed on 30th of
November 2018]
Java2novice.com (2018) selection sort [online]. Available at:
http://www.java2novice.com/java-sorting-algorithms/selection-sort/ [Accessed on 02nd of
December 2018]
Javatpoint.com (2018) doubly linked list [online]. Available at:
https://www.javatpoint.com/doubly-linked-list [Accessed on 16th of November 2018]
HND in Computing & Systems Development

Javatpoint.com (2018) java string compareto [online]. Available at:


https://www.javatpoint.com/java-string-compareto [Accessed on 04th of December 2018]
Javatpoint.com (2018) java string compareto [online]. Available at:
https://www.javatpoint.com/java-string-compareto [Accessed on 04th of December 2018]
Javatpoint.com (2018) java string concat [online]. Available at:
https://www.javatpoint.com/java-string-concat [Accessed on 04th of December 2018]
Javatpoint.com (2018) java string trim [online]. Available at:
https://www.javatpoint.com/java-string-trim [Accessed on 04th of December 2018]
Javatpoint.com (2018) string concatenation in java [online]. Available at:
https://www.javatpoint.com/string-concatenation-in-java [Accessed on 04th of December
2018]
Jquery-az.com (2018) java substring 3 examples to explain strings substring function
[online]. Available at: https://www.jquery-az.com/java-substring-3-examples-to-explain-
strings-substring-function/ [Accessed on 04th of December 2018]
Programiz.com (2018) linked list types [online]. Available at:
https://www.programiz.com/dsa/linked-list-types [Accessed on 16th of November 2018]
Sqa.org (2018) linked list [online]. Available at: https://www.sqa.org.uk/e-
learning/LinkedDS02CD/page_46.htm [Accessed on 15th of November 2018]
Study.com (2018) exceptions in java definition example [online]. Available at:
https://study.com/academy/lesson/exceptions-in-java-definition-example.html [Accessed on
09th of November 2018]
Studytonight.com (2018) insertion sorting [online]. Available at:
https://www.studytonight.com/data-structures/insertion-sorting [Accessed on 30th of
November 2018]
Studytonight.com (2018) introduction to data structure [online]. Available at:
https://www.studytonight.com/data-structures/introduction-to-data-structures [Accessed on
04th of November 2018]
Studytonight.com (2018) queue data structure [online]. Available at:
https://www.studytonight.com/data-structures/queue-data-structure [Accessed on 13th of
November 2018]
Studytonight.com (2018) quick sort [online]. Available at:
https://www.studytonight.com/data-structures/quick-sort [Accessed on 03rd of December
2018]
HND in Computing & Systems Development

Studytonight.com (2018) stack data structure [online]. Available at:


https://www.studytonight.com/data-structures/stack-data-structure [Accessed on 07th of
November 2018]
Techtarget.com (2018) error handling [online]. Available at:
https://searchsoftwarequality.techtarget.com/definition/erro r-handling [Accessed on 09th of
November 2018]
Tekmarathon.com (2018) understanding quick sort algorithm [online]. Available at:
https://tekmarathon.com/2013/09/17/understanding-quicksort-algorithm/ [Accessed on 03rd of
December 2018]
Tutorialride.com (2018) linked list in data structure [online]. Available at:
https://www.tutorialride.com/data-structures/linked-list-in-data-structure.htm [Accessed on
15th of November 2018]
Tutorialspoint.com (2018) algorithms basics [online]. Available at:
https://www.tutorialspoint.com/data_structures_algorithms/algorithms_basics.htm [Accessed
on 28th of November 2018]
Tutorialspoint.com (2018) doubly linked list algorithm [online]. Available at:
https://www.tutorialspoint.com/data_structures_algorithms/doubly_linked_list_algorithm.htm
[Accessed on 15th of November 2018]
Tutorialspoint.com (2018) dsa queue [online]. Available at:
https://www.tutorialspoint.com/data_structures_algorithms/dsa_queue.htm [Accessed on 13th
of November 2018]
Tutorialspoint.com (2018) java exceptions [online]. Available at:
https://www.tutorialspoint.com/java/java_exceptions.htm [Accessed on 09th of November
2018]
Tutorialspoint.com (2018) java string length [online]. Available at:
https://www.tutorialspoint.com/java/java_string_length.htm [Accessed on 04th of December
2018]
Tutorialspoint.com (2018) linear search algorithms [online]. Available at:
https://www.tutorialspoint.com/data_structures_algorithms/linear_search_algorithm.htm
[Accessed on 29th of November 2018]
Tutorialspoint.com (2018) link list algorithm [online]. Available at:
https://www.tutorialspoint.com/data_structures_algorithms/linked_list_algorithms.htm
[Accessed on 14th of November 2018]
HND in Computing & Systems Development

Tutorialspoint.com (2018) software testing method [online]. Available at:


https://www.tutorialspoint.com/software_testing/software_testing_methods.htm [Accessed on
23th of November 2018]
Tutorialspoint.com (2018) sorting algorithms [online]. Available at:
https://www.tutorialspoint.com/data_structures_algorithms/sorting_algorithms.htm [Accessed
on 30th of November 2018]
Tutorialspoint.com (2018) stack algorithm [online]. Available at:
https://www.tutorialspoint.com/data_structures_algorithms/stack_algorithm.htm [Accessed
on 08th of November 2018]
Tutorialspoint.com (2018) stack algorithm [online]. Available at:
https://www.tutorialspoint.com/data_structures_algorithms/stack_algorithm.htm [Accessed
on 08th of November 2018]
W3resource.com (2018) string trim [online]. Available at: https://www.w3resource.com/java-
tutorial/string/string_trim.php [Accessed on 04th of December 2018]
W3schools.in (2018) searching techniques [online]. Available at:
https://www.w3schools.in/data-structures-tutorial/searching-techniques/ [Accessed on 29th of
November 2018]
W3schools.in (2018) selection sort algorithm [online]. Available at:
https://www.w3schools.in/data-structures-tutorial/sorting-techniques/selection-sort-
algorithm/ [Accessed on 02nd of December 2018]

APPENDIX
HND in Computing & Systems Development

Figure 125 - Gantt chart


(Author, 2018)

Practical Observation Sheet

Module: Data Structures and Algorithms


HND in Computing & Systems Development
Unit No: 34

Student Name: ____H.M.Inoka Sandamali_____________________________


Activity Activity Learning Date Signature
No Outcome
(LO)
1 Provide evidence of LO 2.1 26/12/201 tharukawijetunga@gmail.com
coding, and explain LO 3.2 8
a piece of coding to
the audience.
2 Run the solution LO 2.1 26/12/201 tharukawijetunga@gmail.co
LO 3.2 8 m
3 Test the solution LO 2.3
with random data 26/12/201 tharukawijetunga@gmail.com
8
4 Prove the use of LO 2.2
Error Controlling 26/12/201 tharukawijetunga@gmail.com
Mechanism in the 8
solution and Error
reporting structure
5 Compare the D2
performance of 26/12/201 tharukawijetunga@gmail.com
different algorithms 8

Assessor Name : Tharuka Wijetunga

Date : 26/12/2018

Signature : tharukawijetunga@gmail.com

Comments:

Learner has successfully demonstrated the developed applications.


HND in Computing & Systems Development

Assessment Criteria (Students are not authorized to modify or write anything on below)
Possible
Outcomes/Criteria for PASS Page Feedback
evidence
LO1 Understand data structures and algorithms
1.1 produce design specification for data structures Task 1.1, Task 2-5 Learner has produced design specification for data structures
explaining the valid operations that can be carried out 2.1 37-69 explaining the valid operations that can be carried out
on the structures on the structures

1.2 explain the operation and performance of sorting and Task 3.1, Task 88-96 Learner has implemented the binary search using recursive and non-recursive
search algorithms 3.2 97-108 algorithms and has compared the performance. Also learner has done a good
research on the topic. Learner has identified the situations where recursion is
used.

1.3 explain the operation of recursive algorithms and Task 3.2 97-108 Learner has implemented the binary search using recursive and non-recursive
identify situations when recursion is used algorithms and has compared the performance.

LO2 Be able to implement data structures and algorithms


2.1 implement data structures in an executable Task 1.2,Task 6-18 Learner has implemented the data structures in java programming language
programming language in the context of well-defined 2.1 37-69 for the defined problems.
problems
2.2 implement opportunities for error handling and Task 1.3 19-26 Learner has implemented opportunities for error handling and
Reporting Reporting

2.3 test results to enable comparison with expected results Task 1.4,Task 27-35 Learner has defined several test cases to compare the expected result and the
2.2 70-87 actual result.

LO3 Understand how strings are structured and processed.


3.1 explain common string operations and their practical Task 3.3 109-124 Learner has explained some common string operations and their practical
applications Task 1.1 2-5 applications.

3.2 demonstrate the outcome of string operations in Task 3.3 109-124


specified algorithms. Task 1.1 2-5 Learner has demonstrated the outcome of string operations.
HND in Computing & Systems Development

Grade Descriptor for MERIT Possible evidence Feedback


M1 Identify and apply strategies to find appropriate Task 3.2 Achieved
solutions Task 3.3 Learner has Compared different algorithms for

M1.3 an effective approach to study and research has been Compare different algorithms for searching and sorting
Applied searching and sorting Also learner has Searched about different string
Search about different string operations
operations

M2 Select / design appropriate methods / techniques Task 3 Achieved


Proper use of Harvard Referencing Learner has used Harvard Referencing correctly.
M2.3 a range of sources of information has been used
Search about different string Learner has Searched about different string
operations operations

M3 Present and communicate appropriate findings Task 1.5 Achieved


Documentation is well structured Document is well structured and adhere to
M3.1 the appropriate structure and approach has been used. adhering to the formatting formatting guidelines.
guidelines with non-overlapping
facts.
Data provided about the company
are accurate, reliable and
consistent
HND in Computing & Systems Development

Grade Descriptor for DISTINCTION Possible evidence Feedback


D1 Use critical reflection to evaluate own work and Report: shown in the self-reflection Achieved
justify valid conclusions section, good conclusion with
suggestions for further improvement Report contains self-criticism part and
D1.1 conclusions have been arrived at through synthesis of ideas and conclusions along with suggestions for future
have been justified improvements.

D2 Take responsibility for managing and organizing Achieved


activities Undertaken Activities from 01 – 05 Learner has managed activities well and depicted
as mentioned in the observation using a Gantt chart. And learner has submitted
D2.3 Activities have been managed sheet work on time

Submitted the work on time


D3 Demonstrate convergent / lateral / creative thinking Not Achieved
Learner is advised to apply critical thinking when
D3.4 problems have been solved. Task 1.1, Task 2.1, Task 3.1, Task solving problems.
3.2
HND in Computing & Systems Development
Strengths: Weaknesses:

Learner has done a sufficient research on different data structures and their
operations.

Future Improvements & Assessor Comment:

Appreciate the work done by learner.

Assessor: A.W. Tharuka Sandamini Signature: tharukawijetunga@gmail.com


Date: __03_/_01___/___2019___
12
Internal Verifier’s Comments:

The assignment has been marked and evaluated properly.

Internal Verifier: Tharika Amali Signature:tharika@esoft.lk Date: _10___/___1_/___2019___


HND in Computing & Systems Development

You might also like