Skip to content

Implementations of Data Structures and Algorithms in Python

Notifications You must be signed in to change notification settings

psitronic/small-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data Structures and Algorithms

Implementations of Data Structures and Algorithms in Python

  • A basic building block for the linked list implementation. Each node contains the list element and pointer - a reference to the next node. It is implemented as a class with the setters and getters to access and modify the element and the pointer:

    • get_value() is a getter which returns the element value.
    • get_pointer() is a getter which returns the pointer to the next node (next element) in the list.
    • set_pointer(pointer) is a setter which sets the pointer for the current node to the next node.

  • A singly linked list is a collection of nodes where each node points to the next node. The implemented list operations:

    • LinkedList() creates a new empty list.
    • add(element) adds a new element to the list.
    • append(element) adds a new element to the end of the list making it the last element in the list
    • delete(element) removes an element from the list.
    • index(element) returns a position of the element in the list.
    • insert(index, element) adds a new element to the list at position index.
    • is_empty checks whether the list is empty.
    • pop() removes and returns the rear (last) element in the list.
    • pop(index) removes and returns the element at the index postion in the list.
    • search(element) searches for the element in the linked list.
    • size() returns the number of elements in the list
    • __str__() returns a string representation of the list.

About

Implementations of Data Structures and Algorithms in Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages