Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node[T any] struct { // contains filtered or unexported fields }
Node represents a single node in linked list representation.
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
Queue like Stack, is also an abstract data structure. The thing that makes queue different from stack is that a queue is open at both its ends. Hence, it follows FIFO (First-In-First-Out) structure, i.e. the data item inserted first will also be accessed first. The data is inserted into the queue through one end and deleted from it using the other end.
func (*Queue[T]) DeQueue ¶
DeQueue is a data manipulation operation that removes an element from the queue and returns it. If the queue is empty, it sets error.
func (*Queue[T]) EnQueue ¶
func (q *Queue[T]) EnQueue(data T)
EnQueue is a data manipulation operation that inserts an element into the queue.
func (*Queue[T]) Front ¶
func (q *Queue[T]) Front() T
Front returns the front node in the queue, w/o deleting it. If Queue is empty, then it will return nil.
type Stack ¶
type Stack[T any] struct { // contains filtered or unexported fields }
Stack represents the abstract data structure stack. It uses linked list representation to maintain the stack.
func (*Stack[T]) IsEmpty ¶
IsEmpty checks if the stack is empty or not. This is called when performing any of Push, Pop and Display operations.
type TraversalType ¶
type TraversalType int
const ( PreOrder TraversalType = iota InOrder PostOrder )
type Tree ¶
func NewBinaryTree ¶
NewBinaryTree creates an empty tree.
func (*Tree[T]) Traverse ¶
func (t *Tree[T]) Traverse(tType TraversalType)
Traverse prints the tree data based on TraversalType.