0

Transitioning from C++ into web development and am curious about BST and data structures in general in AngularJS.

I would like to create a BST with a breadth-first search option. In C++, I'd create a node with a left and right pointer. Then use a queue to enqueue the root node, see if matches the desired value and if it does not, push the child elements and dequeue the root.

I am not really sure where to begin with this in JavaScript AngularJS, as there are no structs or pointers. When performing an $http.get() in AngularJS, I would like to store the data in a BST and search for items with BFS.

Can anyone suggest a starting place? Would using pure JavaScript to create a custom data structure be preferable?

Edit: changed "node" to "struct;" edited question header "AngularJS" to "JavaScript," as I now understand underlying data structures would be built in the base language and not the framework.

5
  • In almost all web contexts, you will never need to work with BSTs directly. For almost anything you do on web, there's a framework or library. My advice would be to research first, unless of course you're doing it for educational purposes. Commented Jun 28, 2015 at 8:15
  • Predominantly for educational purposes and coming up to speed with AngularJS. I know a hash map can be created and am curious about additional data structures. Perhaps if a BST is not available I can create one as a reusable component; might not be practical but it's fun. Commented Jun 28, 2015 at 8:20
  • 1
    Of course. AngularJS itself is a web framework, not a language. If you want to implement Data Structures, you will be doing those in JavaScript. Learning Angular will entail learning how to use the framework to build controllers, factories, services etc. Happy coding! Commented Jun 28, 2015 at 8:23
  • There are no nodes in C++ either ... Commented Jun 28, 2015 at 8:28
  • Thank you, this helped clarify the concept for me; it is the underlying language of the framework that is used to create data structures, not the framework itself. It seems like JS is what I was looking for: codereview.stackexchange.com/questions/31513/… ; nczonline.net/blog/2009/06/09/… Commented Jun 28, 2015 at 8:30

1 Answer 1

1

AngularJS is a mvc framework... has nothing to do with data structures.

So yeah you'll have to do it with pure js.

There are some libs that might make it easier see: https://lodash.com/docs and http://underscorejs.org/

Sign up to request clarification or add additional context in comments.

1 Comment

This makes sense now; as Spring is an MVC framework for Java and AngularJS is a framework for JavaScript, using the framework to create a data structure would not make sense. I'll look into pure JS and play around with creating a BST there. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.