Linked lists and custom objects?

Do you think that linked lists and custom objects are perhaps easier to use for the solutions in some of the challanges?

I haven’t seen yet any data-structure lesson on freecodecamp. Maybe i missed it. But was curious if any of you used custom objects / binary trees [or others] / linked lists, or cthulhu knows what else, to finish their challange. If so, for which challanges?

I was considering using some of these, but wasn’t sure what’s quicker to finish a challange with.

I would highly recommend the first 6 weeks of CS50 if you’re interested in learning about data structures, the rest of the course deals with web technologies and you can safely skip.

Using a linked list in really high level languages like javascript isn’t always efficient because the language itself already has a natural implementation of these structures behind the scenes. I know Python uses hashes by default for example, most arrays that you use in really-high-level languages are linked lists by default, especially when you can use multiple data types in a single array.

Searching algorithms are always useful, but i can’t remember if there is any challenge on FCC that asks you to search for strings or something like that. Either way, as previously mentioned, efficiency is not something to really worry about for small exercises, i don’t think the idea behind FCC is to focus on that, at least for now.

There are other sites with challenges focused on efficiency like hackerearth, it’s a very interesting field, and really helps you to build confidence as a programmer.

1 Like

Great info guys. I really find the freecodecamp news about advanced data structures intriguing. Thanks for the share.

So tell me, did you use any of this or not?

What are you using as an alternative to nodes?
var node1={

How are you using an array as a replacement for a linked list. Please tell me more. I’m intrigued.

I can’t remember if i used them in freecodecamp. But i don’t think i did.

How are you using an array as a replacement for a linked list. Please tell me more. I’m intrigued.

Oh, i didn’t mean that, you can’t replace linked lists for arrays in javascript (as far as i know). What i mean was that in javascript (or at least most implementations of javascript), an array is already a linked list. When the language javascript was being created, someone decided that whenever you create an array, that array object will represent a linked list.

I’m not completely sure, but i think it’s impossible to create a proper and useful linked list in languages like javascript, because you don’t have a very essential concept from C that is pointers. A pointer is a variable that stores the address of values in memory, so instead of having “A”, you would have the location of where “A” is in your computer’s memory. Linked lists are created using these pointers, because you have values A B C, those values represent a node, and then you have a pointer to the next node in that list. And that next node itself contains values D E F, plus a pointer to the next value. If there aren’t anymore nodes, the pointer is null.

If you’re really interested in structures try checking out CS50, i know i’m preaching but i finished their course today and i’m blown away by how good it is. I feel even bad for not having the money to pay for the certificate right now.

1 Like

Hey what do you mean by “Language itself has a natural implementation of these structures”. If so then how do I use a linked list in JS. How do I create them, as I have seen linked list tutorials for creating them in JS. If it is naturally inbuilt how do we use them ? Thank you!

When you create an array you’re creating a linked list by default in JS. It depends on which implementation of javascript you’re using, but the data structures available to you in any really high level language already implements these concepts on the background. You don’t need to create a linked list in JS, because the linked list’s purpose is already fulfilled by an array or any other structure from the standard library.

The expression:
var a = [1,2,{hi: "bye"},4,"hi"]
either is a linked list (depending on which javascript implementation you’re using), or serves the exact same purpose as one, thus you don’t need to create it except for learning purposes. Javascript (or any other language as high level as javascript) is a horrible way to learn data structures, not because you can’t create said structures, but because they’re already abstracted away, so it’s harder for you to realize it’s importance.
You would be unable to create the a object written above in C, for example, so you would need to create a data structure to hold that information, and that data structure cannot be an array, so by necessity you learn the difference between data structures and their applications.


I was following this freecodecamp tutorial on linked list. But how would an Array fulfil a Linked Lists purpose as the way of access and memory allocation for both are different. And thank you for the suggestion that Java Script or any other higher level languages is a bad way to learn Data Structures. So would Python be a good option then as I see many universities teaching these topics using Python. Please suggest me. Thank you!

Depends on your goal really. Just look for a good book or course on introduction to computer science and follow whatever language they use.

Everything you use in your program allocates memory, every program must be stored in memory while it runs, that can be done manually or automatically, in the case of javascript, it’s done automatically.
var a = 10; allocates a part of the memory to allow the value “10” to be stored in a variable called “a”. The problem with learning linked lists or similar data structures that rely on hardware functionality using javascript is that you’re too far away from how the hardware actually works to realize it’s importance. In javascript, the memory was allocated and freed automatically for you, so the concept of linked lists is kind of irrelevant.

I recommend the course CS50 if you want to learn more about the basics of computer science, it’s an excellent course, and it’s free. The freecodecamp tutorial seems only appropriate for those who already understand what a linked list is and what purpose it serves, in a vaccum, specially using javascript, that explanation is fairly ineffective at teaching the concept behind linked lists.

A linked list is just a way to create a List (nodes of data that point to each other). In javascript, an array already does that job because it can allocate an undefined amount of data in each node, so it’s probably very difficult for you to understand without having experience in lower level languages. Do CS50 or any other computer science introduction course and you will probably find clearer explanation for this and related subjects.

1 Like

Thank you for the suggestion! Will definitely have a look