@@ -662,44 +662,54 @@ The result of the worst case time complexities are as follow:
662662
663663| Implementation | Insert | Lookup | Delete | Verify Deletion |
664664| -------------- | -------- | --------: | -------: | ----------------: |
665- | List | 0 (n) | 0 (n^2) | 0 (n^2) | 0 (n^2) |
666- | Set | 0 (n) | 0 (n) | 0 (n) | 0 (n) |
665+ | List | $O (n)$ | $O (n^2)$ | $O (n^2)$ | $O (n^2)$ |
666+ | Set | $O (n)$ | $O (n)$ | $O (n)$ | $O (n)$ |
667667
668668: Worst case time complexities for all operations and implementations studied in this experiment. {.responsive}
669669
670670## Insert
671- - Set remains at 0(n).
672- - List is also 0(n) as it is appending at the end.
673- - Even though both are at 0(n), List is comparatively a lot faster than set at pure appending hence it is faster than set.
671+ - Set remains at $O(n)$.
672+ - List is also $O(n)$ as it is appending at the end.
673+ - Even though both are at $O(n)$, List is comparatively a lot faster than set at
674+ pure appending hence it is faster than set.
674675
675676## Lookup
676- - Set remains at 0(n)
677- - List provide time complexity of 0(n^2) when doubling the list size.
678- - Set is faster constantly for the both small and large data sizes compared to list.
677+ - Set remains at $O(n)$
678+ - List provide time complexity of $O(n^2)$ when doubling the list size.
679+ - Set is faster constantly for the both small and large data sizes compared to
680+ list.
679681
680682## Delete
681- - Set remains at 0(n).
682- - List provides time complexity of 0(n^2).
683- - For the smaller data both are almost similar for the deletion but as the data increases the list falls behind due to the shifting.
683+ - Set remains at $O(n)$.
684+ - List provides time complexity of $O(n^2)$.
685+ - For the smaller data both are almost similar for the deletion but as the data
686+ increases the list falls behind due to the shifting.
684687
685688## Verify Deletion
686- - Set remains at 0(n).
687- - List provide time complexity of 0(n^2).
688- - Set is faster constantly for the both small and large data sizes compared to list.
689+ - Set remains at $O(n)$.
690+ - List provide time complexity of $O(n^2)$.
691+ - Set is faster constantly for the both small and large data sizes compared to
692+ list.
689693
690694## Conclusion
691695
692- Set is demonstrably faster than list because it uses a hash table while lists use dynamic arrays. Other than append(insert)
693- which is 0(n) due to python geometrically growing capacity, List must look at every element or need to shift for other
694- operations which results in 0(n^2).
695- - If you need fast, random insert, delete and lookup of vertices or edges use ** Set** .
696- - If you truly just need to build up nodes or neighbors and then walk them sequentially use ** List** .
696+ Set is demonstrably faster than list because it uses a hash table while lists
697+ use dynamic arrays. Other than ` append ` and ` insert ` , which is $O(n)$ due to
698+ Python's geometrically growing capacity, ` List ` must look at every element or
699+ need to shift for other operations which results in $O(n^2)$.
700+
701+ - If you need fast, random insert, delete and lookup of vertices or edges use
702+ ** Set** .
703+ - If you truly just need to build up nodes or neighbors and then walk them
704+ sequentially use ** List** .
697705
698706# Next Steps
699707
700- Potential next steps could be testing the limits of the set and list approaches, or seeing the largest number of verticies they
701- can handle. Also, considering that this experiment is implemented with a tree structure to avoid cycles, another next step
702- could be trying to implement the same thing with a graph structure and cycle detection.
708+ Potential next steps could be testing the limits of the set and list approaches,
709+ or seeing the largest number of vertices they can handle. Also, considering that
710+ this experiment is implemented with a tree structure to avoid cycles, another
711+ next step could be trying to implement the same thing with a graph structure and
712+ cycle detection.
703713
704714# References
705715
0 commit comments