+1 vote
in Data Structures & Algorithms I by (110k points)
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 I

The question was posed to me in an online interview.

1 Answer

+1 vote
by (550k points)
selected by
 
Best answer
Correct option is (a) S[N-1]

Best explanation: Array indexing start from 0, hence N-1 is the last index.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...