中易网

请高手推荐本c++数据结构的经典书!

答案:3  悬赏:40  
解决时间 2021-01-04 07:02
如题,但是要经典。经典程度最好相当于谭浩强的c语言程序设计和C++ Primer
最佳答案
看你是什么级别的了。如果是初级先把清华大学 严蔚敏 《数据结构》啃完。

再可以看看《Data Structures and Algorithms with Object-Oriented Design Patterns in C++》

如果再有余力就看《STL源码剖析》(侯捷)——里面是STL的实现分析,绝对值得看。
全部回答
清华大学的严蔚敏 《数据结构》 足够了

n=2的例子:

const unsigned int stacksize = 100;

#ifndef bothstack_h #define bothstack_h template<typename t> class cbothstack {  t data[ stacksize ];  int top1;  int top2;

public:  cbothstack();  ~cbothstack();  void push(unsigned short int i , t x);  t pop(unsigned short int i);  t gettop(unsigned short int i) const;  bool empty() const; }; #endif

template<typename t> cbothstack<t>::cbothstack() {  top1 =- 1;  top2 = stacksize; }

template<typename t> cbothstack<t>::~cbothstack() {}

template<typename t> void cbothstack<t>::push(unsigned short int i , t x) {  if ( top1 + 1 == top2 ) throw "上溢";  if ( i == 1) data[ ++top1 ] = x;  if ( i == 2 ) data[ --top2 ] = x; }

template<typename t> t cbothstack<t>::pop(unsigned short int i) {  if ( top1 == -1 || top2 == stacksize) throw "下溢";  else if ( i == 1 ) return data[ top1-- ];  else if ( i == 2 ) return data[ top2++ ]; }

template<typename t> t cbothstack<t>::gettop(unsigned short int i) const {  if ( top1 == -1 || top2 == stacksize ) throw "下溢";  if ( i == 1 ) return data[ top1 ];  if ( i == 2 ) return data[ top2 ]; }

template<typename t> bool cbothstack<t>::empty() const {  return ( top1 == -1 && top2 == stacksize); }

我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
累歲的意思是什么?累歲的释义是什么啊?
请问务位朋友老鹧鸪炖不烂,炖汤时加什么才能
His teacher is r__ a story
7个6等于5,填十一x÷
米外史的意思是什么啊?请解释下!
小孩子吃东西呛到迅速死亡是怎样回事
女墙的意思是什么?女墙的释义是什么啊?
为什么有人死了身为长孙子要挨家挨户的磕头
除了剧毒响尾蛇在夜晚行动还有什么蛇会在夜间
什么是公众人物???
如何招聘到最合适的候选人
小松350挖掘机右边不能行走了是哪里故障了
贤交的意思是什么?贤交的释义是什么啊?
烟签的意思是什么啊?请解释下!
南非被绑的5名中国籍公民怎么样了?
推荐资讯
钱袋宝怎么停止注册账号,什么时候能恢复啊
女人可以天天去汗蒸吗
使用座机时,是不是只要把听筒放在电话上,就
CCNA过了期就得重考吗?以后找工作时
龙湖武林九里离3号地铁多远
阳春市松柏派出所办公地址在什么地方,我要处
梦幻西游中的套装定心术增加多少灵力啊?
征求一个餐馆名字,准备做韩国拌饭。
乾隆这个乾隆通宝值多少钱
阴阳师在世界聊天怎么发送点击领取 颜色字体
长期拿符纸烧成灰泡水喝对身体会不会有影响?
尼龙是什么面料
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?