DATA STRUCTURES EXAM WITH
CORRECT ANSWERS
The following code: Print(Animal(4,1)) outputs the string, 'Dog'. However, the code:
Animal(4,1)='Cat' produces an error. Why could this be? - Correct Answers -Animal is a
tuple
The data structure used to store return addresses and local variables when a function is
executing is a: - Correct Answers -Stack
Before data is removed (popped) from a stack, what should be checked first? - Correct
Answers -Stack underflow
A buffer is used in data transfer between two devices operating at different speeds. For
example between a server and client in video transfer over the internet. Which data
structure should data be held in before being shown to the user? - Correct Answers -
Queue
A circular queue is implemented using an array of 6 elements, 0-5. The front pointer is
2, the back pointer is 5. What is the value of the back pointer when a new item is
enqueued? - Correct Answers -0
Sarah is making a version of a board game called Othello which is played on an 8x8
grid. Which data structure should Sarah use to store the colour of the counters in each
space to make her algorithms for the game most efficient? - Correct Answers -Arrays
(Arrays are an ideal data structure when the number of elements is known in advance
and does not change at run-time. An 8x8 grid for a board game is therefore best stored
as an array.)
The data structure used to store process blocks in a round robin scheduling algorithm is
a: - Correct Answers -Queue
A hash table is used when you want - Correct Answers -Immediate access to data
**A network printer uses spooling to hold print jobs waiting to print from many users.
Which data structure would be most suitable for storing the print jobs? - Correct
Answers -• Printers make use of queues to hold print jobs as they arrive.
CORRECT ANSWERS
The following code: Print(Animal(4,1)) outputs the string, 'Dog'. However, the code:
Animal(4,1)='Cat' produces an error. Why could this be? - Correct Answers -Animal is a
tuple
The data structure used to store return addresses and local variables when a function is
executing is a: - Correct Answers -Stack
Before data is removed (popped) from a stack, what should be checked first? - Correct
Answers -Stack underflow
A buffer is used in data transfer between two devices operating at different speeds. For
example between a server and client in video transfer over the internet. Which data
structure should data be held in before being shown to the user? - Correct Answers -
Queue
A circular queue is implemented using an array of 6 elements, 0-5. The front pointer is
2, the back pointer is 5. What is the value of the back pointer when a new item is
enqueued? - Correct Answers -0
Sarah is making a version of a board game called Othello which is played on an 8x8
grid. Which data structure should Sarah use to store the colour of the counters in each
space to make her algorithms for the game most efficient? - Correct Answers -Arrays
(Arrays are an ideal data structure when the number of elements is known in advance
and does not change at run-time. An 8x8 grid for a board game is therefore best stored
as an array.)
The data structure used to store process blocks in a round robin scheduling algorithm is
a: - Correct Answers -Queue
A hash table is used when you want - Correct Answers -Immediate access to data
**A network printer uses spooling to hold print jobs waiting to print from many users.
Which data structure would be most suitable for storing the print jobs? - Correct
Answers -• Printers make use of queues to hold print jobs as they arrive.