MShafquat's blog

By MShafquat, history, 5 years ago, In English

I was solving a problem on SPOJ which says to count inversions. It can be solved using BIT or Merge Sort algorithm. I searched the topic on the internet, I found a page on Geeksforgeeks with exactly the same problem. So I try to understand it, but after a while I could not get much of it. So I copied those functions and used it directly in my solution. But I started feeling guilty. I am interested to know how you guys learn an algorithm. This is my first blog post, so please ignore if I made any mistakes and help me. Thank you. ^_^

  • Vote: I like it
  • +36
  • Vote: I do not like it

»
5 years ago, # |
  Vote: I like it +84 Vote: I do not like it

At least try to type the algorithms you learn instead of copying. Also, don't force yourself into getting AC for problems that might be too hard for you :)

»
5 years ago, # |
  Vote: I like it +58 Vote: I do not like it

From a practical perspective, it really depends. For certain data structures like Segment trees or algorithms like Dijkstra's, you'll often be required to modify them, so it's important to understand.

On the other hand, you could probably get around fine without understanding the details of how a flow algorithm or FFT work. Note that many of these algorithms that you can black box are mostly more advanced algorithms.

»
5 years ago, # |
  Vote: I like it +8 Vote: I do not like it

It does work pretty well for 'small' algorithms like, for example, GCD or sorting. But when you use more complex algorithms like, for example, Dinic or Hungarian, it is difficult to 'remember' the implementation in a real contest if you have know idea how it works.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    If anyone is re-implementing something like Hungarian algorithm or Voronoi diagram from scratch in a contest.... orz