Pheww....we all would have read this topics a lot of time.
But still with every new question, we get something new to work with.
I think Algorithms and Data Structures increase human Intelligence, because everytime you get a new way to solve some problem.
Now whenever you are coding next time, please pay attention to below topics.
1) Space complexity of your algorithm
> rather than how much size is needed, focus on how you can reduce the size which is currently used.
i.e Can you change the DATA STRUTURE you are using to store things.
Ex: 1) A lot of people uses matrix array to solve graph problem, even though adjacency list might be better choice.
2) When sorting data, a lot of people creates duplicate of original data given, which sometimes is not necessary.
Or take an example, that you have string array and you have to sort it, but have to keep original data also.
In that case, rather than having two STRING array, just have one string array, and create a STRING position array to keep original string places, in this case you have INT array, rather than STRING array solving the same thing.
2) Time complexity of your algorithm
> For this you need to focus on
1) Standard algorithm used for that type of problem.
2) Type of data structure used, when you have space vs time constraint.
3) Try to use more maths.
> Standard formulas, SET theory, Matrix property : If you know what happens when you run transpose on matrix, or union of two sets. You will have better ALGORITHMS and it will be easy to prove them.
4) COMPUTER STORAGE: Many of use when coding write program as we are writing on piece of paper. But we have to understand how our data is saved in computer. Ex : How many bits , whether INTEGER will be converted to CHAR easily.
This way you can use bitwise operation and other properties to get faster ALGORITHMS.
Also amount of DATA storage can be reduced
Thinking about these points everytime you code , will help in getting better solution
No comments:
Post a Comment