总结
1.视频资源P14-P17:
https://www.bilibili.com/video/BV1gE41157pC?p=8&spm_id_from=pageDriver
2.学习内容:
1)栈与队列 P14;
数据结构:栈部分
2)数组栈 P15;
3)链表栈 P16;
4)数组栈与链表栈性能对比 P17。
3.2021/10/11回溯:
紫色红色笔均为回溯后增加
1)根据伪代码编写程序。
具体内容
P14 栈
1、什么是栈;
2、栈的应用。
P15 数组栈
1、栈通用接口;
2、创建数组栈类。
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApp1
{
class Array1Stack<E>:IStack<E>
{
private Array1<E> array1stack;
public Array1Stack(int capacity)
{
array1stack = new Array1<E>(capacity);
}
public Array1Stack()
{
array1stack = new Array1<E>();
}
public int Count { get { return array1stack.Count;} }
public bool IsEmpty { get { return array1stack.IsEmpty; } }
public E Peek()
{
return array1stack.GetLast();
}
public E Pop()
{
return array1stack.RemoveAtLast();
}
public void Push(E e)
{
array1stack.InsertAtLast(e);
}
public override string ToString()
{
return "Stack: " + array1stack.ToString() + "top";
}
}
}
P16 链表栈
1、创建链表栈类。
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApp1
{
class Linklist1Stack<E>:IStack<E>
{
private Linkedlist1<E> linkedlist1stack;
public Linklist1Stack()
{
linkedlist1stack = new Linkedlist1<E>();
}
public int Count { get { return linkedlist1stack.Count; } }
public bool IsEmpty { get { return linkedlist1stack.IsEmpty; } }
public E Peek()
{
return linkedlist1stack.GetFirst();
}
public E Pop()
{
return linkedlist1stack.RemoveAtFirst();
}
public void Push(E e)
{
linkedlist1stack.InsertFirst(e);
}
public override string ToString()
{
return "Stack: top " + linkedlist1stack.ToString();
}
}
}
P17 数组栈与链表栈性能分析
1、数组栈与链表栈时间复杂度理论分析;
2、数组栈与链表栈时间复杂度实际分析。