algorithm-exercise

https://github.com/billryan/algorithm-exercise

Part I - Basics

Basic Data Structure

string:

s2 = "shaunwei" 

s2.index('w') # return 5, if not found, throwValueError
s2.find('w') # return 5, if not found, return -1

linked list:

线性表有两钟结构:

顺序表 顺序存储结构(数组)、链表,链式存储结构

1.顺序表,顺序存储结构的线性表.

  特性是随机读取,也就是访问单个元素的时间复杂度是O(1)。

2.链表,链式存储的线性表。

  链式存储结构:就是两个相邻的元素在内存中可能不是相邻的,使用指针操作。

  优点是定点插入和定点删除的时间复杂度为 O(1),不会浪费太多内存,添加元素的时候才会申请内存,删除元素会释放内存。缺点是访问的时间复杂度最坏为O(n)。

原文地址:https://www.cnblogs.com/IDRI/p/6440356.html