Linked Lists and Array Questions
-
-
An array is a static data structure which holds a collection of data of a single type.
str[10] names for i of {0..9} names[i] = input('Enter a name: ') print((str i+1) + '. ' + names[i]) next
-
array totals[10] for row of data for i of {0..10}: totals[i] += row[i] next next for total of totals print(total / 11) next-
-
Identifier:
Board
Dimensions: 2
Most appropriate data type:char[][] PROCEDURE ClearDisplay FOR Row = 1 TO 3 FOR Column = 1 to 15 Board( Row, Column) = " " NEXT Column NEXT Row END PROCEDURE
-
-
-
nodeNoorderNonext0 154 1 1 157 2 2 155 3 3 156 4 4 158 ø nodeNoorderNonext0 154 5 1 157 2 2 155 3 3 156 4 4 158 ø 5 159 1
-
nodeNois equivalent to the column index of the 2D array.finishedcountoutputfalse- - false0 - false0 184 false1 184 false1 186 false2 186 false2 185 false3 185 true3 185 xfinds and prints the last order in the linked list.- The new order can be added to the array, such that the linked list is in the correct order, as follows:
- Locate the third item in the list (by traversing the first and second nodes)
- Add the new order to the end of the list, with the link pointer set to the address of the third item (found previously)
- Update the link pointer of the second item to point to the new item (the end of the array)
- It allows fast insertion of new elements to arbitrary points in the list, and allows freedom to extend the list infinitely without reallocating the entire list when its buffer is filled
-
-
- A record is a static collection of data which can be of different types
- A 1D array is suitable for the application as it is used to hold information about the players in the game; the number of which is selected once (and so only one index is needed)
- Queue