swift로 우선순위 큐를 구현했습니다. /* base on : Array, binary Tree */ class PriorityQueue{ private var elements: [T] = [] private let compare: (T, T) -> Bool var top: T?{elements.first} var isEmpty: Bool{elements.isEmpty} var count: Int{elements.count} init(){ compare = {$0 Bool){ self.compare = compare // 정렬 기준을 받아서 덮어쓰기 } func pus..
https://en.wikipedia.org/wiki/Doubly_linked_list Doubly linked list - Wikipedia From Wikipedia, the free encyclopedia Linked list data structure In computer science, a doubly linked list is a linked data structure that consists of a set of sequentially linked records called nodes. Each node contains three fields: two link fields (refe en.wikipedia.org 위키피디아에서 어떤 메소드를 갖고 있어야 하며, 어떤 프로퍼티가 있는지만 확인하..
저번에 이어서 이번에는 queue 구현 코드이다. class Queue{ private var backStack = Stack() private var frontStack = Stack() var isEmpty : Bool{ return backStack.isEmpty && frontStack.isEmpty } var front : Any?{ guard backStack.isEmpty || frontStack.isEmpty else {return nil} if !frontStack.isEmpty {return frontStack.top} while !backStack.isEmpty { if let top = backStack.pop() { frontStack.push(top) } } return fron..