Please copy and paste this embed script to where you want to embed

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

Student Name & No.

Assessor

SED52013

Priyanga Siriwardana

Hand out date

Submission Date

Assessment type Duration/Length of Weighting of Assessment Assessment Type Coursework

3 weeks

100%

Learner declaration I, …………………………………………., 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 F 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 Create an approp appropriat riatee Java Java class. class. 2. Create a method to Sort the above mention array 3. Create a method method to to search the the given given values values in above above mention mention array and and method method requires requires array parameter with search key. 4. Create a method method to to print print the values values in array array and method method require require array array parameter parameter 5. Create the the main method method to to declare declare the given given array. array. Call search search and display display method methods. s.

Task 3

Marks 35 (LO 3)

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

1. What is recursio recursion n in data data structure? structure? Identify Identify the advanta advantages ges and disadv disadvantage antagess of recursi rec ursion on algori algorithm thms. s. 2. Develo Develop p metho method d for for recurs recursion ion algori algorithm thm to prin printt factor factorial ial valu valuee number numbers. s.

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 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 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. Availa Ava ilable ble at: [Accessed 20 Octomber 2014].

Resources

Books

An Introduction to Object-Oriented Programming with Java, Ja va, 5th Edition(McGrawHill)978-0-07352-330-9

Data Structures and Algorithms in Java , 2 nd Edition (Robert Lafore)

Websites

http://www.javaworld.com/article/2073390/core-java/datastructures-and-algorithms/core-java/datastructures-and-algorithmshttp://www.javaworld.com/article/2073390 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 Structures .....................................................................................................................11 Identifying the appropriate data structure for the “POP” game...............................................................12 game...............................................................12 Other Advantages......................................................................................................................................12 Advantages......................................................................................................................................12 Other Disadvantages.................................................................................................................................12 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 program......................................................................................................................................13

Task 3..................................................................................................................................................................16 What is recursion in data structure? Identify the advantages and disadvantages of recursion algorithms......................................................................................................................................................16 algorithms......................................................................................................................................................16 Advantages.................................................................................................................................................16 Advantages .................................................................................................................................................16 Disadvantages............................................................................................................................................16 Disadvantages............................................................................................................................................16 .............. .............. ...............................16 ........................16 Develop method for recursion algorithm to print factorial value numbers. numbers........ References............................................................................................................... Error! Bookmark not dened.

Table of Figures appropriate Java class & method to Sort the above mention Figure 1 Create an appropriate mention array.......................13 Figure 2 Create a method to search the given values in above mention array and method requires array parameter with search s earch key................... ke y......................................... ............................................ ............................................ .............................................14 .......................14 Figure 3 Create a method to print the values in array arr ay and method require array parameter& Create the main method to declare the given array. Call search and display methods.....................................15 methods.....................................15 Figure 4 Ouput........................... Ouput................................................. ............................................ ............................................ ............................................................... ..........................................15 .15 Figure 5 Develop method for recursion algorithm algorithm to print factorial value numbers............................16 numbers........................ ....16

Acknowledgement I would really like to give my special thanks to my lecturer Mr. Priyanga Siriwardana as well as our Campus Cam pus (ICBT) (ICBT) who gave me the golden golden opport opportuni unity ty to do this this wonder wonderful ful project project on the Data 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 compo nents for better organization organization and storage.in storage.in this assignment 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. 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. Prim Primit itiv ivee data data stru struct ctur ures es 2. Non-pr Non-primi imitiv tivee data data structu structures res Primitive data structures 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. Line Linear ar da data ta str struc uctu tures res 2. NonNon-li line near ar data data stru struct ctur ures es Linear data structures 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 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. 2. 3. 4. 5. 6.

Inser sertion. Detection Searching Trav raversa rsal. Sorting. 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

Sortin ing g is call called ed or orga gani nizi zing ng data data elem elemen ents ts of a da data ta stru struct ctur uree in a gi give ven n or orde der. r. Sorting - Sort 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 Identifyin g 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 las t 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 advantage of using using Stack data structure structure is, it helps to manage 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 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 menon 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 menon array and method requires array parameter with search key.

A method method to search search for an element element in array is implem implement ented ed named “sea This is method “searchA rchArray rray”. ”. Th 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

arr ay parameter& Create the main method to declare the Figure 3Create a method to print the values in array and method require array 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 imple mented to define the array elements elements and call the above created created methods 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 The main ad adva vant ntag agee of us usin ing g re recu cursi rsion on is so some meti times mes it is much much simp simpler ler to impl implem emen entt some 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 Recursion traversing through tree elemen elements. ts. Since recursion methods 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 f rom www.geeksforgeeks.org: hps://www.geeksforgeeks.org/datastructures/ geeksforgeeks. (n.d.). www.geeksforgeeks.org. Retrieved from hps://www.geeksforgeeks.org/dierencehps://www.geeksforgeeks.org/dierencebetween-linear-and-non-linear-data-structures/ james. (n.d.). Retrieved from www.datastructure.com www.datastructure.com scanree. (n.d.). Retrieved from www.scanree.com: hps://scanree.com/Data_Structure/ whas.techtarget. (n.d.). whas.techtarget.com. Retrieved from hps://whas.techtarget.com/denion/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

Thank you for interesting in our services. We are a non-profit group that run this website to share documents. We need your help to maintenance this website.