Discover Packages
github.com/golark/algos
linkedlist
package
Version:
v0.0.0-...-d6c755d
Opens a new window with list of versions in this module.
Published: Jun 28, 2022
License: Apache-2.0
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
Documentation
¶
Display
display linked list contents
func NewLinkedList(data []interface{}) *node
NewLinkedList
factory function
func RemoveKthNodeToTail(head *node, K int ) (*node, error )
RemoveKthNodeToTail
remove k'th node before tail
traverse through the linkedlist with 2 pointers to find k-1'th node
then remove the node by manipulating the pointers
O(n) time and O(1) space
func Reverse(head *node) *node
Reverse
inplace reversal
traverse through one time and reverse
returns new head
O(n) time, O(1) space
func Size(head *node) int
Size
returns the Size of the linkedlist
O(n) time, O(1) space
Source Files
¶
Click to show internal directories.
Click to hide internal directories.