/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

8,899 Subscribers

1

if anyone searching for dsa in python buddy??

comeover to discord we will catch up and plan what next

3 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

1

help needed

I've recently begun learning DSA from Striver's SDE sheet, but I'm finding it quite challenging. Can anyone offer some guidance or assistance?

2 Comments
2024/09/22
17:23 UTC

4

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

16

DSA Study Group -Basics to Advanced within **7 MONTHS**

Hi guys I am having Computer Science background and currently in my 7th sem- 4th year

I am searching for people who are interested to do DSA so that we can sharpen our coding skills together I have completed it till searching

rules to follow :

Staying consistent no matter what (even a question counts)

If there is anyone who is interested you can dm me

10 Comments
2024/09/18
11:46 UTC

1

Need a playlist

Guys help me. I need to learn data structures and algorithms. Need a playlist or an entire video.

1 Comment
2024/09/18
08:51 UTC

2

Depth First Search Time Complexity Question

Below is the code for depth for search algorithm:

If I run this code i get 'run for loop' in dfs_rec for 20 times that is O(edges=5)^(2) then how is the time complexity.

O(V+E) shouldn't it be O(V + E^(2))? I tried running and finding the time complexity.

Can somebody please explain?

def add_edge(adj, s, t):
    # Add edge from vertex s to t
    adj[s].append(t)
    # Due to undirected Graph
    adj[t].append(s)

print('adj add edge', adj)
def dfs_rec(adj, visited, s, nv):
    # Mark the current vertex as visited
    visited[s] = True
    print('visited', visited)
    nv += 1

    # Print the current vertex
    print(s)

    # Recursively visit all adjacent vertices
    # that are not visited yet
    for i in adj[s]:
        nv += 1
        #print('nv', nv)
        print('run for loop', i)
        if not visited[i]:
            dfs_rec(adj, visited, i, nv)


def dfs(adj, s, nv):
    visited = [False] * len(adj)
    print('visited', visited)
    # Call the recursive DFS function
    dfs_rec(adj, visited, s, nv)


if __name__ == "__main__":
    V = 5

    # Create an adjacency list for the graph
    adj = [[] for _ in range(V)]

    # Define the edges of the graph
    edges = [[1, 2], [1, 0], [2, 0], [2, 3], [2, 4], [1,3], [1, 4], [3,4], [0,3], [0,4]]

    # Populate the adjacency list with edges
    ne = 0
    nv = 0
    for e in edges:
        ne += 1
        print('e', e)
        print('adj for loop', adj)
        add_edge(adj, e[0], e[1])

    source = 1
    print("DFS from source:", source)
    dfs(adj, source, nv)
    print('ne', ne)
    print('nv', nv)
2 Comments
2024/09/18
04:00 UTC

2

Project help

Hey folks , I have a project to be done in my data structure subject in college this project is solving a real world problem Statement using data structures like stack linked list queues etc using language like C , python and java etc . Being confident in C and python.I am thinking of doing html and css for the front end part .

Can I get your suggestions and ideas for the projects

1 Comment
2024/09/17
13:07 UTC

4

How to follow the strivers course please help me..I am confused

Hey I have started the striver course so I have a doubt should I go on solving easy, med,hard questions of a topic at a time or should I first do cover all the topics and do easy ones thereafter go for the medium, hard questions of all topics pleas help me I am confused

3 Comments
2024/09/15
05:14 UTC

1

Feeling discouraged while solving problems on code forces

Hi,I am secondyear non cse student I am learning DSA of my own by following striver DSA sheet but still 10% only completed in sheet I am trying problems on codechef codeforces leetcode but I can hardly do only one sum thats all Can anyone please suggest me what to do to become a best coder 😭🙏

2 Comments
2024/09/14
15:53 UTC

7

Anyone can advice how to stay consistent with DSA?

Hii guys looking to start DSA and stay consistent in it any piece of advice that would be helpful will be appreciated 👏

3 Comments
2024/09/14
15:24 UTC

2

How to increase rating in codechef

I am a 2nd year student in noncse branch self learning DSA from striver DSA sheet I have knowledge of c,cpp and doing DSA with cpp I have completed only 2 steps in DSA sheet trying to give contests in codechef along side but I am able to solve 1 or 2 that's it .........Any tips to get ideas wiile solving in contests ??

2 Comments
2024/09/12
03:33 UTC

3

Help me to switch job

1 plus Y. O. E Full stack dev in a seed level startup Stack : Springboot, Reactjs, Aws

1 Comment
2024/09/11
10:59 UTC

1

Need help for dsa competition in university

Need help for dsa competition in university

So tomorrow is DSA CONTEST in my university compulsory for all the students And i am in 3rd of my degree and literally not good at DSA how can i do this within 1 dayy And its compulsory for all students

The upcoming DSA contest will focus exclusively on problems related to arrays. Participants should be prepared to tackle a variety of challenges that test their understanding and mastery of array-based algorithms and techniques.

4 Comments
2024/09/11
08:02 UTC

1

Need help for dsa competition in university

So tomorrow is DSA CONTEST in my university compulsory for all the students And i am in 3rd of my degree and literally not good at DSA how can i do this within 1 dayy And its compulsory for all students

The upcoming DSA contest will focus exclusively on problems related to arrays. Participants should be prepared to tackle a variety of challenges that test their understanding and mastery of array-based algorithms and techniques.

0 Comments
2024/09/11
07:32 UTC

6

Underrated resources to learn data structures and algorithms

1 Comment
2024/09/09
15:08 UTC

3

Anyone up to join me in learning and solving data structures and algorithms?

1 Comment
2024/09/09
14:51 UTC

8

I need help starting DSA

Hello, I am new to the world of DSA, I am in 4th year of undergraduate Computer Engineering, but I have only dealt with moderate level codes and small Projects. Its time to grab jobs, my seniors told me I need to have good hold on DSA. (Where should I start, how should I go about it?) Is it necessary to follow one specific resource or playlist etc? Advice plzz

8 Comments
2024/09/06
09:27 UTC

3

DS + Algo prep for Interview(s) for Cloud+AI and research AI roles at Google?

What kind of DS + Algo questions should I practice for ML research roles and Cloud Technical Solutions Engineer in AI/ML at Google? I’m sure that I can handle the ML and cloud part but my DS and Algo is weak since my previous work experiences never really relied on practising competitive coding. How tough should I expect the DS and Algo to be since it’s not an SDE job but it’s at Google?

0 Comments
2024/09/06
02:03 UTC

3

Data structures and algorithms

Should I do DSA online or offline?

2 Comments
2024/09/04
13:22 UTC

2

Help Needed with Implementing Concordance on File Using Different Data Structures

Hi everyone,

I'm currently working on a lab for the algo, data structures and complexity course, which involves creating a concordance data structure on the file system and implementing a search program that retrieves word occurrences along with their surrounding context. For Task 3, we need to evaluate different data structures (binary search tree, sorted array, hash table, trie, and lazy hashing) for implementing the concordance on file. I need help with the following points:

  1. Implementation Details: How would you go about implementing these data structures on file, especially considering we should use as little internal memory as possible? Are there any resources or examples that show how to handle pointers or references on disk, especially when dealing with large text files?

  2. Performance Considerations: The task requires us to compare the speed (number of file reads and seeks per search), memory complexity for file storage, and the ease of construction and storage on file. Does anyone have insights or experience on which data structures are most efficient in these aspects? I'm particularly struggling to understand how to keep the search fast when the data is not in memory.

  3. Why Lazy Hashing (Latmanshashning)?: In this lab, we are encouraged to use lazy hashing, also known as "latmanshashning." This method hashes only on the first three letters of the search key and then uses binary search to refine the results. It is particularly suited for searches with few disk accesses in large texts when the index can't fit in primary memory. I'm trying to fully grasp why this approach is preferred over other data structures like tries or hash tables. I understand that it maintains constant memory complexity, but I’m not clear on how it compares practically with the other options in terms of implementation complexity and speed.

Any advice, resources, or code snippets that could help me better understand these aspects would be greatly appreciated. I'm also open to any suggestions on testing strategies to evaluate these implementations effectively.

Thanks in advance for your help!

0 Comments
2024/09/02
15:09 UTC

2

Why is my approach not working?

Minimize Max Distance to Gas Station

Minimize Max Distance to Gas Station

Difficulty: HardAccuracy: **38.36%**Submissions: **57K+**Points: 8

We have a horizontal number line. On that number line, we have gas stations at positions stations[0], stations[1], ..., stations[N-1], where n = size of the stations array. Now, we add k more gas stations so that d, the maximum distance between adjacent gas stations, is minimized. We have to find the smallest possible value of d. Find the answer exactly to 2 decimal places.

Example 1:

Input:
n = 10
stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
k = 9
Output:
 0.50
Explanation: 
Each of the 9 stations can be added mid way between all the existing adjacent stations.

Example 2:

Input:
n = 10
stations = 
[3,6,12,19,33,44,67,72,89,95]
 
k = 2 
Output:
 14.00 
Explanation: 
Construction of gas stations at 8th(between 72 and 89) and 6th(between 44 and 67) locations.

 

Your Task:
You don't need to read input or print anything. Your task is to complete the function findSmallestMaxDist() which takes a list of stations and integer k as inputs and returns the smallest possible value of d. Find the answer exactly to 2 decimal places.

Expected Time Complexity: O(n*log k)
Expected Auxiliary Space: O(1)

Constraint:
10 <= n <= 5000 
0 <= stations[i] <= 10^(9) 
0 <= k <= 10^(5)

stations is sorted in a strictly increasing order.Minimize Max Distance to Gas Station

This is the question . I employed the logic that lets store the gaps between adjacent stations in a maxheap. we have 'k' stations ,so i poll the first gap out from the heap and try to divide it into segments until their gaps are less than the next gap in the heap,when it does i just insert the formed segments gap into the heap(for ex: if i break up 6 into 3 segments of 2 , i insert three 2s into the heap). If at any point we exhaust all 'k's we break out of the loop. I know this is a binary search question and all,but will my approach not work? If anyone can confirm or deny this it'll be great great help!

0 Comments
2024/08/30
16:42 UTC

9

Not able to solve DSA problems

I work as a React Deceloper. I've been meaning to start dsa from very long now. I have also tried multiple resources here and there and have tried countless youtube videos. The thing is I'm not able to build up logic manier times. I've tried doing leetcode easy questions. Once I try I am able to come up with a solution which eventually doesn't work. But when I see solution I'm able to understand those. Because of this I'm not able to stay consistent either. I lose motivation immediately. What should I do? Has anyone faced the same problem? Because it's been too long now. (Also its just DSA which I'm not able to study. I've learmed variaous tech stacks over the time. But never have been able to keep up with DSA) If I'm to apply for a better companies and switch jobs, I need to have atleast intermediate level of grasp on DSA. Help??? Or share any tips. Thanks already.

9 Comments
2024/08/28
17:54 UTC

3

How to manage time for DSA and other subjects as I am noncse student

Hey guys I am studying 2nd year Robotics and AI branch it is a noncse branch in my college I have more intrest towards coding as of now I started learning DSA but managing looks a little bit difficult someone give some tips pleaseee and can i get into Microsoft as engage intern this year is it possible for noncse branch student

2 Comments
2024/08/27
10:05 UTC

2

Need a companion to learn dsa and system design in C# , having more than 7 years experience

I am pretty new to dsa, have solved some easy and medium problems but need to go advanced and also start system design post that. We can start as early, probably 2 hrs a day..

1 Comment
2024/08/26
13:10 UTC

2

Need a companion for DSA and system design as beginner, who is around same age 27 or similar, I started learning DSA and system design little late in my career for better job opportunities as already in software development. I am using java as my main language for dsa. (DM me)

4 Comments
2024/08/25
10:14 UTC

Back To Top