Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display Stack and Queue
#1
I am a bit confused on implementing our display functions for Stack and Queue. Since there are different symbols (i.e. "[ ]", "< >", "( )", "| |"), how do we call different functions to display the different outputs since we can't just call the displayDA function for Stack and displayCDA for Queue?

Thanks so much!
Reply
#2
Since the stack and queue have different brackets, you need to walk through the underlying array (using getDA or getCDA) and print each item using the cached display function.

For the stack, you have to walk the underlying array in reverse.
Reply
#3
(09-08-2017, 09:45 PM)lusth Wrote: Since the stack and queue have different brackets, you need to walk through the underlying array (using getDA or getCDA) and print each item using the cached display function.

For the stack, you have to walk the underlying array in reverse.

So how do we access the private display function from Stack and Queue? I thought it was a private variable...
Reply
#4
you can cache the display function in your queue and stack structs as well.
Reply
#5
(09-08-2017, 10:38 PM)kjbrawner Wrote: you can cache the display function in your queue and stack structs as well.

Ok, didn't think about that. Thanks so much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)