/r/datastructures

Photograph via snooOG

What's better than one data structure? Two data structures.

Let's discuss the latest hip and fashionable data structures and conjectures about them:

cache trees, skip-splay trees, the world is our data oyster.

/r/datastructures

9,136 Subscribers

2

BFS animation video

0 Comments
2024/10/30
16:16 UTC

1

Time computations

Under the hood as a fresh software developer should I deeply know how the time complexity computations work mathematically? bc I'm studying algorithms-I by robert sedjweck and till module 3 now he is talking about Mathematical models and observations for algorithms

1 Comment
2024/10/30
14:25 UTC

6

DFS Animation

0 Comments
2024/10/29
17:36 UTC

1

Hash tables

Does anyone know playlist on hash tables.i strugging with these.thank you

0 Comments
2024/10/29
10:06 UTC

2

New to programming

Just took the basics of programming in c++ , i will learn data structure in this semester any recommendations or playlist which explain it simply and giving all details it will be amazing if he explains it while developing a game from scratch, thanks feel free to leave a comment or give an advice 🫶

3 Comments
2024/10/29
00:16 UTC

3

We are hosting weekly sessions to help you crack MAANG

0 Comments
2024/10/27
05:11 UTC

1

Anyone here who can solve my DSA assessment questions?

3 Comments
2024/10/22
16:48 UTC

0

Question

I’m thinking of buying Neetcode premium subscription for a year, is it worth buying? please reply me need to start grinding dsa as quick as possible

3 Comments
2024/10/20
20:12 UTC

2

building a hash table vs using a hash table library

When I took DSA, the professor said it was better to build your own hash table instead of using a library and that it would make your programs better but never explained why. Is this true? Why would that be the case?

1 Comment
2024/10/17
04:30 UTC

6

Just Upload KMP Algorithm Visualisation (in 7 minutes)

0 Comments
2024/10/16
16:45 UTC

2

Is BFS and a Tree Data Structure Sufficient for Comparing if two Trees are Structurally Equal?

I’m working on a problem where I need to compare multiple lineages (family trees) to check if they are structurally identical. Each lineage starts from a single root (ancestor) and extends downwards. The trees are ordered by the age of the children, and each node has a gender indicator (I, M, K for intersex, male, female, respectively).

The trees are considered structurally equal if:

  1. The root nodes of both trees have the same gender.
  2. The number of children at each node matches between the trees.
  3. The children at each level are ordered the same way, and the nth child of one root is structurally identical to the nth child of the other root, where their gender needs to be the same. They're ordered from oldest to youngest, from left to right.

Here's an image that shows when two trees are not structurally equal.

The problem requires an algorithm with a time complexity of O(n * m), where n is the number of lineages, and m is the number of nodes in the largest tree. We're given that a parent can't have more than 12 children. We're required to use decomposition in our algorithm.

I’ve considered using BFS for tree traversal, as it processes nodes level by level, which fits well with comparing ordered children. I would also use a tree data structure to represent each lineage, where each node contains the gender and references to its children.

However, I’m not entirely sure if this approach is sufficient to meet the problem's requirements, especially given the constraints around ordering and early termination if the structures are not identical.

So to my question: Would using BFS combined with a tree data structure be sufficient to compare these trees in terms of both time complexity and structure? How does BFS start without a common root? Wouldn't that imply a common ancestor and be incorrect for this type of comparison?

1 Comment
2024/10/15
07:44 UTC

3

how to backtrack?

I am CS Student who is interested about Data Engineering, so i skipped DSA my first 2 years at UNI thinking that only SWE need that. Now i Want get back on the race and get better at solving leetcode problems yet unfortunately, there is a concept that keeps me frozen, it's recursion, I just can't write recursion code to solve backtracking problems, I know the concepts and most of the times i look at a problem, I know the exact approach or algorithm yet i struggle at implementing this recursion thing. (i couldn't even solve the all combination of an integer array problem).

2 Comments
2024/10/13
09:29 UTC

11

Struggling with Leetcode, constantly relying on solutions. How can I improve?

Hey everyone,

I've been trying to work on Leetcode, but I feel like I'm constantly copying solutions instead of solving the problems on my own. I've completed around 55 questions so far, but for most of them, I had to check the solutions to even make progress. This is really making me feel bad about myself because I know this approach won’t help in the long run.

It feels like every problem is completely different, and I’m struggling to apply the concepts I’ve learned. Has anyone else been through this? How did you overcome this hurdle and start solving problems on your own? Any advice or resources that could help me build problem-solving skills would be really appreciated!Thanks for your help in advance.

#Leetcode #CodingHelp #ProgrammingAdvice #StrugglingToLearn #CodingJourney

11 Comments
2024/10/11
17:22 UTC

12

Data structure roadmap

I'm in my 5th semester I studied data structures in my 2nd sem. I know the theory but I couldn't code. If you guys used any road map for this please help me.i really don't know where to start

15 Comments
2024/10/09
18:11 UTC

7

Made a detailed animated video on Binary Search Trees

2 Comments
2024/10/08
21:26 UTC

1

How can i study data structure

I entered my first lecture last week and i literally couldn't understand anything like i understand what the professor saying but i just don't understand what is this about or what is the whole goal of it can someone help me out study this subject please Thank you

4 Comments
2024/10/07
21:41 UTC

5

How can i study data structure ?

I entered my first lecture last week and i literally couldn’t understand anything like i understand what the professor saying but i just don’t understand what is this about or what is the whole goal of it can someone help me out study this subject please Thank you 💗

6 Comments
2024/10/07
17:53 UTC

1

What will you suggest flutter or react?

1 Comment
2024/10/07
04:55 UTC

1

How to implement a dynamic array in Python from scratch?

Hi, sorry a basic question, as title. I have searched internet and asked ChatGPT, and cannot get a coherent answer to this question. My understanding is that I need a poiner for the dynamic array. Here is my attempt: (I have already implemented all functions of linked list from scratch, but struggled with getting started with this one) Thank you again for your kind help!! Question: dynamic array is always better than static array due to memory allocation, right?

class DynamicArray:
    def __init__(self):
        self.array = []
        self.next = 0 # a pointer

    def size(self): # number of items
        array = self.array
        while array is not None: # array not empty
            self.next += 1
5 Comments
2024/10/06
19:28 UTC

1

Whats the difference between these implementations of bubble sort.

Implementation 1
n = len(my_array)
for i in range(n-1):
    for j in range(n-i-1):
        if my_array[j] > my_array[j+1]:
            my_array[j], my_array[j+1] = my_array[j+1], my_array[j]

Implementation 2
for i in range(len(array)-1,0,-1):
        for j in range(i):
            if (array[j] > array[j+1]):
                temp = array[j]
                array[j] = array[j+1]
                array[j+1] = temp
3 Comments
2024/10/06
05:52 UTC

4

How I mastered data structure and algorithms

Somebody guide me for leaning DSA in programming

6 Comments
2024/10/02
03:44 UTC

2

Summary: How to even answer these job hunt questions?

0 Comments
2024/10/01
05:27 UTC

2

EXPLAINING SORTING ALGORITHMS WITH CARDS|DSA

0 Comments
2024/09/28
21:03 UTC

3

Had a bad OA exam

Why am I not getting better in data structures man people who are around me who didn't even understand them are getting ahead Why am I not able to build logic why am I not able to code Man I'm so tired I'm so jealous and sacred this exam could've landed me a good internship

2 Comments
2024/09/28
12:23 UTC

1

if anyone searching for dsa in python buddy??

comeover to discord we will catch up and plan what next

4 Comments
2024/09/24
12:02 UTC

3

How to calculate time complexity and space complexity

Hello, I'm looking for videos that help me understand how to calculate tc and sc. Like solving them (I know what tc and sc are, it is difficult for me to calculate them tho)

Any advice is helpful

2 Comments
2024/09/23
05:23 UTC

3

How To Calculate Big O in 5 Steps?

2 Comments
2024/09/22
16:33 UTC

0

Should I Stick to JavaScript or Invest Time in Learning Go for Coding Interviews?

Hi everyone,

I'm preparing for software engineering roles at big product-based companies, and I have a bit of a dilemma. I’ve been working with JavaScript (and TypeScript) for the past 4-5 years, so I’m very comfortable with it, especially when it comes to coding challenges and problem-solving. However, I’ve heard that using Go (Golang) in interviews could create a good impression, especially for backend or systems roles.

I’m willing to put in the extra effort to learn Go if it helps me stand out in interviews, but I’m not sure if it’s the best strategy considering I’m already strong in JS/TS. I’ll need to spend time learning Go's syntax and nuances, but if it’s worth it for my career growth and interview performance, I’m ready for the challenge.

For those who have been through similar situations, what would you recommend? Should I stick with what I know (JS/TS), or should I invest time in learning Go for the potential advantage it might give in interviews? I'd love to hear your thoughts, especially if you’ve faced a similar decision!

Thanks!

1 Comment
2024/09/22
16:00 UTC

Back To Top