算法导论10.2-7习题解答(单链表逆转)
摘要:
CLRS 10.2-7 :在O(n)时间内对给定的单链表进行逆转。解法:这题没什么技巧,就是将指针的指向进行改变即可。#include <iostream>usingnamespace std;//很简单的Node 和 Listclass Node{public: Node* next; int data; Node(); Node(int d);};class List{public: Node* first; List(); void insert(int d);};int main(){ int K =5; List* list =new List(); ... 阅读全文
posted @ 2011-04-16 19:23 NULL00 阅读(846) 评论(1) 推荐(0) 编辑