DP Computer Science Questionbank
Topic 5: Abstract data structures
Description
[N/A]Directly related questions
-
21M.1.HL.TZ0.10:
Identify two characteristics of a dynamic data structure.
-
21M.1.HL.TZ0.11:
Sketch a balanced binary tree that would allow the following output when traversed using in order traversal:
Zebra, Tango, Hotel, Foxtrot, Delta, Bravo, Alpha.
-
17N.1.HL.TZ0.13a:
Describe the features of a dynamic data structure.
-
17N.1.HL.TZ0.6b:
Determine the output produced by the method call
mystery(4)
. -
17N.1.HL.TZ0.13c:
Show the output produced by the following algorithm.
loop while (NOT FRUITS.isEmpty()) AND (NOT FLOWERS.isEmpty())
X = FRUITS.pop()
Y = FLOWERS.pop()
if X < Y then
output
X
else
output Y
end
if
end
loop
-
17N.1.HL.TZ0.13d:
A third stack,
FLOFRU
, is needed. It should contain all the data fromFLOWERS
andFRUITS
and will store it as shown belowDescribe how the
FLOFRU
stack could be created. -
17N.1.HL.TZ0.13b:
Explain how
“Primrose”
could be inserted into this doubly linked list. You should draw a labelled diagram in your answer. -
17N.1.HL.TZ0.14f.i:
State the index in of the first non-zero element in row of
- 17N.1.HL.TZ0.14e: State how many rows in BIGMAT contain only zeros.
- 17N.1.HL.TZ0.14a: State the total number of elements stored in MAT.
- 17N.1.HL.TZ0.14b: State the number of non-zero elements in MAT.
- 17N.1.HL.TZ0.14f.i: State the index in VALUES of the first non-zero element in row 5 of BIGMAT.
-
18N.1.HL.TZ0.11b:
Sketch a single linked list holding these vegetables.
-
18N.1.HL.TZ0.6:
Explain the importance of the method
isEmpty()
when constructing an algorithm which performs operations on a stack data structure. -
18N.1.HL.TZ0.12c.i:
State Paul’s total score.
-
18N.1.HL.TZ0.12c.ii:
State where Hugh’s score in the fourth round can be found.
-
18N.1.HL.TZ0.11a:
Compare the use of a dynamic linked list for holding these names of vegetables with a static one-dimensional array.
-
18N.1.HL.TZ0.11c.i:
List the steps required to insert cabbage into the linked list.
-
18N.1.HL.TZ0.11d:
State the dynamic data structure suitable for maintaining this list of vegetables which will allow faster searching for a given vegetable name.
-
18N.1.HL.TZ0.12d:
All the data stored in memory should be sorted in ascending order of total score using selection sort.
For example, after sorting, the data given opposite will be held in memory as follows
Construct an algorithm that will sort all the data in ascending order.
In your solution you should call methods
swap()
andswapRows()
given in part (a) and part (b). -
18N.1.HL.TZ0.11c.ii:
Explain why deleting the first node in this list is different to deleting other nodes.
-
18N.1.HL.TZ0.11e:
The vegetable names are input in the following order
potato, asparagus, lettuce, radish.
Sketch the data structure suggested in part (d) containing the vegetable names sorted in alphabetical order.
-
19N.1.HL.TZ0.5:
Sketch a double linked list that holds the following sequence of names: Anne, Lana, Mary.
-
19N.1.HL.TZ0.13b:
Construct an efficient algorithm for the method
isValidMatrix()
. -
19N.1.HL.TZ0.13c:
Determine the value of variable
X
after execution of the following method call:X = mystery(MAT,5)
where
MAT
is the two-dimensional array given. You must show your working. -
19N.1.HL.TZ0.13d:
Deduce the purpose of the method
mystery(A,R)
. -
19N.1.HL.TZ0.12c.i:
State the result of postorder traversal.
-
19N.1.HL.TZ0.13a:
State the value of
MAT
[3][4]. -
19N.1.HL.TZ0.12a:
State two applications of stacks.
-
19N.1.HL.TZ0.12c.ii:
Draw the binary tree after deleting the root node.
-
19N.1.HL.TZ0.12d:
Compare the use of static and dynamic data structures.
-
19N.1.HL.TZ0.12b:
Explain the use of a one-dimensional array as a static stack. Your answer should include brief outlines of the push and pop operations and the tests for empty and full stacks.
-
21N.1.HL.TZ0.5b:
Given the following binary search tree (BST), draw the resulting BST after the deletion of the root node.
-
21N.1.HL.TZ0.12b:
Outline how the last node of the circular linked list is identified.
-
21N.1.HL.TZ0.12c:
Describe the steps required to calculate the sum of all numbers held in this circular linked list.
-
21N.1.HL.TZ0.12d:
Compare the use of arrays and linked lists.
-
21N.1.HL.TZ0.5a:
Identify one difference between a binary tree and a non-binary tree.
-
21N.1.HL.TZ0.12a:
Sketch a diagram showing the resulting circular linked list.
-
21N.1.HL.TZ0.13a:
State the distance between Kiko and Longlines.
-
21N.1.HL.TZ0.13c:
Construct an algorithm in pseudocode that inputs the names of two bus stations and outputs the distance between them. If any of the inputted names are not found, the method should output an appropriate message.
-
21N.1.HL.TZ0.12e:
A linked list can be used to implement a data structure queue.
Identify two applications of a queue data structure.
-
21N.1.HL.TZ0.13b:
Construct an algorithm in pseudocode that checks the elements of the array
ROUTE_X_DISTANCES
and outputs whether the array is valid or not. -
21N.1.HL.TZ0.13d:
The array
ROUTE_X_TIMES
(Figure 3) stores the approximate number of minutes it takes for a bus to travel to a bus station from the previous one. For example,ROUTE_X_TIMES [6]
stores the number of minutes it takes for a bus to travel from Kingsley to Allapay: 7 minutes.Figure 3: The array
ROUTE_X_TIMES
Explain how this data could be used to determine the number of minutes it takes for a bus to travel between any two bus stations.
-
20N.2.HL.TZ0.16a.ii:
Identify one disadvantage of using a two-dimensional array for this purpose.
-
20N.2.HL.TZ0.16a.i:
Identify one advantage of using a two-dimensional array for this purpose.
-
20N.1.HL.TZ0.2b:
State the result of preorder traversal of this binary tree.
-
20N.1.HL.TZ0.12a:
Describe one difference between stack and queue data structures.
-
20N.1.HL.TZ0.12b.i:
State the purpose of the following queue method:
enqueue()
-
20N.1.HL.TZ0.12c:
Assume that the queue Q holds the following data:
The reversed queue Q would be:
Construct an algorithm in pseudocode for reversing the queue using a stack data structure.
You may assume that the data in the queue is input and a new empty stack is created.
Only the standard queue and stack operations are allowed. -
20N.1.HL.TZ0.12d:
Consider the following recursive method:
mystery(N)
if N>0 then
return 3 + mystery(N-3)
else
return 3
end if
end mysterywhere
N
is an integer.Determine the value of
mystery(7)
. Show all your working. -
20N.1.HL.TZ0.2a:
State the result of inorder traversal of this binary tree.
-
20N.1.HL.TZ0.12b.ii:
State the purpose of the following queue method:
dequeue()
-
20N.1.HL.TZ0.12e:
Outline one disadvantage of solving problems recursively.
-
20N.1.HL.TZ0.13a:
Construct an algorithm in pseudocode for the method
invert(N,A)
. -
20N.1.HL.TZ0.13b.ii:
Outline why it is more efficient that the loop in the given algorithm fragment executes
(K mod 4)
times instead ofK
times. You may give an appropriate example in your answer. -
20N.1.HL.TZ0.13c:
Construct the algorithm in pseudocode for the method
rotate(N,A)
described above. -
20N.1.HL.TZ0.13d:
To avoid inefficient use of memory, a new algorithm for the method
rotate(N,A)
is constructed.The
N × N
two-dimensional arrayA
should be rotated clockwise by 90°, without the use of any additional arrays.One way of rotating the two-dimensional array
A
clockwise by 90° is to transposeA
, and then reverse each row ofA
.The transpose of
A
is formed by turning all the rows ofA
into columns. For example, the value in the first row and third column (A[1][3]
) is swapped with the value in the third row and first column (A[3][1]
).
Construct the new algorithm in pseudocode for the methodrotate(N,A)
described above. -
20N.1.HL.TZ0.12b.iii:
State the purpose of the following queue method:
isEmpty()
-
20N.1.HL.TZ0.13b.i:
State the number of degrees by which the image will be rotated if the input value of
K
is 3. -
18M.1.HL.TZ0.8:
Describe the characteristics of a queue.
-
18M.1.HL.TZ0.13b:
Explain the benefits of using a binary search tree, compared to a stack, when searching for a specific item.
-
18M.1.HL.TZ0.13c:
If the tree is populated with the data from the stack, the first item popped off will become the root. For each subsequent item popped from the stack, a recursive procedure is followed until the item is correctly placed in the tree.
Without writing code, describe this recursive procedure.
- 18M.1.HL.TZ0.7: Define the term recursion.
-
18M.1.HL.TZ0.13d:
By considering only the data visible in the stack shown above, sketch the binary search tree that has been created from the items removed from the stack.
-
18M.1.HL.TZ0.13a:
Construct the pseudocode that will search the stack for a specific name, and output its position in the stack. You may assume that all names in the stack are unique.
-
18M.1.HL.TZ0.15a:
Construct pseudocode that will read
PASSENGERS
into the two-dimensional array,2D_ARRAY
. -
18M.1.HL.TZ0.15b:
Construct the pseudocode for the procedure
total
, that takes as input a column number of this two-dimensional array and returns the sum of the elements in that column. -
18M.1.HL.TZ0.15c:
The transport authority wishes to know how many passengers, on average, travel on each day of the week.
Using the procedure
total
construct the pseudocode to output the day of the week with the highest average number of passengers, and the value of this average.You should make use of the sub procedure
convert()
which converts the numbers 0 to 6 into days of the week, for exampleconvert(1)
will return “Tuesday”. -
18M.1.HL.TZ0.15d:
The transport authority stores details about the ticket prices in a one-dimensional array,
FEES
, whereFEES[0]
contains the price of a ticket for Monday to Friday, whileFEES[1]
contains the price of a ticket for Saturday and Sunday.The procedure
salesCalculate()
takes as input the column and row indices that define two specific days during the 30 weeks, and outputs the total amount of money generated from ticket sales between those two days (inclusive).Construct, in pseudocode, the procedure
salesCalculate()
. -
19M.1.HL.TZ0.12:
Outline why a binary tree would be a good choice of data structure for maintaining an address book.
-
19M.1.HL.TZ0.11:
State the output from the binary tree using postorder traversal.
-
19M.1.HL.TZ0.17b:
Construct an algorithm that will enable the company to print the mailing labels for all customers called
Jones
who live inCardiff
. -
19M.1.HL.TZ0.17c:
Explain the steps to insert
“Jones”
into this singly linked list. You may draw a labelled diagram in your answer. -
19M.1.HL.TZ0.17d:
Outline one example of where a circular linked list would be used in preference to a linear linked list.
-
19M.1.HL.TZ0.17a:
Construct the pseudocode that will find how many customers live in the city of
Cardiff
and display the results. -
22M.1.HL.TZ0.15d:
State the output from the given tree using inorder tree traversal.
-
22M.1.HL.TZ0.9a:
Identify one characteristic of a queue.
-
22M.1.HL.TZ0.9b:
Identify one application of a queue.
-
22M.1.HL.TZ0.15c:
Outline the steps involved in traversing the given tree using postorder tree traversal.
-
22M.1.HL.TZ0.10:
Define the term child in relation to a binary tree.
-
22M.1.HL.TZ0.15b:
Explain why a stack is used in the process of evaluating the expression in the algorithm.
- 957244: This is an example question for the example test. You can delete this question.
Sub sections and their related questions
5.1 Abstract data structures
- 18M.1.HL.TZ0.7: Define the term recursion.
-
18M.1.HL.TZ0.8:
Describe the characteristics of a queue.
-
18M.1.HL.TZ0.13a:
Construct the pseudocode that will search the stack for a specific name, and output its position in the stack. You may assume that all names in the stack are unique.
-
18M.1.HL.TZ0.13b:
Explain the benefits of using a binary search tree, compared to a stack, when searching for a specific item.
-
18M.1.HL.TZ0.13c:
If the tree is populated with the data from the stack, the first item popped off will become the root. For each subsequent item popped from the stack, a recursive procedure is followed until the item is correctly placed in the tree.
Without writing code, describe this recursive procedure.
-
18M.1.HL.TZ0.13d:
By considering only the data visible in the stack shown above, sketch the binary search tree that has been created from the items removed from the stack.
-
18M.1.HL.TZ0.15a:
Construct pseudocode that will read
PASSENGERS
into the two-dimensional array,2D_ARRAY
. -
18M.1.HL.TZ0.15b:
Construct the pseudocode for the procedure
total
, that takes as input a column number of this two-dimensional array and returns the sum of the elements in that column. -
18M.1.HL.TZ0.15c:
The transport authority wishes to know how many passengers, on average, travel on each day of the week.
Using the procedure
total
construct the pseudocode to output the day of the week with the highest average number of passengers, and the value of this average.You should make use of the sub procedure
convert()
which converts the numbers 0 to 6 into days of the week, for exampleconvert(1)
will return “Tuesday”. -
18M.1.HL.TZ0.15d:
The transport authority stores details about the ticket prices in a one-dimensional array,
FEES
, whereFEES[0]
contains the price of a ticket for Monday to Friday, whileFEES[1]
contains the price of a ticket for Saturday and Sunday.The procedure
salesCalculate()
takes as input the column and row indices that define two specific days during the 30 weeks, and outputs the total amount of money generated from ticket sales between those two days (inclusive).Construct, in pseudocode, the procedure
salesCalculate()
. -
19M.1.HL.TZ0.11:
State the output from the binary tree using postorder traversal.
-
19M.1.HL.TZ0.12:
Outline why a binary tree would be a good choice of data structure for maintaining an address book.
-
19M.1.HL.TZ0.17a:
Construct the pseudocode that will find how many customers live in the city of
Cardiff
and display the results. -
19M.1.HL.TZ0.17b:
Construct an algorithm that will enable the company to print the mailing labels for all customers called
Jones
who live inCardiff
. -
19M.1.HL.TZ0.17c:
Explain the steps to insert
“Jones”
into this singly linked list. You may draw a labelled diagram in your answer. -
19M.1.HL.TZ0.17d:
Outline one example of where a circular linked list would be used in preference to a linear linked list.
-
21M.1.HL.TZ0.10:
Identify two characteristics of a dynamic data structure.
-
21M.1.HL.TZ0.11:
Sketch a balanced binary tree that would allow the following output when traversed using in order traversal:
Zebra, Tango, Hotel, Foxtrot, Delta, Bravo, Alpha.
-
17N.1.HL.TZ0.6b:
Determine the output produced by the method call
mystery(4)
. -
17N.1.HL.TZ0.13a:
Describe the features of a dynamic data structure.
-
17N.1.HL.TZ0.13b:
Explain how
“Primrose”
could be inserted into this doubly linked list. You should draw a labelled diagram in your answer. -
17N.1.HL.TZ0.13c:
Show the output produced by the following algorithm.
loop while (NOT FRUITS.isEmpty()) AND (NOT FLOWERS.isEmpty())
X = FRUITS.pop()
Y = FLOWERS.pop()
if X < Y then
output
X
else
output Y
end
if
end
loop
-
17N.1.HL.TZ0.13d:
A third stack,
FLOFRU
, is needed. It should contain all the data fromFLOWERS
andFRUITS
and will store it as shown belowDescribe how the
FLOFRU
stack could be created. - 17N.1.HL.TZ0.14a: State the total number of elements stored in MAT.
- 17N.1.HL.TZ0.14b: State the number of non-zero elements in MAT.
- 17N.1.HL.TZ0.14e: State how many rows in BIGMAT contain only zeros.
- 17N.1.HL.TZ0.14f.i: State the index in VALUES of the first non-zero element in row 5 of BIGMAT.
-
17N.1.HL.TZ0.14f.i:
State the index in of the first non-zero element in row of
-
18N.1.HL.TZ0.6:
Explain the importance of the method
isEmpty()
when constructing an algorithm which performs operations on a stack data structure. -
18N.1.HL.TZ0.11a:
Compare the use of a dynamic linked list for holding these names of vegetables with a static one-dimensional array.
-
18N.1.HL.TZ0.11b:
Sketch a single linked list holding these vegetables.
-
18N.1.HL.TZ0.11c.i:
List the steps required to insert cabbage into the linked list.
-
18N.1.HL.TZ0.11c.ii:
Explain why deleting the first node in this list is different to deleting other nodes.
-
18N.1.HL.TZ0.11d:
State the dynamic data structure suitable for maintaining this list of vegetables which will allow faster searching for a given vegetable name.
-
18N.1.HL.TZ0.11e:
The vegetable names are input in the following order
potato, asparagus, lettuce, radish.
Sketch the data structure suggested in part (d) containing the vegetable names sorted in alphabetical order.
-
18N.1.HL.TZ0.12c.i:
State Paul’s total score.
-
18N.1.HL.TZ0.12c.ii:
State where Hugh’s score in the fourth round can be found.
-
18N.1.HL.TZ0.12d:
All the data stored in memory should be sorted in ascending order of total score using selection sort.
For example, after sorting, the data given opposite will be held in memory as follows
Construct an algorithm that will sort all the data in ascending order.
In your solution you should call methods
swap()
andswapRows()
given in part (a) and part (b). -
19N.1.HL.TZ0.5:
Sketch a double linked list that holds the following sequence of names: Anne, Lana, Mary.
-
19N.1.HL.TZ0.12a:
State two applications of stacks.
-
19N.1.HL.TZ0.12b:
Explain the use of a one-dimensional array as a static stack. Your answer should include brief outlines of the push and pop operations and the tests for empty and full stacks.
-
19N.1.HL.TZ0.12c.i:
State the result of postorder traversal.
-
19N.1.HL.TZ0.12c.ii:
Draw the binary tree after deleting the root node.
-
19N.1.HL.TZ0.12d:
Compare the use of static and dynamic data structures.
-
19N.1.HL.TZ0.13a:
State the value of
MAT
[3][4]. -
19N.1.HL.TZ0.13b:
Construct an efficient algorithm for the method
isValidMatrix()
. -
19N.1.HL.TZ0.13c:
Determine the value of variable
X
after execution of the following method call:X = mystery(MAT,5)
where
MAT
is the two-dimensional array given. You must show your working. -
19N.1.HL.TZ0.13d:
Deduce the purpose of the method
mystery(A,R)
. -
20N.2.HL.TZ0.16a.i:
Identify one advantage of using a two-dimensional array for this purpose.
-
20N.2.HL.TZ0.16a.ii:
Identify one disadvantage of using a two-dimensional array for this purpose.
-
20N.1.HL.TZ0.2a:
State the result of inorder traversal of this binary tree.
-
20N.1.HL.TZ0.2b:
State the result of preorder traversal of this binary tree.
-
20N.1.HL.TZ0.12a:
Describe one difference between stack and queue data structures.
-
20N.1.HL.TZ0.12b.i:
State the purpose of the following queue method:
enqueue()
-
20N.1.HL.TZ0.12b.ii:
State the purpose of the following queue method:
dequeue()
-
20N.1.HL.TZ0.12b.iii:
State the purpose of the following queue method:
isEmpty()
-
20N.1.HL.TZ0.12c:
Assume that the queue Q holds the following data:
The reversed queue Q would be:
Construct an algorithm in pseudocode for reversing the queue using a stack data structure.
You may assume that the data in the queue is input and a new empty stack is created.
Only the standard queue and stack operations are allowed. -
20N.1.HL.TZ0.12d:
Consider the following recursive method:
mystery(N)
if N>0 then
return 3 + mystery(N-3)
else
return 3
end if
end mysterywhere
N
is an integer.Determine the value of
mystery(7)
. Show all your working. -
20N.1.HL.TZ0.12e:
Outline one disadvantage of solving problems recursively.
-
20N.1.HL.TZ0.13a:
Construct an algorithm in pseudocode for the method
invert(N,A)
. -
20N.1.HL.TZ0.13b.i:
State the number of degrees by which the image will be rotated if the input value of
K
is 3. -
20N.1.HL.TZ0.13b.ii:
Outline why it is more efficient that the loop in the given algorithm fragment executes
(K mod 4)
times instead ofK
times. You may give an appropriate example in your answer. -
20N.1.HL.TZ0.13c:
Construct the algorithm in pseudocode for the method
rotate(N,A)
described above. -
20N.1.HL.TZ0.13d:
To avoid inefficient use of memory, a new algorithm for the method
rotate(N,A)
is constructed.The
N × N
two-dimensional arrayA
should be rotated clockwise by 90°, without the use of any additional arrays.One way of rotating the two-dimensional array
A
clockwise by 90° is to transposeA
, and then reverse each row ofA
.The transpose of
A
is formed by turning all the rows ofA
into columns. For example, the value in the first row and third column (A[1][3]
) is swapped with the value in the third row and first column (A[3][1]
).
Construct the new algorithm in pseudocode for the methodrotate(N,A)
described above. -
21N.1.HL.TZ0.5a:
Identify one difference between a binary tree and a non-binary tree.
-
21N.1.HL.TZ0.5b:
Given the following binary search tree (BST), draw the resulting BST after the deletion of the root node.
-
21N.1.HL.TZ0.12a:
Sketch a diagram showing the resulting circular linked list.
-
21N.1.HL.TZ0.12b:
Outline how the last node of the circular linked list is identified.
-
21N.1.HL.TZ0.12c:
Describe the steps required to calculate the sum of all numbers held in this circular linked list.
-
21N.1.HL.TZ0.12d:
Compare the use of arrays and linked lists.
-
21N.1.HL.TZ0.12e:
A linked list can be used to implement a data structure queue.
Identify two applications of a queue data structure.
-
21N.1.HL.TZ0.13a:
State the distance between Kiko and Longlines.
-
21N.1.HL.TZ0.13b:
Construct an algorithm in pseudocode that checks the elements of the array
ROUTE_X_DISTANCES
and outputs whether the array is valid or not. -
21N.1.HL.TZ0.13c:
Construct an algorithm in pseudocode that inputs the names of two bus stations and outputs the distance between them. If any of the inputted names are not found, the method should output an appropriate message.
-
21N.1.HL.TZ0.13d:
The array
ROUTE_X_TIMES
(Figure 3) stores the approximate number of minutes it takes for a bus to travel to a bus station from the previous one. For example,ROUTE_X_TIMES [6]
stores the number of minutes it takes for a bus to travel from Kingsley to Allapay: 7 minutes.Figure 3: The array
ROUTE_X_TIMES
Explain how this data could be used to determine the number of minutes it takes for a bus to travel between any two bus stations.
-
22M.1.HL.TZ0.9a:
Identify one characteristic of a queue.
-
22M.1.HL.TZ0.9b:
Identify one application of a queue.
-
22M.1.HL.TZ0.10:
Define the term child in relation to a binary tree.
-
22M.1.HL.TZ0.15b:
Explain why a stack is used in the process of evaluating the expression in the algorithm.
-
22M.1.HL.TZ0.15c:
Outline the steps involved in traversing the given tree using postorder tree traversal.
-
22M.1.HL.TZ0.15d:
State the output from the given tree using inorder tree traversal.
- 957244: This is an example question for the example test. You can delete this question.