雙向鍊結串列
<!DOCTYPE >
<html lang="zh-TW">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>List 雙向鍊結</title>
<meta name="description" content="" />
<meta name="author" content="hua" />
<style>
</style>
</head>
<body>
<input type="button" value="建立時間比較" id="btn1"/>
<input type="button" value="移除時間比較" id="btn2"/>
<!--
一開始設計在Node中有 index 屬性
但很明顯的在從最前端移除後,要對每一個節點從算index
如此很耗效能
於似乎思考,java的鍊結串列也有index可是效能很好怎麼做到的.
於是想到,node根本不需要Index,index只是用來做拜訪node的條件.
因此在重新修改一次
-->
<script type="text/javascript">
(function(window){
function getList(){
function List(){
var firstNode=null;
var lastNode=null;
var count=0;
var getNode = function(leftNode, rightNode, val){
return{
'left':leftNode,
'right':rightNode,
'value':val,
'destory':function(){
this.left = null;
this.right = null;
this.value = null;
}
};
}
2014年1月13日 星期一
2013年12月8日 星期日
insertion sort
插入排序 insertion sort
Worst case performance :О(n2) comparisons, swaps
Best case performance :O(n) comparisons, O(1) swaps
Average case performance: О(n2) comparisons, swaps
Worst case space complexity: О(n) total, O(1) auxiliary
參考資料:
Worst case performance :О(n2) comparisons, swaps
Best case performance :O(n) comparisons, O(1) swaps
Average case performance: О(n2) comparisons, swaps
Worst case space complexity: О(n) total, O(1) auxiliary
參考資料:
Bubble Sort
氣泡排序 (Bubble Sort)
參考資料:維基百科 bubble sort
最差時間複雜度 (Worst case performance): O(n^2)
最佳時間複雜度 (Best case performance): O(n)
平均時間複雜度 (Average case performance):O(n^2)
最差空間複雜度 (Worst case space complexity): O(1) auxiliary
參考資料:維基百科 bubble sort
最差時間複雜度 (Worst case performance): O(n^2)
最佳時間複雜度 (Best case performance): O(n)
平均時間複雜度 (Average case performance):O(n^2)
最差空間複雜度 (Worst case space complexity): O(1) auxiliary
2013年12月3日 星期二
訂閱:
文章 (Atom)