Write a program to find the node at which the intersection of two singly linked lists begins.
For example, the following two linked lists:
A: a1 → a2
↘
...
分类:
其他好文 时间:
2015-01-16 11:18:52
阅读次数:
110
Sort a linked list using insertion sort.
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
...
分类:
其他好文 时间:
2015-01-15 16:10:33
阅读次数:
147
Sort a linked list in O(n log n)
time using constant space complexity.
MergeSort对于链表的排序,实现了就地排序的同时,时间复杂度和空间复杂度都达到了基于比较的排序的最优值,因此归并排序是链表排序的最佳排序方式。
/**
* Definition for singly-linked list.
* str...
分类:
其他好文 时间:
2015-01-15 16:01:52
阅读次数:
193
Given a list, rotate the list to the right by k places, where k is non-negative.
For example:
Given 1->2->3->4->5->NULL and k = 2,
return 4->5->1->2->3->NULL.
/**
* Definition for singly-lin...
分类:
其他好文 时间:
2015-01-12 16:45:05
阅读次数:
151
2015年学习计划安排:http://www.cnblogs.com/cyrus-ho/p/4182275.html尝试用C++实现了双向链表类LinkList,基本功能是在位置i插入结点和删除位置i的结点。首先是结点类,每个结点有数据data,指向前一个结点的指针front和指向后一个结点的指针n...
分类:
编程语言 时间:
2015-01-05 18:37:50
阅读次数:
226
package com.lanyuan.log;public class Test1 { private TNode head; private int size; private TNode last; public int size() { return t...
分类:
其他好文 时间:
2014-12-22 12:28:38
阅读次数:
243
操作系统实验作业。简单写一下,都写到一个文件去来。 1 /************************************************************************* 2 > File Name: LinkList.c 3 > Author...
分类:
系统相关 时间:
2014-12-21 13:51:49
阅读次数:
247
概述 还是相对简单,不过要记得释放不用的头结点即可.代码为: 1 //将lList2头结点连接在lList1尾结点的后面. 2 void 3 combine(linklist lList1, linklist lList2) { 4 Linknode *lst01Tail = lList1...
分类:
其他好文 时间:
2014-12-19 11:35:54
阅读次数:
164
主要分两个接口:collection和Map主要分三类:集合(set)、列表(List)、映射(Map)1.集合:没有重复对象,没有特定排序方式2.列表:对象按索引位置排序,可以有重复对象3.映射:有一个键对象和一个值对象,键不可重复,值可以重复这里我们介绍Listlist是接口,linklist和...
分类:
编程语言 时间:
2014-12-16 19:09:00
阅读次数:
207
主要内容:链表头插法和尾差法
#include
//typedef int data;
typedef struct node
{
char data;
struct node* next;
}linklist;
/* method 1 insert node as first element */
linklist* CreateList1()
{
char ch;
linkl...
分类:
编程语言 时间:
2014-12-10 00:33:45
阅读次数:
224