This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import heapq | |
| class PriorityQueue: | |
| def __init__(self): | |
| self.items = [] | |
| self.count = 0 | |
| def enqueue(self, item, priority): | |
| heapq.heappush(self.items, (priority, self.count, item)) | |
| self.count += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "container/heap" | |
| type Item struct { | |
| value interface{} | |
| priority int | |
| index int | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import deque | |
| class Deque: | |
| def __init__(self): | |
| self.items = deque() | |
| def add_front(self, item): | |
| self.items.appendleft(item) | |
| def add_rear(self, item): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| type Deque struct { | |
| items []interface{} | |
| } | |
| func NewDeque() *Deque { | |
| return &Deque{ | |
| items: make([]interface{}, 0), | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node: | |
| def __init__(self, data): | |
| self.data = data | |
| self.next = None | |
| class SinglyLinkedList: | |
| def __init__(self): | |
| self.head = None | |
| def is_empty(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| type Node struct { | |
| data interface{} | |
| next *Node | |
| } | |
| type SinglyLinkedList struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node: | |
| def __init__(self, data): | |
| self.data = data | |
| self.prev = None | |
| self.next = None | |
| class DoublyLinkedList: | |
| def __init__(self): | |
| self.head = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| type Node struct { | |
| data interface{} | |
| prev *Node | |
| next *Node | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node: | |
| def __init__(self, data): | |
| self.data = data | |
| self.next = None | |
| class CircularLinkedList: | |
| def __init__(self): | |
| self.head = None | |
| def is_empty(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| type Node struct { | |
| data interface{} | |
| next *Node | |
| } | |
| type CircularLinkedList struct { |