
数据结构与算法
矢口
这个作者很懒,什么都没留下…
展开
-
两个栈实现队列 两个队列实现栈
转自为说明思想,假设队列、栈都很大,不会出现满的情况。1. 两个栈实现队列//前提已知:struct Stack{ int top; //栈顶指针 int stacksize;//栈的大小 int *s; //栈底指针};void InitStack(Stack *s);void Push(Stack *s转载 2014-09-30 18:07:23 · 558 阅读 · 0 评论 -
单链表反转的递归实现(Reversing a Linked List in Java, recursively)
转自There's code in one reply that spells it out, but you might find it easier to start from the bottom up, by asking and answering tiny questions (this is the approach in The Little Lisper):转载 2014-10-31 22:23:35 · 1907 阅读 · 0 评论 -
什么是P问题、NP问题和NPC问题
转自 什么是P问题、NP问题和NPC问题 这或许是众多OIer最大的误区之一。你会经常看到网上出现“这怎么做,这不是NP问题吗”、“这个只有搜了,这已经被证明是NP问题了”之类的话。你要知道,大多数人此时所说的NP问题其实都是指的NPC问题。他们没有搞清楚NP问题和NPC问题的概念。NP问题并不是那种“只有搜才行”的问题,NPC问题才是。好,行了,基本上这个误解已经被澄...转载 2019-04-29 22:52:22 · 309 阅读 · 1 评论 -
通过快慢指针判断链表成环的原理
转自How does Floyd’s slow and fast pointers approach work?We have discussed Floyd’s fast and slow pointer algorithms inDetect loop in a linked list.The algorithm is to start two pointers, slo...转载 2019-05-10 23:00:13 · 638 阅读 · 0 评论