1. A desk can be modelled as a simple data structure with the following ADT Desk:
• add(x) puts item x on top of the desk
• process() processes the top item on the desk and removes it (either sending it to someone else or
just throwing it away!)
• find(x) finds and retrieves the item x if it’s somewhere on the desk
• scan() looks at the top item on the desk, but doesn’t remove it
i). What data structure can you think of that is most like the ADT Desk? Give reasons.
ii). Write out in pseudocode in the space below how you would implement the find(x)
method in the ADT Desk above, using only stacks. Assume the standard methods for a stack have
already been defined.
iii). What is the running time of your method above? explain.
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment