2 votes 2 votes Consider a stack and we wish to perform an operation StackDelete() in which we wish to delete all the elements of the stack .What is the worst case time complexity of doing this if stack is implemented: 1) Using an array 2)Using a Linked list Programming in C data-structures stack + – VS asked Dec 26, 2017 VS 762 views answer comment Share Follow See all 11 Comments See all 11 11 Comments reply Show 8 previous comments joshi_nitish commented Dec 26, 2017 reply Follow Share @VS there array is dynamic array, where memory is allocated using malloc(). but generally by default we take static array in which memory is binded up throughout lifetime of a function(in which array is declared) or throughout lifetime of program(if array declared globally). in case of static allocation deallocation of a array memory is not possible(i think so) because memory is allocated during compile time itself rather than runtime. 1 votes 1 votes VS commented Dec 26, 2017 reply Follow Share @joshi_nitish I think then the answer depends on how memory is allocated to an array. 1) Dynamic --> StackDelete() -->O(1) 2)Static --> StackDelete() -->O(n) But, what is the default case then ? 0 votes 0 votes joshi_nitish commented Dec 26, 2017 reply Follow Share @VS if asked in GATE, qsn will be properly framed avoiding any type of abguity that may arise 1 votes 1 votes Please log in or register to add a comment.