147k views
1 vote
Write an algorithm in pseudocode or english that would describe how to use a stack to reverse any list.

User Atu
by
8.2k points

1 Answer

2 votes
int data[n];
int rev[n];

for (i=0; i < n; i++)
stack.push(data[n]);
for (i=0; i <n; i++)
rev[i] = stack.pop();

User Jerome Escalante
by
8.0k points