How do I implement actionBarSherlock?

"How can I implement Graph/Tree algorithms in java ?"

  • I can implement all the algorithms like DFS/BFS/Dijkstra and can implement data structures like BST, AVL, RB Tree in C. But I donot know how to implement them using "Java"  as there are  no pointers available or Am I missing something ? I want to implement them from scratch even if these are already implemented.

  • Answer:

    Java object references are the equivalent of pointers. For example, a binary tree might have a node structure like this: class Node<T> { T value; Node<T> left; Node<T> right; } (If they don't teach parameterized types in your class... then boo on them. Just omit <T> and use Object value instead.)

Joshua Engel at Quora Visit the source

Was this solution helpful to you?

Other answers

If you are able to implement something in C you should be able to implement in Java as well. The only reason I can think of why you are not able to do it is due to lack of sufficient knowledge of the java language. You don't have pointers available in Java but all objects are accessed by references so you could create self referential structures in java as well.   Look at these codes to see how the self referential data structures are coded BST - http://algs4.cs.princeton.edu/32bst/BST.java.html Red Black Trees - http://algs4.cs.princeton.edu/33balanced/RedBlackBST.java.html Further have a look at http://algs4.cs.princeton.edu/code/ this page has most of the standard algorithms implemented in Java if while implementing you are stuck at some point you can refer to their implementation and try to re implement on your own with out seeing it.

Praveen Reddy Vaka

A detailed explanation about graphs, trees and their representations including Java code is available at http://sadakurapati.wordpress.com/2014/01/06/graph-tree-algorithms/

Sada Kurapati

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.