1.

Which of the following array element will return the top-of-the-stack-element for a stack of size N elements(capacity of stack > N)?(a) S[N-1](b) S[N](c) S[N-2](d) S[N+1]The question is from Stack using Array in portion Abstract Data Types of Data Structures & Algorithms IThe question was posed to me in an online interview.

Answer» CORRECT option is (a) S[N-1]

Best explanation: Array INDEXING start from 0, hence N-1 is the LAST INDEX.


Discussion

No Comment Found

Related InterviewSolutions