具有資訊(意義)的資料,如被排序、被規劃/整理,這些被賦予意義的資料
int[] numbers = new int[] { 1, 2, 3, 4, 5 };
可參考 [DAY3] C#基礎與實作(Array)
List<string> names = new List<string>();
names.Add("Alice");
names.Add("Bob");
可參考 [DAY8] C#基礎與實作(List)
Dictionary<string, int> ages = new Dictionary<string, int>();
ages["Alice"] = 25;
ages["Bob"] = 30;
ages["Charlie"] = 22;
可參考 [DAY9] C#基礎與實作(Dictionary)
Queue<int> queue = new Queue<int>();
queue.Enqueue(1);
queue.Enqueue(2);
Stack<string> items = new Stack<string>();
items.Push("Item 1");
items.Push("Item 2");
LinkedList<int> linkedList = new LinkedList<int>();
linkedList.AddLast(1);
linkedList.AddLast(2);
linkedList.AddLast(3);
LinkedListNode<int> node = linkedList.Find(2);
linkedList.AddAfter(node, 4);
// 現在 linkedList 包含 1 -> 2 -> 4 -> 3
class Node
{
public int Value { get; set; }
public Node Next { get; set; }
}
class LinkedList
{
public Node Head { get; set; }
// 添加、刪除、搜尋等操作的方法
}
class TreeNode
{
public int Value { get; set; }
public TreeNode Left { get; set; }
public TreeNode Right { get; set; }
}
class TreeNode
{
public int Value;
public TreeNode Left;
public TreeNode Right;
public TreeNode(int value)
{
Value = value;
Left = null;
Right = null;
}
}
TreeNode root = new TreeNode(10);
root.Left = new TreeNode(5);
root.Right = new TreeNode(15);
root.Left.Left = new TreeNode(3);
using System;
using System.Collections.Generic;
Heap<int> minHeap = new Heap<int>(HeapType.Min);
minHeap.Insert(10);
minHeap.Insert(15);
minHeap.Insert(5);
int min = minHeap.ExtractTop(); // 取出最小值,這裡是 5
class Graph
{
private int V; // 節點數
private List<int>[] adj; // 鄰接串列
public Graph(int v)
{
V = v;
adj = new List<int>[v];
for (int i = 0; i < v; ++i)
adj[i] = new List<int>();
}
public void AddEdge(int v, int w)
{
adj[v].Add(w);
adj[w].Add(v); // 無向圖需加入雙向邊
}
}
Graph graph = new Graph(4);
graph.AddEdge(0, 1);
graph.AddEdge(0, 2);
graph.AddEdge(1, 2);
graph.AddEdge(2, 3);
期望挑戰30天持續更新成功 ~ DAY20