CITS2002 Systems Programming  
prev
next CITS2002 CITS2002 schedule  

Problems with our stack data structure

As written, our stack data structure works, but may be difficult to deploy in a large program.

In particular, the whole stack was represented by a single global pointer variable, and all functions accessed or modified that global variable.

  • What if our program required 2, or more, stacks?
  • What if the required number of stacks was determined at run-time?
  • Could the stacks be manipulated by functions that didn't actually "understand" the data they were manipulating wacko ?

Ideally we'd re-write all of our functions, push_item, push_item, and print_stack so that they received the required stack as a parameter, and used or manipulated that stack.

Techniques on how, and why, to design and implement robust data structures are a focus of the unit CITS2200 Data Structures & Algorithms.

 


CITS2002 Systems Programming, Lecture 19, p8, 3rd October 2023.