DP Computer Science Questionbank
D.4 Advanced program development
Description
[N/A]Directly related questions
-
19M.2.HL.TZ0.17b:
Outline one reason why a linked list may be more suitable than a binary tree in this particular situation.
-
19M.2.HL.TZ0.17c.i:
Construct the code needed to instantiate an object
guests
of theLinkedList
class. -
19M.2.HL.TZ0.17a:
Define the term object reference.
-
19M.2.HL.TZ0.17c.ii:
Construct the code for the method
penultimate()
that returns the second to last element in the linked listguests
. You may assume thatguests
is locally accessible. -
19M.2.HL.TZ0.17d:
Using the data provided in the diagram, trace the call
recursive(0,'F')
, clearly showing the levels of recursion. -
19M.2.HL.TZ0.17e:
Outline one reason why the use of a recursive method may be inappropriate for linked lists.
-
19M.2.HL.TZ0.17f:
Due to unforeseen circumstances, schools may cancel their participation in an event at the last minute. Therefore, a method is needed to remove all the visiting students of one school from the linked list
guests
.Construct the method
removeSchool
that takes the name of a school as parameter and removes all students of that school from the listguests
. - 17N.2.HL.TZ0.19a: Explain why recursion is a suitable tool to use when performing this check.
-
17N.2.HL.TZ0.18b:
Construct the method
changePrice()
. -
17N.2.HL.TZ0.19b:
The method
palindrome()
is called byboolean t = palindrome(word)
;
whereword
is a String variable.Without writing code, describe the recursive method
palindrome()
that returns whether or not a word is a palindrome. -
17N.2.HL.TZ0.18a:
Outline one benefit that the use of either of these choices will have over the original array structures.
-
17N.2.HL.TZ0.18c:
Explain how a binary tree structure would allow a more efficient search for the
Item
object. -
18N.2.HL.TZ0.16c:
Sketch the resulting linked list when an airplane with ID RO225, STA 12:05 and delay 0 is added to this list.
- 18N.2.HL.TZ0.16d.i: Define the term recursion.
-
18N.2.HL.TZ0.16e:
In case of bad weather it is possible that one of the runways has to be closed and the two linked lists (
runway1
andrunway2
) need to be merged using a methodmergeLists()
into one new linked listrunway
.Construct the method
public LinkedList<Arrival> mergeLists()
that merges the two sorted linked lists in to one sorted linked listresult
which needs to be returned. You may assume thatrunway1
andrunway2
are accessible to the method and do not need to be passed. The original two lists are allowed to becomenull
as a result of the merging.In answering this question, you may use the following methods from the JETS
LinkedList
class, in addition to any method provided or developed in this exam paper.addFirst(<object>) // adds the object at the head of the list
addLast(<object>) // adds the object at the tail of the list
getFirst() // returns the head object in the list
getLast() // returns the tail object in the list
removeFirst() // removes and returns the head object
removeLast() // removes and returns the tail object
size() // returns the number of objects in the list
isEmpty() // returns true if the list is empty -
18N.2.HL.TZ0.16d.ii:
Trace the call
process(runway1,0)
given the diagram ofrunway1
as drawn above. Copy and complete the following table. -
18N.2.HL.TZ0.16b:
Evaluate the use of dynamic linked lists to static arrays when managing arriving airplanes.
-
18N.2.HL.TZ0.16a:
Outline an advantage of using a library.
-
19N.2.HL.TZ0.17a:
Define the term object reference.
-
19N.2.HL.TZ0.17b:
Using object references, construct the method
public Cart removeFirst()
that removes the firstCartNode
object fromlist
. The method must return theCart
object in that node ornull
iflist
is empty. -
19N.2.HL.TZ0.17c:
Sketch the linked list
list
after running the following code fragment wherecart1, cart2, cart3, cart4
andcart5
have been instantiated as objects of the classCart
.POSlist queueList = new POSlist()
queueList.addLast(cart2);
queueList.addLast(cart1);
queueList.addLast(cart4);
queueList.removeFirst();
queueList.addLast(cart5);
queueList.addLast(cart3);
queueList.removeFirst(); -
19N.2.HL.TZ0.17d:
Outline one feature of the abstract data structure queue that makes it unsuitable to implement customers waiting in line.
-
19N.2.HL.TZ0.17e:
Using object references, construct the method
public Cart leaveList(int n)
that removes the nthCartNode
object fromlist
. The method must return theCart
object in that node.You may assume that the nth
CartNode
object exists in the list.
You may use any method declared or developed. -
19N.2.HL.TZ0.17f:
Explain the importance of using coding style and naming conventions when programming.
-
20N.2.HL.TZ0.16b:
Outline why searching for the registration plate in a binary tree would be faster than looking for it in the two-dimensional array.
-
20N.2.HL.TZ0.16c:
Identify the steps that would be involved in taking the data from this two-dimensional array and creating a binary search tree.
-
20N.2.HL.TZ0.17b:
A stack can be implemented using an array or a singly linked list.
Compare the use of these two data structures for creating a stack. -
20N.2.HL.TZ0.17a:
Construct the
staffRemoveCar
method. - 18M.2.HL.TZ0.18a: Outline why a linked list structure has been chosen for allCustomers.
-
18M.2.HL.TZ0.19b:
Copy and complete the following table to show the output when the method is called by:
recursionEx(3)
; -
18M.2.HL.TZ0.18b:
Construct the method
goldMails()
that will return anArrayList
containing the email addresses of all current “Gold” members. You should make use of any previously defined methods. -
18M.2.HL.TZ0.19a:
Identify two essential features of a recursive algorithm.
-
18M.2.HL.TZ0.19c:
Explain what would happen if the method was called by
recursionEx(-3)
. -
18M.2.HL.TZ0.19d:
Identify three features which should be included in either program code or UML diagrams to help programmers understand and modify programs in the future.