Skip to content

Conversation

@rawrrawrpurpledinosaur
Copy link

Added optimized bubble sort, thought it might be relevant
Added json file reading, used frequently in NoSQL questions where contents of a json file is uploaded to a MongoDB database.

@DenseLance
Copy link
Owner

I will leave the pull request as it is instead of making it a permanent commit, as the content may be beneficial to some.

The optimized bubble sort can be faster than the original version empirically, but we all know that it will never beat the allegations for O(n^2) average time complexity. As for file operations, while it is true that the context manager helps with the closing of files ever since a certain Python version, I included f.close() anyways for better code readability and it's probably better to include that statement especially during examinations. The json file reading is a good add, though I would appreciate if you could pretty print the output.

@DenseLance
Copy link
Owner

I will leave the pull request as it is instead of making it a permanent commit, as the content may be beneficial to some.

The optimized bubble sort can be faster than the original version empirically, but we all know that it will never beat the allegations for O(n^2) average time complexity. As for file operations, while it is true that the context manager helps with the closing of files ever since a certain Python version, I included f.close() anyways for better code readability and it's probably better to include that statement especially during examinations. The json file reading is a good add, though I would appreciate if you could pretty print the output.

I just did a small check on my repo, and found that 10 NoSQL.py already contains code on how to read json files. Your code on pretty print will be helpful though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants