Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stoverc/datastructuresandalgorithms
From-scratch attempts at implementing some common data structures and algorithms.
https://github.com/stoverc/datastructuresandalgorithms
algorithm algorithms core-language cpp data-structures data-structures-algorithms data-structures-and-algorithms datastructures java linked-list python study-guide
Last synced: 3 days ago
JSON representation
From-scratch attempts at implementing some common data structures and algorithms.
- Host: GitHub
- URL: https://github.com/stoverc/datastructuresandalgorithms
- Owner: stoverc
- Created: 2022-07-23T06:13:19.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-05T20:29:37.000Z (over 1 year ago)
- Last Synced: 2023-07-06T07:46:43.379Z (over 1 year ago)
- Topics: algorithm, algorithms, core-language, cpp, data-structures, data-structures-algorithms, data-structures-and-algorithms, datastructures, java, linked-list, python, study-guide
- Language: C++
- Homepage:
- Size: 4.4 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Data Structures and Algorithms
From-scratch attempts at implementing some common data structures and algorithms.
Currently, this repo contains (both bug-free and buggy) versions of code I've written to try to get a better understanding of the under-the-hood inner workings of various data structures.
As of this writing (23 July 2022), most of the code is in `Python3`, though some `Java` and `C++` updates have started to creep in as well. Future iterations will include more `Java` and `C++` code, and perhaps some other languages as well. **Update:** Due to some changes in circumstance, `C++` may become the main focal point of my contributions; we shall see.As of 3 July 2022, a study guide has also made its way into the repo. This study guide is `LaTeX`'ed and is intended to help guide my studies + document the journey so far. **Update:** Later, I removed the `TeX` source code from the repo so that the code percentages would better reflect my _real_ contributions rather than showing a repo with 80% `TeX` code!
## TODO:
* Consider returning pointer-type variables in data structures where "actual return" of a variable is impossible (see `stack` in CPP).
* Use [this link](https://stackoverflow.com/questions/68055899/concatenating-two-linked-lists-using-operator-overloading-c) to concert `Concatenate(...)` functionality into operator overloading in `LinkedList.cpp` file.
* Incorporate more headers for new `LinkedList.cpp` file.
* Work on porting the old `C++` singly linked list + doubly linked list algorithms to the new `LinkedList.cpp` implementation.
* Make sure `C++` files adhere to best practices re: [Rule of Three/Five/Zero](https://en.cppreference.com/w/cpp/language/rule_of_three) and [RAII](https://en.cppreference.com/w/cpp/language/raii).
* Continue adding to `SparseMatrixStruct.cpp` and `SparseMatrix.cpp` (include subtraction; possibly multiplication?).
* Get all the `Python` code translated in to `C++` (!!!) and `Java` (as time permits).
* Translate `Array` ADT from `C++` to `Python` and `Java`.
* Get study guide source re-added so I can work on it elsewhere.
* Keep working on the study guide.Changelog
5 Jul 2023
- Reorganization of Trees, Tries, and Hybrid Trees in the study guide.
- Later, more fleshing out of study guide subsections on trees and substructures.
26 Jun 2023
- Edited the study guide to include more information about queues and related structures.
- Made several other study guide changes/commits throughout the day.
23 Jun 2023
- Edited the study guide to include more information about queues + to better delineate the subsections of the stack and queue topics.
21 Jun 2023
- In array-based
stack.cpp
: Made changes toPeek()
.
- Later, made initial commits of
Node.h
,LinkedList.h
, andstack.cpp
forLinkedList
-based stack.
- Made changes to
Display()
functions in bothLinkedList.h
andLinkedList
-basedstack.cpp
.
- Later, made changes to
Peek(int index)
inLinkedList
-basedstack.cpp
to ensure that"Invalid Position!"
prints wheneverindex
is greater thantop+1
.21 Jun 2023
- Initial commit of array-based
stack.cpp
in CPP.
- Added
Pop()
functionality to stack.
- After some time weighing how to handle the Stack underflow! situation, changed
Pop()
to return pointer type variable.
- After learning that Stack underflow! resulted in seg fault in VSCode, I decided to undo the above change for the time being.
- Later, Added
Peek(...)
,IsEmpty()
, andIsFull()
.
14 Jun 2023
- Updated the study guide some restructuring re: Stacks, Queues, etc.
13 Jun 2023
- Added
Middle()
support toLinkedList.cpp
.
- Later, updated the study guide with details related to linked lists, variants of linked lists, and linked lists versus arrays.
9 Jun 2023
- In
LinkedList.cpp
: AddedAppend(...)
functionality, which should have been here a long time ago.
- After much back-and-forth, added
Concatenate(...)
functionality. Later, this will come in the form of an overloaded operator.
- Later, refactored (old)
Concatenate(...)
into (renamed)Join(...)
and (new) (void
)Concatenate(...)
.8 Jun 2023
- In
LinkedList.cpp
: Added new example +SortedQ()
.
- Later, added
DeleteDuplicates()
inLinkedList.cpp
.
- Eventually, swapped order of parameters for
Insert(...)
to better match what happens in theArray
ADT.
- Added
Reverse()
functionality toLinkedList.cpp
.
- From home: Renamed
/Okay/
to/Working/
.7 Jun 2023
- Added
Display()
toLinkedList.cpp
.
- Later, added
Length()
,Sum()
,Min()
, andMax()
toLinkedList.cpp
.
- Added
Insert(...)
toLinkedList.cpp
.
- Later, added
Delete(...)
toLinkedList.cpp
, and later, made a small edit toDelete(...)
.
- At home, moved
CPP/SinglyLinkedList/
andCPP/DoublyLinkedList
to/Obsolete/CPP/
per inclusion of new/LinkedList/
files.6 Jun 2023
- Changed
LinkedList.cpp
to havehead
as a pointer + percolated the associated method changes throughout.
- Changed the name of old-
LinkedList.cpp
file toLinkedListLegacy.cpp
.31 May 2023
- Initial commit of
Node.h
andLinkedList.cpp
; the particulars of this were written last week but uncommitted.26 May 2023
- Updated the study guide.
24 May 2023
- Initial commit of
SparseMatrix.h
andSparseMatrixNew
, featuring hard-codedint
-type dataElement.x
. I'm still trying to figure out the intricacies of the templating for non-integer types.
- Later, deleted those two files to try to figure out stuff.
- After much work + help on Stack Overflow: Got
SparseMatrix.cpp
to work with generics / templating. I'm an idiot for not considering forward-declaration as a solution sooner; forward-declaration literally solved one of myArray.h
problems the other day!
- Split
SparseMatrix.cpp
intoElement.h
andSparseMatrix.h
.23 May 2023
- Initial commit of
SparseMatrixStruct.cpp
.
- Later, added
Add()
functionality toSparseMatrixStruct.cpp
.
- Uploaded initial commit of
SparseMatrix.cpp
, which usesclass
es instead ofstruct
s.
- Later: Swapped
Read()
andDisplay()
for overloadedcin
andcout
.
- Even later: Implemented old
Add()
as customSparseMatrix::operator+
operator.22 May 2023
- In
LowerTriangularMatrix.cpp
: Revamped loops to start ati=1
andj=1
.
- Later, initial commit of
UpperTriangularMatrix.h
andUpperTriangularMatrix.cpp
using row-major mapping.
- Used
LowerTriangularMatrix*
to build initial commit ofSymmetricMatrix*
---and later,TridiagonalMatrix*
---files.
- Fixed bug in
ShortPrint()
forSymmetricMatrix.cpp
.
- Later, fixed indexing bug in
TridiagonalMatrix.cpp
and fixed typo inREADME
.
- Even later: Initial commit of
ToeplitzMatrix.h
andToeplitzMatrix.cpp
.18 May 2023
- Added destructor to Array ADT in
C++
.
- Created
CPP/Matrices
directory + added initial commit ofDiagonalMatrix
files (.cpp
and.h
).
- Later, created
C++
filesLowerTriangularMatrix.h
andLowerTriangularMatrix.cpp
using row-major mapping.
- Improved commenting in
Array.h
,DiagonalMatrix.cpp
, andLowerTriangularMatrix.cpp
.
- Added a driver to
LowerTriangularMatrix.cpp
to allow for entering a whole matrix all at once.16 May 2023
- In
C++
Array ADT: Added Setters, in part to allow thepublic
T* A
to become private.
- Later, declared
Union2
as afriend
function to allow access to private member variables.
- Added better commenting to show the breakdown of functions throughout code.
- Later, moved legacy functions to
ArrayLegacy.cpp
and renamedUnion2
andUnion3
both asUnion
.
- Also: Implemented
friend
versions ofIntersection
andComplement
.
- Later still: Changed a number of dereferencing operations to
->
s.
- Also, added
Intersection
,Complement
member functions.15 May 2023
- In
C++
Array ADT: Added functionality forIntersection
andComplement
.
- Later, simplified
Intersection
algorithm and changed the existing algorithm toLegacyIntersection
for posterity.
- Eventually figured out a non-
Void
version ofUnion
inC++
Array ADT. This will be fleshed out more soon.
- Mimicked non-member
Union2
code into member functionUnion3
.12 May 2023
- Made some small code tweaks to the Array ADT in
C++
, and later, added support forContains
and(Unsorted) Union
.11 May 2023
- To Array ADT in
C++
: AddedGet
,Set
,Sum
,Avg
,Max
, andMin
.
- Later, rewrote some code in a clearer manner + deleted some commented-out code in
C++
Array ADT.
- In Array ADT
C++
files: AddedReverse
,LeftShift
,LeftRotate
,RightShift
,RightRotate
.
- Added functionality in Array ADT for
SortedInsert
,IsSorted
, andPosNegSwap
.
- Later, improved incapsulation in Array ADT by making member vars private + adding getters.
10 May 2023
- Committed initial version of Array ADT in
C++
(both.cpp
and.h
files).
- Later, fixed up some pointer-related things in Array ADT.
19 Aug 2022
- Made some small edits to linked list in
C++
- Completed doubly linked list in
C++
with generics.14 Aug 2022
- Completed singly linked list in
C++
with generics.
- Learned more about pointers, but still need additional refresher.
12 Aug 2022
- Started working on singly linked lists in
C++
.
- In so doing, realized I have a lot to (re-)learn (for the 17th time) about pointers.
10 Aug 2022
- Got a 0th draft of hash sets working in
C++
. To get this working, I had to abandon my aspirations for generic types and just stick with integers. Generic types will come soon! ::crosses fingers::
- Later, added working(!!!) generics to
C++
hash sets.
- Also, removed references to
this->*
, as that doesn't appear to be veryC++
-like? :shrug:23 Jul 2022
- Decided to try my hand at hash sets in
C++
after having not writtenC++
code in 15 years. It did not go well!
- Made some small tweaks to the
Java
Hash Map file.
- Edited the README and the .gitignore files.
- Later, removed some of the
Python
test code so the GitHub calculator thing gets the language percentages more accurate.16 Jul 2022
- Filled in the
Stacks and Queues
section of the study guide.
- Also, added in the
Stack
andQueue
rows of the first-page complexity table.12 Jul 2022
- Made a few small edits to the study guide.
- Also, added a section for
Stacks and Queues
+ filled in the subsections a bit before bedtime.9 Jul 2022
- Made some complexity-related edits to the study guide.
8 Jul 2022
- Renamed the repo to include common algorithms. Will ultimately restructure the directories as well.
- Later, restructured all subdirectories.
- Much later, wrote + uploaded initial versions of
SelectionSort
for bothPython3
andJava
.
Both versions include the algorithm, as well as a
SelectionSortAnalysis
method/function which shows how the number of steps grows as the size of the input array doubles.
What I reallllllly want to show is how time increases, not code count. I'll do some digging into that soon and try to implement ASAP.
- Much later still, updated the study guide pretty heavily, including uses of newly-included images and a new .gitignore file.
7 Jul 2022
- Big changes to the study guide, including:
Data Structures and Search Algorithms main sections.
- A full-populated and linked search algorithm complexity table.
- A fully-written section on Selection Sort (plus a lot of dummy text for other sort algorithms).
6 Jul 2022
- First upload of a Java version (
HashSet
) plus a general restructuring of directory structure + a revamped.gitignore
file.4 Jul 2022
- I added some details to the study guide, and implemented BFS to the
BST.py
file. Next up, I plan to implement some deletion methods, and possibly to adapt some BST-implemented methods to code a less-specific brand of tree.3 Jul 2022
- I'm keeping a study guide to go along with my explorations into these data structures/algorithms. I decided it was a good idea to upload the related .tex, .sty, and .pdf files.
- Later, added BST information to both
Okay
directory (in Python3) and study guide.27 Jun 2022
- Used some snippets from this answer to prototype a redo of SinglyLinkedList. This code + the code in the accepted comment contained >= 2 very serious bugs and needed quite a bit of plussing up, so I did that plus thoroughly documented everything before **finally** reaching the level of "accepted LeetCode answer."
26 Jun 2022
- Initial upload.
- Later, updated the README.md file to its current state.
- Approximately 22 hours later, attempted to use the GeeksForGeeks solution as an inspiration for a new implementation of SinglyLinkedList, only to find that this one times out on LeetCode. I think my best plan of action moving forward will be to try a whole new implementation; I have some ideas!