由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Sort a stack without using auxiliary stacks or arrays
相关主题
请大虾验证!这段C++程序有错吗?
stack/heap corruption看来跳了Scala的坑是对的
array allocation in c请教改numpy array的dtype
[合集] 两个经典面题how to use stack(s) to realize a queque
OO design for reservation system?关于thread的stack
千老大叔学编程看了几个kaggle的答题,有点迷惑了
a simple question请熟悉Scheme (LISP)编程的高手帮忙
A question about sharing data inside a C++ classPython:请问如何把list变成structured array。
相关话题的讨论汇总
话题: auxiliary话题: sort话题: stack话题: stacks话题: arrays
进入Programming版参与讨论
1 (共1页)
b**a
发帖数: 1118
1
Design an efficient algorithm to sort elements in a stack in either
ascending/descending order, using only pop(), top(), push(), isEmpty(),
isFull(). Do not use any auxiliary stacks or arrays.
I found this question in jobhunting board. the anwser given by a niu ren is
Is this right? Does not look like right one.Thanks.
c*****t
发帖数: 1879
2
You didn't post the complete code. What you looked at was mostly a
for-loop.

is

【在 b**a 的大作中提到】
: Design an efficient algorithm to sort elements in a stack in either
: ascending/descending order, using only pop(), top(), push(), isEmpty(),
: isFull(). Do not use any auxiliary stacks or arrays.
: I found this question in jobhunting board. the anwser given by a niu ren is
: Is this right? Does not look like right one.Thanks.

E*V
发帖数: 17544
3
seems right
why dont' you test it?

is

【在 b**a 的大作中提到】
: Design an efficient algorithm to sort elements in a stack in either
: ascending/descending order, using only pop(), top(), push(), isEmpty(),
: isFull(). Do not use any auxiliary stacks or arrays.
: I found this question in jobhunting board. the anwser given by a niu ren is
: Is this right? Does not look like right one.Thanks.

w***g
发帖数: 5958
4
This is a recursive algorithm, and it actually uses an auxiliary stack
, though not obvious to newbies. This is actually more dangerous than
explicitly using some auxiliary data structure because recursion may lead to
stack overflow.

is

【在 b**a 的大作中提到】
: Design an efficient algorithm to sort elements in a stack in either
: ascending/descending order, using only pop(), top(), push(), isEmpty(),
: isFull(). Do not use any auxiliary stacks or arrays.
: I found this question in jobhunting board. the anwser given by a niu ren is
: Is this right? Does not look like right one.Thanks.

1 (共1页)
进入Programming版参与讨论
相关主题
Python:请问如何把list变成structured array。OO design for reservation system?
[转载] CS Algorithm Interview question千老大叔学编程
size不固定的struct怎么定义呀?a simple question
how to use array to simulate multi loopsA question about sharing data inside a C++ class
请大虾验证!这段C++程序有错吗?
stack/heap corruption看来跳了Scala的坑是对的
array allocation in c请教改numpy array的dtype
[合集] 两个经典面题how to use stack(s) to realize a queque
相关话题的讨论汇总
话题: auxiliary话题: sort话题: stack话题: stacks话题: arrays