Linked list vs. dynamic array for implementing a stack

后端 未结 5 1110
再見小時候
再見小時候 2020-12-24 13:02

I\'ve started reviewing data structures and algorithms before my final year of school starts to make sure I\'m on top of everything. One review problem said \"Implement a s

5条回答
  •  甜味超标
    2020-12-24 13:56

    I think you answered the question yourself. For a stack with a large number of items, the dynamic array would have excessive overhead costs (copying overhead) when simply adding an extra item to the top of the stack. With a list it's a simple switch of pointers.

提交回复
热议问题