This project is an implementation of the List Abstract Data Type (ADT) using an AVL Tree as the underlying data structure. The AVL Tree provides a balanced binary search tree that ensures O(log n) time complexity for all the operations on the List.
empty
: Check if the List is emptyretrieve
: Retrieve an element at a given position in the Listinsert
: Insert an element into the List at a given positiondelete
: Delete an element from the List at a given positionfirst
: Retrieve the first element in the Listlast
: Retrieve the last element in the ListlistToArray
: Convert the List to an arraylength
: Get the length of the Listsplit
: Split the List into two separate Listsconcat
: Concatenate two Lists togethersearch
: Search for an element in the List
- Python 3.x
- Clone the project repository from GitHub:
git clone https://github.com/BourshanDor/DS.git
- Import the AVLTreeList class from the AVLTreeList.py file in your Python code.
- Create a new AVLTreeList object.
- Use the available methods to perform operations on the List.
Here's an example code snippet for using the AVLTreeList:
from avl_tree_list import AVLTreeList
# Declare a new AVLTreeList object
list = AVLTreeList()
# Insert elements into the List
list.insert(10)
list.insert(20)
list.insert(30)
# Delete an element from the List
list.delete(20)
# Get the first and last elements in the List
print("First element: ", list.first())
print("Last element: ", list.last())
# Convert the List to an array
arr = list.listToArray()
print("Array representation of List: ", arr)
- Jonathan Yahav
- Dor Bourshan