Skip to content

LoaiWael/Python-ADTs-impelementation

Repository files navigation

Python-ADTs-impelementation

Python data structures implemented and tested by me ;D


Binary search

Stack

  • len(object) => stack object lenght
  • Iterator => loop on the stack
  • peek() => get the last element
  • push(element) => add element
  • pop(element) => remove and return the last element added

Set

  • len(object) => Set object lenght
  • Itrator => loop on the set
  • add(element) => add element
  • remove(element) => remove element
  • contains(element) => returns True if it have the element and False if not
  • equals(object: Set) => compare 2 sets and returns True if equal and False if not
  • subset_of(object: Set) => returns True if subset and False if not
  • union(object: Set) => returns a new set
  • intersect(object: Set) => returns a new set
  • difference(object: Set) => returns a new set

Map -> using BinarySearch.py

  • len(object) => Map object lenght
  • Itrator => loop on the map
  • add(key: int, *values) => if key is found it will overwrite it and its values, if not it will creat new one
  • append(key: int, *values) => if key is found it will append the values to it, if not it will creat one
  • remove_Key(key: int) => remove a key and its values
  • remove_Values(key: int, *values) => remove the key values included at the method only
  • values_Of(key: int) => return list of the key values

circularQueue

  • len(object) => Queue object lenght
  • Iterator => Loop over the queue
  • enqueue(element) => add element to the queue
  • dequeue() => Removes the front element
  • isEmpty() => Returns True if empty and False if not
  • isFull() => Returns True if it's full and False if not
  • clear() => Clears the queue || deletes all the elements
  • object.Get_numOfItems => property returns number of elements in the queue
  • object.Get_front => property returns the front element
  • object.Get_rear => property returns the rear element
  • object.Get_Available_Space => property returns the available space in the queue

circularDeque

  • len(object) => queue object lenght
  • Iterator => loop over the queue
  • insert_Left(element) => add element from the left side
  • insert_Right(element) => add element from the right side
  • remove_Left() => removes element from the left of queue
  • remove_Right() => removes element from the right of the queue
  • isEmpty() => Returns True if empty and False if not
  • isFull() => Returns True if it's full and False if not
  • clear() => Clears the deque || deletes all the elements in the queue
  • object.Get_numOfItems => property returns number of elements in the queue
  • object.Get_front => property returns the front element
  • object.Get_rear => property returns the rear element
  • object.Get_Available_Space => property returns the available space in the queue

linkedList

  • Iterator => loop over the list data
  • getSize => property gets to you the lenght of the list
  • isEmpty => property checks whether the list is empty or not
  • Clear() => clears the list
  • search() => searchs on an item and returns true if exists
  • insert(item, position: int) => inserts an item in its given posotion if the position exists
  • append(item) => put an item at the end of the list
  • remove(item) => removes an item from the list if exists
  • insertAtBegginning(item) => insert an item at the begginning of the list || same as insert(item, 0)

doubleLinkedList

  • Iterator => loop over the list data
  • len(object) => get the list lenght
  • isEmpty => property checks whether the list is empty or not
  • getFirst => property gets the head element or the one at the first
  • getLast => property gets the last element in the list
  • insertAtBeggin(data) => insert data at the first
  • insertAtEnd(data) => insert data at the end of the list
  • insert(data, posotion: int) => insert data at any position
  • deleteLast() => deletes only the last item
  • deleteFirst() => deletes only the first item
  • deleteData(data) => deletes the given data from the list

binarySearchTree

  • isEmpty => property checks if tree is empty or not
  • getRoot => property returns the root element
  • getMin => property returns the minimum number
  • getMax => property returns the maximum
  • insert(data) => inserts number to the tree
  • inOrderT(func=print) => looping over the tree in order for an action
  • preOrderT(func=print) => looping over the tree pre order for an action
  • postOrderT(func=print) => looping over the tree post order for an action
  • ---Deletion empelemintation was not available during my year 2025---

About

Python abstract data types implemented and tested

Topics

Resources

Stars

Watchers

Forks

Languages