r/javahelp • • Jan 06 '21

Algorithm in Java Spring

I am Java self-taught, I just learned algorithms and spring framework. I want to master web programming using Java. I am still a student, I have never participated in real projects so I have many questions I want to be answered. I would be more than happy to receive an answer from someone.

-In Java Spring practical projects, algorithms such as recursion, backtracking, BFS, DFS, binary tree search, etc are used and used a lot? When Spring Data JPA has a search function, are search algorithms such as binary tree search, BFS, DFS, etc important and used?

- Between the algorithm and the framework, which one should I learn more deeply?

Hope someone will answer these of my problems. Thanks very much

21 Upvotes

11 comments sorted by

View all comments

1

u/sweetno Jan 06 '21

It depends on what's the problem domain. The damning majority of problems in web development, whether they use any advanced algorithms or not, have already been solved, so it's uncommon to write algo code for such projects.

However, if you develop something that is conceptually new, knowing algorithms and data structures will decide who wins the competition.

1

u/dastardly740 Jan 07 '21

Also, understanding time complexity analysis (i.e. Oh of) can be a good thing. So, when you find out that a Java LinkedList get(int index) has to traverse the list to get to the element. You don't do this...

for(int i == 0; i < mylist.size(); i++) {
    Object item = mylist(i);
    item.doSomething();
}

O(n2) use an ArrayList if you really need to do that...

Of course the right way because we should program to interfaces and not implementations, so your code shouldn't know what kind of List it is working on...

for(Object item : mylist) {
   item.doSomething();
}

O(n)