A linked list is a linear collection of data elements, whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes which together represent a sequence. In its most basic form, each node contains: data, and a reference (in other words, a link) to the next node in the sequence.
A linked list is said to contain a cycle if any node is visited more than once while traversing the list.
- Create a data structure that will be used for your linked list.
- Create function that will receive one parameter:
head
:= A node structure/object that is the head of a linked list.
- Your function must return a boolean denoting whether or not there is a cycle in the list. If there is a cycle, return true; otherwise, return false.
Given a matrix F of size n by m (where: m >= n) filled with integer numbers you can calculate a diagonal sum by summing all of the numbers starting from one of the corners (a, b, c, d) in F following a diagonal path until you reach the last number in the diagonal line.
Example:
In this case we start at corner c of a matrix of size n=3 by m=4, which has the diagonal numbers: [3, -7, -3]. The sum of all these numbers is: 3 + (-7) + (-3) = -7.
Our diagonal sum result is -7.
Another Example:
In this case we start at corner a of a matrix of size n=3 by m=3, which has the diagonal numbers: [-4, 8, 7]. The sum of all these numbers is: -4 + 8 + 7 = 11.
Our diagonal sum result is 11.
- Create a function named
diagonalSum
that receives two arguments:matrix
:= An Array[][] of size n by m: Array[n][m].corner
:= A character that represents the corner (a, b, c, d).
- The function
diagonalSum(matrix, corner)
must return an integer number, the diagonal sum result.
A round-robin tournament (or all-play-all tournament) is a competition in which each contestant meets all other contestants in turn. Also if there are several contestants is common to create groups that runs their own round robin tournament per group.
Example of a round robin tournament: Group A results.
Example of a round robin tournament: Group B results.
A tournament can have g number of groups and each group can have c number of contestants. Not all of the groups will have the same number of contestants, for example Group C (no picture for this group) will have 6 contestants instead of 5 which Group A has.
The total number of matches that can happen in a given group is calculated by:
Note that each match has a score, it's not just a win or a lose.
At the end of a round robin tournament (or a group tournament) the sum of all of the scores in which a contestant T participated will be used to determine the final position of the contestant T. The contestant with the best score will be placed first, then the second best score and so on.
Example of results:
The sum of the scores in which a particular contestant participated it's shown to the right of the row:
Both numbers represent the score at the end of the tournament, the black number is a minified & rounded version and the grey one is the score without any modification. The grey score is the one that we want and we will call it final score.
The final score can be calculated by getting the sum of all scores of the matches in which a contestant participated.
- Design a data structure that can hold the results of all of the groups and matches with the score.
- Create a function that allows to report a result of a match (score).
- Create a function that given a contestant name, returns the position and the final score of that contestant.
A linked list is a linear collection of data elements, whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes which together represent a sequence. In its most basic form, each node contains: data, and a reference (in other words, a link) to the next node in the sequence.
Given a linked list, the sum of all consecutive nodes that results in a 0 (zero) will be called Le Sammy sequence.
Example of Le Sammy sequence:
3 -> 4 -> -7 -> 5 -> -6 -> 6
In the above case you should first remove 3 -> 4 -> -7
, then -6 -> 6
, leaving only 5
.
- Create a function that given a linked list, removes the presence of all Le Sammy sequence (basically removes all the consecutive nodes that sum zero).