1、一、collection (有序)接口的实现的接口 set list其中set接口的实现类是HashSet,List接口的实现类是ArrayList、LinkList、Vector二、Map(无序)接口的实现类是HashMap、HashTableArrayList和Vector都是使用数组方式存...
分类:
编程语言 时间:
2015-06-15 23:26:39
阅读次数:
176
Rotate ListGiven a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3-...
分类:
其他好文 时间:
2015-06-12 09:46:35
阅读次数:
120
#include<stdio.h>#include<stdlib.h>typedefintStatus;typedefintElemtype;typedefstructLNode{ Elemtypedata; structLNode*next;}*LinkList;StatusInitList(LinkList&L){ L=(LinkList)malloc(sizeof(LNode)); L->next=NULL; return1;}StatusDestoryList(L..
分类:
编程语言 时间:
2015-06-10 15:57:02
阅读次数:
132
自己写的代码有几个比较大的用例一直过不去,网上的代码大部分有问题,思路是先将链表置空表,再将链表中的元素循环插入到指定位置。 下面是一份正确的代码,但是是带头节点的链表:void Insertsort(Linklist &L){ LNode *p,*q,*r,*u; p=L->next...
分类:
编程语言 时间:
2015-06-10 13:54:41
阅读次数:
204
#include#includeusing namespace std;typedef int ElemType;typedef struct LNode{ ElemType data; struct LNode *next1,*next2;}*LinkList;int main(){ int...
分类:
其他好文 时间:
2015-06-09 19:42:37
阅读次数:
108
public class LinkList {
public Node head;
public LinkList() {
head = new Node();
head.next = null;
}
//尾插法
public void createByTail(int[] arr, int n) {
Node tail = head;
for(int i=0; i...
分类:
编程语言 时间:
2015-06-09 17:10:25
阅读次数:
205
题目:现有两个递增的单链表L1和L2,设计一个算法将L1与L2的所有结点归并到递增的单链表L3中。要求:空间复杂度为O(1)。思路:本题可采用二路归并思路,但题目要求空间复杂度为O(1),因此不能复制结点,只能破坏L1和L2将结点插入到L3中。代码:void Merge(LinkList &L1,LinkList &L2,LinkList &L3)
{
LinkList *p=L1.head...
分类:
编程语言 时间:
2015-06-07 18:55:19
阅读次数:
350
#include "stdio.h" #include "string.h"#include "ctype.h" #include "stdlib.h" #include "io.h" #include "math.h" #include "time.h"#define OK...
分类:
其他好文 时间:
2015-06-06 16:33:44
阅读次数:
181
链表_LINKLIST
链表的结构
链表节点_LinkNode
链表节点连接
链表的基本操作
节点的插入_INSERTNODE
节点的删除_REMOVENODE
访问链表元素_VISITNODE
链表基本操作接口_INTERFACE
链表的编码实现
链表总结
本文中的所有代码都可以在这里:
https://github.com/qeesung/algorithm/tree/master/chapt...
分类:
其他好文 时间:
2015-06-05 22:45:06
阅读次数:
359
通过对单链表代码的复用,实现队列
一、LinkList.h
#ifndef _LINKLIST_H_
#define _LINKLIST_H_
typedef void LinkList;
typedef struct _tag_LinkListNode LinkListNode;
struct _tag_LinkListNode
{
LinkLis...
分类:
其他好文 时间:
2015-05-29 18:18:13
阅读次数:
212