摘要: 注意插入和删除操作中的限制约束条件。class ListNode { ListNode next; int val; public ListNode(int x) { val = x; }}public class LinkList { private L... 阅读全文
posted @ 2015-10-05 22:08 lasclocker 阅读(247) 评论(0) 推荐(0) 编辑
摘要: 打印链表元素的顺序与尾插入法的相反,但代码比尾插入法更简洁。class ListNode { ListNode next; int val; public ListNode(int x) { val = x; }}public class LinkList { ... 阅读全文
posted @ 2015-10-05 20:51 lasclocker 阅读(430) 评论(0) 推荐(0) 编辑
摘要: class ListNode { ListNode next; int val; public ListNode(int x) { val = x; }}public class LinkList { private ListNode curr = new... 阅读全文
posted @ 2015-10-05 20:44 lasclocker 阅读(539) 评论(0) 推荐(0) 编辑
摘要: 利用尾插入法建立单向链表,开始结点充当队列的head,末尾结点充当队列的tail,并考虑下溢出。class ListNode { ListNode next; int val; public ListNode(int x) { val = x; }}public... 阅读全文
posted @ 2015-10-05 19:12 lasclocker 阅读(353) 评论(0) 推荐(0) 编辑
摘要: 下面利用数组实现的循环队列,并考虑了上溢出和下溢出。public class Queue { private int[] queue; private static final int defaultSize = 100; private int size; private ... 阅读全文
posted @ 2015-10-05 19:10 lasclocker 阅读(299) 评论(0) 推荐(0) 编辑
摘要: 链式栈不需要考虑上溢出(overflow),但在存储时需要增加指针开销。class ListNode { ListNode next; int val; public ListNode(int x) { val = x; }}public class Stack... 阅读全文
posted @ 2015-10-05 16:10 lasclocker 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 上面代码实现了Stack的isEmpty(),isFull(),clear(),push(),pop(),peek()方法。顺序栈,必须要同时检查下溢出(underflow)和上溢出(overflow)。public class Stack { private int[] stack; ... 阅读全文
posted @ 2015-10-05 16:02 lasclocker 阅读(447) 评论(0) 推荐(0) 编辑