CTEC2909 - Data Structures and Algorithms: Tournament Players Analysis

Verified

Added on  2023/05/30

|9
|2102
|311
Report
AI Summary
This report provides an analysis of tournament players using data structures and algorithms. It discusses the behavior of players, the chosen array data structure for storing tournament information, and the justification for this choice, including time and space complexity considerations. The report details the elements and fields within the array list, such as game number, player names, and winner. It also includes a sample game information table and compares the advantages of using an array list over other data structures like linked lists, stacks, queues, and trees. Finally, it outlines operations that can be performed using the array list, such as listing played games and searching for game winners, along with their respective time complexities. Desklib provides a platform for students to access similar solved assignments and past papers.
Document Page
1Data Structure and Algorithms
DATA STRUCTURE AND ALGORITHMS
By (Student names)
[Course Name]
[Lecture Name]
[University Name]
[City where the university is located]
[Date]
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
2Data Structure and Algorithms
Table of Contents
Part 1: Tournament Players.........................................................................................................................3
Question a: players behavior...................................................................................................................3
Assumptions........................................................................................................................................3
Question b: chosen data structure and information storage......................................................................3
Array data structure.............................................................................................................................3
Question c: Table for storing example game information........................................................................4
Part 2 – Justification of the choice...............................................................................................................5
Advantages of array list.......................................................................................................................5
Part 3 – Operations......................................................................................................................................5
Reference.....................................................................................................................................................7
Document Page
3Data Structure and Algorithms
Part 1: Tournament Players
Question a: players behavior
In this games tournament scenario there are various players are involved and the selected players
will play against each other until the winner is found below are the assumptions made to
determine the players behaviors.
Assumptions
i. The tournament will involve more than three players.
ii. Each game will be played against two players.
iii. The players will be paired.
iv. Losers of each pair will not play against other players.
v. The winner of each pair will play will be selected to play against the other pair winner
(Wixom,2016).
vi. Each player will only play with each other once.
vii. The final winner will be the player who had not lost any game played from the first
pairs to the subsequent winners’ pairs.
Question b: chosen data structure and information storage
In order to store the tournament information there is the data structure that will be used that will
enable safe and quick data storage and also will allow the manipulation and operation of data
stored in them, below is the selected data structure.
Array data structure
The array is the selected data structure that will be used to store the games tournament details , in
this case the array list is the type of the array that will be used and this is to ensure the record
stored are in good format which enable users operations.
The array list will be implemented in with various dimensions and to hold all the attributes of the
stored data.
In the array list selected there will be various two vertices which include the players and winners
vertices and the games vertices where the players and winners vertices will be arranged
horizontally while the games vertices will be arranged vertically (Singh, 2016).
Document Page
4Data Structure and Algorithms
The arraylist will be having various elements which include the following:
i. ArrayList<Integer> Game_number.
This is used to store the records of the number of the games which is represented by intergers.
ii. ArrayList<String> Player1.
This is the element used to store details of the player 1 in the pairs of the playing teams.
iii. ArrayList< String > Player2.
This is the element used to store details of the player 2 in the pairs of the playing teams.
iv. ArrayList< String > Winner
This is the element used to store details of the winner in the pairs of the playing teams.
However there will be fields that will be used in the selected arraylist and they will include the
following:
i. Game_number. This is the field used to store the index value of the games being played.
ii. Player1. This is the field used to store the player1 of the games being played.
iii. Player2. This is the field used to store the player2 of the games being played
iv. Winner. This is the field used to store the winner of the games being played
The selected array list will be representing some edges which includes the game, player 1, player
2 and the winner of specific games and the results of each game will be recorded which will
entail the game number, player one name, player two name and the game winner name.
Question c: Table for storing example game information
Game_number Player1 Player2 Winner
1 Player
1
Player2 Player 1
2 Player
3
Player 4 Player 4
3 Player
5
Player 6 Player 5
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
5Data Structure and Algorithms
4 Player
1
Player 4 Player 1
5 Player
5
Player 1 Player 1
The table above shows the modeled tournament games record where there are six players, the
players are paired to form three initial games teams, the winner of game 1 and 2 are then paired
to form fourth team, the winner of the fourth game team is then paired with winner of game 3 to
form game 5 team where the winner of game 5 is therefore declared as the overall winner of the
entire tournament (Laplante, 2013).
Part 2 – Justification of the choice
The array list is the selected data structure to be used in the storage of the tournament records
and the selection of this data structure was due to the following reasons.
i. Time complexity of operations.
The array list will have constant O (n) time complexities while using various arbitrary index
while doing the add, remove, search and delete operations where it uses O(1) time at the end of
the list , therefore it becomes better than other data structures which have variable O(1) time
complexity at start and the end.
ii. Space complexity.
The arraylist space use is not directly proportional to the list size this is because the array list has
double size while is filled with elements for better utilization of memory, however unlike other
data structures like hashmap and linked list, the arraylist use a very little space per element and
therefore arraylist is best for memory utilization and thus is best for keeping a huge record of
tournament games (Karumanchi, 2012).
iii. Information handling.
The array list is type of array and is re-sizeable by nature and thus termed as dynamic array
where it grows in size in order to accommodate new elements and also reduces in size in case
some element are deleted from the list and therefore the arraylist use dynamic arrays in the
storage of the elements, therefore the player’s names, winner’s names and the games numbers
Document Page
6Data Structure and Algorithms
will be stored easily in the array list structure which will accommodate any size of games played
in the tournaments (Goyal, 2011).
Advantages of array list compared to other data structures
There are various data structures that can be used can be used as an alternative data structure but
the array list is better due to the various advantages associated to it which includes the following:
i. Unlike the linked list which has fixed length data structure the array list is re-sizeable
since it has a dynamic size that can shrink or expand.
ii. Unlike the stacks that one need to specify the size the arraylist uses length attribute to
get length of array which is unlimited.
iii. Unlike the queues that cannot store generic data the arraylist is able to store generic
data types easily.
iv. Unlike other tree structures which takes long to retrieve the records the arraylist is
able to access the elements quickly through searching process.
v. Unlike graphs data structures that take long to add and remove elements the arraylist
is able to add and remove elements dynamically.
vi. Unlike the other data structures that are very rigid to change the arraystructure is able
to be synchronized into a vector without anay codes modifications (Gupta, 2015).
Part 3 – Operations
Using the array list there are various operations that can be done which includes the following.
i. Listing the played games.
Working
To list all the games played in the tournament one could use the various methods where all the
indexes of the games played are selected, this involves the use of the “for loop”.
However listing of all elements in the array is done using the loop functions, this will be done by
first defining the “for” loop function then a print statement is given which holds the array name
and the index of all elements to be displayed, the index represents the loop variable name where
it will be continuously incremented or decremented which makes the index change and hence all
Document Page
7Data Structure and Algorithms
the game elements are displayed using the loop print statement defined using the get() method
which helps in displaying the elements of the respective index in the arraylist .
Below is a sample codes used.
System.out.println("Using for loop");
System.out.println("--------------");
for (int i = 0; i < list.size(); i++)
{
System.out.println(list.get(i));
}
Time complexity
The array list records will be listed easily and just little time will be used to retrieve and display
all the games records to the users.
However listing of all the elements in the arraylist takes some time to display all those elements
of the played games. The arraylist is basically a list which is backed by the array ,however there
is use of get(index) method that takes constant time O(1) in its operation , therefore the arraylist
will be returning games elements values from the array at a constant period of time.
ii. Searching the games winners.
Working
The array list will be having various games stored and the users can be able to search the specific
game record using the unique game number where the players and the winner details are then
displayed to the users.
However arraylist search is used to search specific values and in this case the various games
winners are searched, the search in this arraylist works as follows.
While searching the game winner in a certain game the winner element is found in the list that
contains strings, then the arraylist then use the for function to loop over its various games
elements , then in the loop equal() method is called on the given winner element and checks
whether it is matching with the elements that are from the arraylist for instance one can search
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
8Data Structure and Algorithms
the winner of “game 3” and the result is returned as true, in case a wrong index is entered a false
will be returned instead.
Time complexity
The arraylist is able to perform the search process where the game winner is retrieved using the
index, the element is accessed in random form using the elements index, the get() method is used
in retrieving the records where a constant set of time per operation is used which is represented
as O(n) operation, where O represents operations and n is the number of operations required
(Award, 2013).
.
Document Page
9Data Structure and Algorithms
Reference
Award, E.(2013) Systems Analysis and Design .3rd edn.Delhi:Galgotia Publications Pvt Ltd.
Gupta, B.(2015) Power System Analysis and Design.1st edn.New Delhi: S Chand & Company.
Goyal, A. (2011) systems Analysis and Design Paperback .2nd edn.INDIA:Prentice Hall India
Learning Private Limited.
Karumanchi, N.(2012) Peeling Design Patterns: For Beginners and Interviews.5th edn.New
York:CareerMonk Publications.
Laplante, P.(2013) Real-Time Systems Design and Analysis: Tools for the Practitioner.2nd
edn.New Jersey:Wiley.
Singh, B.(2016) Systems Analysis and Design.4th edn.Delhi:New Age International Private
Limited.
Wixom, D.(2016) Systems Analysis and Design.2nd edn. New Jersey: Wiley publishers.
chevron_up_icon
1 out of 9
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]