You are on page 1of 19

INTERNATIONAL COLLEGE OF BUSINESS & TECHNOLOGY LTD

ASSIGNMENT BRIEF

Assignment Cover Sheet

Qualification Module Number and Title


HND in Computing and Software Engineering Data Structures and Algorithms SED52013

Student Name & No. Assessor


Priyanga Siriwardana
Hand out date Submission Date

Assessment type Duration/Length of Weighting of Assessment


Assessment Type
Coursework 3 weeks 100%

Learner declaration

I, ………………………………………….<name of the student and registration number>,


certify that the work submitted for this assignment is my own and research sources are fully
acknowledged.

Marks Awarded
First assessor

IV marks

Agreed grade

Signature of the assessor Date


FEEDBACK FORM
INTERNATIONAL COLLEGE OF BUSINESS & TECHNOLOGY
Module: Data Structures and Algorithms - SED52013
Student:
Assessor: Mr. Priyanga Siriwardana
Assignment:

Strong features of your work:

Areas for improvement:

Marks Awarded:

earning outcomes covered

LO 1 Understand Data Structures and storage in computer systems.

LO 2 Develop and implement Suitable Data Structures given requirement.

LO 3 Develop, implement and use searching and sorting techniques.


Assignment Brief

Task List

Task 1 Marks 30 (LO 1)

“POP” is a famous game among school boys. Player one will put the ball one by one and each ball will
locate on top of each other. Very first ball is located in the bottom of the tube and last ball is located in
the top.

Player 2 will fire the ball which is located in the top. Then the next ball become the top

 Identify and properly justify the most suitable data structure with their operations for above
requirement. (Explain and evaluate the advantages and disadvantages of suitable data structure.
And evaluate the suitability of selected algorithm with real-time examples)

Task 2 Marks 35 (LO 2 & LO 3)

Crate a Program for search value in the given int array. Student can select any search algorithm
for execute the program.
30 45 55 56 70 72 74 76 80 120

1. Create an appropriate Java class.


2. Create a method to Sort the above mention array
3. Create a method to search the given values in above mention array and method requires
array parameter with search key.
4. Create a method to print the values in array and method require array parameter

5. Create the main method to declare the given array. Call search and display methods.
Task 3 Marks 35 (LO 3)

To improve the performance of the system memory management recursion algorithms, play big
role.

1. What is recursion in data structure? Identify the advantages and disadvantages of


recursion algorithms.
2. Develop method for recursion algorithm to print factorial value numbers.

Note: You can make any valid assumptions and need to mention your assumptions clearly

Referencing Guidance

 To use Harvard referencing for citation and compile reference list you can go through
following guidance provided by Anglia Ruskin University.
 In the Harvard system, the author's surname and year of publication are cited in the text of your
work. The full details of the source are included in a reference list at the end of the
assignment. 
(Anglia Ruskin University,2013)

You can follow below link for more details

Guide to the Harvard Style of Referencing 2013. University Library. [pdf] Anglia Ruskin University.
Available at: <http://libweb.anglia.ac.uk/referencing/files/Harvard_referencing_2013.pdf> [Accessed
20 Octomber 2014].

Resources

Books
 An Introduction to Object-Oriented Programming with Java, 5th Edition(McGraw-
Hill)978-0-07352-330-9
 Data Structures and Algorithms in Java , 2nd Edition (Robert Lafore)
Websites
 http://www.javaworld.com/article/2073390/core-java/datastructures-and-algorithms-
part-1.html
 https://www.udemy.com/introduction-to-data-structures-algorithms-in-java/
Contents
Table of Figures....................................................................................................................................................7
Acknowledgement.................................................................................................................................................8
Task 1.................................................................................................................................................................. 10
Data structure.................................................................................................................................................10
Operations on Data Structures.....................................................................................................................11
Identifying the appropriate data structure for the “POP” game...............................................................12
Other Advantages......................................................................................................................................12
Other Disadvantages.................................................................................................................................12
Task 2.................................................................................................................................................................. 13
Crate a Program for search value in the given int array. Student can select any search algorithm for
execute the program......................................................................................................................................13
Task 3.................................................................................................................................................................. 16
What is recursion in data structure? Identify the advantages and disadvantages of recursion
algorithms......................................................................................................................................................16
Advantages.................................................................................................................................................16
Disadvantages............................................................................................................................................16
Develop method for recursion algorithm to print factorial value numbers..............................................16
References...............................................................................................................Error! Bookmark not defined.
Table of Figures

Figure 1 Create an appropriate Java class & method to Sort the above mention array.......................13
Figure 2 Create a method to search the given values in above mention array and method requires
array parameter with search key............................................................................................................14
Figure 3 Create a method to print the values in array and method require array parameter& Create
the main method to declare the given array. Call search and display methods.....................................15
Figure 4 Ouput.......................................................................................................................................15
Figure 5 Develop method for recursion algorithm to print factorial value numbers............................16
Acknowledgement
I would really like to give my special thanks to my lecturer Mr. Priyanga Siriwardana as well as our
Campus (ICBT) who gave me the golden opportunity to do this wonderful project on the Data
structures and algorithms, which also helped me do a lot of homework and I came to know so many
new things that I'm very grateful to them. During the lecture sessions Mr Priyanga Siriwardana shows
us to solve different kind data structures and algorithms Tasks and errors. Now I understand how data
structures and algorithms works.
Introduction

Data Structure is a means to gather and organize information in such a way that we can efficiently
execute operations on that data. In terms of certain partnerships, Data Structures is about making data
components for better organization and storage.in this assignment we need to Identify and properly
justify the most suitable data structure with their operations for above requirement. and also, we need to create
proper algorithms. For given scenarios.
Task 1

What is Algorithm?

An algorithm is a problem-solving process or formula based on a series of specified actions being


done. It is important to see a computer program as an intricate algorithm. An algorithm typically
means a small procedure in mathematics and computer science that addresses a recurring problem.

[ CITATION wha \l 1033 ]

Data structure
A data structure is a way of organizing and storing the data in computer in a manner that it can be used
effectively.

We may choose a data structure to work with various algorithms in computer programming. There is
details in and data structure about the relationship between data values and the functions that can be
added to the data. [ CITATION gee1 \l 1033 ]

There are mainly two types of data structures

1. Primitive data structures


2. Non-primitive data structures

Primitive data structures are data types which holds a single value.

E.g.: int, char, float, double

Non-primitive data structures are again divided into two groups

1. Linear data structures


2. Non-linear data structures

Linear data structures are arranged in a way that a data item is connected to one other data item in a
sequential manner. Data structure where data elements are organized sequentially or linearly in what is
called a linear data structure where the elements are connected to their prior and next neighboring
elements. Single stages are involved in the linear data structure. We can, thus, only traverse all the
elements in a single sprint. It is easy to enforce linear data structures since machine memory is
organized in a linear fashion.

E.g.: Arrays, Linked Lists, Stacks, Queues


Non-linear data structures are arranged in a way that a data item is connected to n number of other
data items in a random manner. Non-linear data structures are referred to as data structures where data
elements are not organized sequentially or linearly. A single level is not included in a non-linear data
system. Therefore, in a single sprint, we can't just traverse all the elements. In contrast to linear data
structures, non-linear data structures are not simple to introduce.

E.g.: Trees, Graphs

[ CITATION gee \l 1033 ]

Operations on Data Structures


1. Insertion.
2. Detection
3. Searching
4. Traversal.
5. Sorting.
6. Merging

Insertion - Insertion implies the addition to a data structure of a new data element
Detection- Deletion means the elimination, if detected, of a data entity from a data system.
Searching - Searching requires searching within a data structure for the defined data function.
Traversal- That means adding a new dimension to the structure of the crated data
Sorting - Sorting is called organizing data elements of a data structure in a given order.
Merging - It is called combining, which incorporates components of two identical data structures to
create a single data structure of the same kind.
[CITATION sca \l 1033 ]
Identifying the appropriate data structure for the “POP” game
In this game balls are added in a manner that the first ball added stays at the bottom of the tube and the
next one on top of it. Finally, the last ball added to the tube is the one we can fire first. And once it is
fired, the previously added ball comes to the top. This scenario follows first in last out (FILO)
procedure. So, we need a data structure which also follows First in last out procedure. So, Stack data
structure is the best data structure to implement this game.

Stack data structure has an operation named “push” which can be used to implement putting the balls
to the tube with respect to the game. And the “pop” operation of the stack can be used to implement
the Firing operation of the game.

The advantage of using Stack data structure is, it helps to manage the First in Last out method easily
and it won’t make any errors when ordering the items. The Disadvantage of this is, if we wanted to
select a random ball to shoot in the future, we can’t do that. Because Stack data structure always
allows us to fire the last ball that added to the tube.

Other Advantages
 Unlike arrays, memory can be allocated dynamically in stacks
 Adding and removing elements is faster it does not need much effort compared to arrays
 Stacks automatically deallocates variables once removed
Other Disadvantages
 Because of the dynamic memory allocation, if all the memory space is not used, then there will
be memory space wastage
 Stacks are not much flexible and it lacks of scalability
 Can only access local variables
 Needs to be careful when adding too much elements to the stacks, there’s a risk of stack
overflow
Task 2

Crate a Program for search value in the given int array. Student can select any search
algorithm for execute the program.

Figure 1Create an appropriate Java class & method to Sort the above mention array

A public java class is created named “Search”.

A method to sort the elements in the array in ascending order was created. Bubble sort method is
used in here because it is easier to understand and it is simple.

Bubble Sort is a basic algorithm that is used in the context of an array of n elements to sort a given set
of n elements supplied. Bubble Sort compares one by one all the elements and sorts them on the basis
of their values.

If the array in question needs to be sorted in ascending order, so the bubble sort begins by matching the
first element of the array with the second element, and if the first element is bigger than the second
element, all elements are switched, then the second and third elements are compared, and so on.
Figure 2Create a method to search the given values in above mention array and method requires array parameter with search key.

A method to search for an element in array is implemented named “searchArray”. This method
requires 2 arguments: an array and a search key. If the search value is found inside the array, the index
is returned. Binary Search method is the best method suitable here, because the array is already sorted.
So it is more efficient than linear search in this situation
Figure 3Create a method to print the values in array and method require array parameter& Create the main method to declare the
given array. Call search and display methods.

“display Array” method is implemented to print the values in the array. And a main method is
implemented to define the array elements and call the above created methods to get the output of the
program.

Figure 4Ouput

The output of the program is received as this, after the program is executed through NetBeans
Task 3
What is recursion in data structure? Identify the advantages and disadvantages of
recursion algorithms.

Recursion in data structures happens when a method calls itself within its own definition scope. It calls
itself over and over again until an exit condition is met which cause to breaks the loop.

Recursion method idea is to break a bigger problem into smaller pieces and compute these small pieces
individually and finally merge the results to get the final output.

Advantages
The main advantage of using recursion is sometimes it is much simpler to implement some
functionalities as a recursive function such as finding a factorial of a number. And also, it needs less
code and its much clearer because its closer to the mathematical definition.

Recursion methods are very helpful when traversing through tree elements. Since recursion methods
use a stack memory to store intermediate results it is faster in accessing the data. So the execution cam
be faster.

Disadvantages
However, it has some disadvantages. It needs more memory to work because intermediate values are
stored in the stack until the execution completes. So, this could lead to stack overflows if the program
is going much deeper. Also, if the exit conditions are not correctly defined, recursion methods could
lead to infinite loops and crash the program.

Develop method for recursion algorithm to print factorial value numbers.

Figure 5 Develop method for recursion algorithm to print factorial value numbers.
 We assume that, N is not a very big number, because it may cause errors due to stack overflow
if N is too big.

References
geeksforgeeks. (n.d.). . Retrieved from www.geeksforgeeks.org: https://www.geeksforgeeks.org/data-
structures/

geeksforgeeks. (n.d.). www.geeksforgeeks.org. Retrieved from https://www.geeksforgeeks.org/difference-


between-linear-and-non-linear-data-structures/

james. (n.d.). Retrieved from www.datastructure.com

scanftree. (n.d.). Retrieved from www.scanftree.com: https://scanftree.com/Data_Structure/

whatis.techtarget. (n.d.). whatis.techtarget.com. Retrieved from


https://whatis.techtarget.com/definition/algorithm

www.datastructure.com. (n.d.).
Conclusion

in this Data Structure & Algorithm assignment we have to identified and properly justified the most
suitable data structure with their operations for above requirement. and also, we had to create proper
algorithms. For given scenarios. I learnt lot from our lecturer Mr Priyanga Siriwardana and also, I have
read data structure and Algorithm E book online. I am thanking again Mr. Priyanga Siriwardana as
well as our Campus (ICBT) who gave me the golden opportunity to do this wonderful Data Structure
& Algorithm Project.
Page 19 of 19

You might also like