A data structure is a way of organizing data in a fashion that allows particular properties of that data to be queried and/or updated efficiently.

learn more… | top users | synonyms (1)

2
votes
1answer
32 views

Segment tree challenge

Here is my implementation of a segment tree with a sample driver file (I didn't make an update function because I didn't need it for what I was doing). I'm a huge fan of geeksforgeeks, but I do not ...
-2
votes
0answers
27 views

Parsing through a tangled linked list [closed]

The struct function is: ...
3
votes
2answers
135 views

Connected components in an undirected graph in C#

My knowledge in graph theory is very limited. I have to look for elements in an (undirected) graph who are in the same connected component. The idea is simple. First, build the graph. Then, allocate ...
0
votes
0answers
24 views

Dataframe helper in R

In order to have a "unified" (I realize how ambitious this actually is) syntax when working on dataframes, I wrote the following functions that is a general purpose dataframe set of tools in R. ...
0
votes
0answers
13 views

Add and merge 2D array items so no nested duplicates on the outer array

this.collisions is a 2D array containing a list of collisions that, when bodies collide, they should be added to it. Here's an example: ...
1
vote
1answer
49 views

N-tier application with BAL and DAL methods

I was just asking this question over here. I'm on a project in which I'm failing to see the point of how a previous developer made decisions. I HAVE taken over this project and wish to make changes. ...
6
votes
5answers
671 views

An ordered set in C#

I need a generic data structure that ensures that its elements are unique. C# has HashSet<T>, great! As it turns out, the elements have to stay in the order ...
4
votes
1answer
71 views

Comparing three data structures for dealing with probability distributions in Java

Introduction Suppose you are given three elements \$a, b, c\$ with respective weights \$1, 1, 3\$. Now, a probability distribution data structures will return upon request \$a\$ with probability 20%, ...
3
votes
1answer
61 views

Simple singly linked list in Java

The list is pretty simple, here is my code: ILinkedList.java ...
2
votes
1answer
34 views

DisjointSet with O(1) find and O(1) amortised union

Does this code outperform the common implementation with path-compression and union-by-rank? I'm still okay with a review. GitHub ...
6
votes
3answers
117 views

Generic graph implementation in C#

I am implementing fundamental data structures in C# while trying to learn techniques in the language to make my code cleaner, more concise, and reusable. I have implemented a generic graph with a few ...
3
votes
0answers
125 views

Data model for complex tree (multiple children and multiple parents)

I'd like to have a discussion on the data model (mostly) for a tree with nodes having multiple children and multiple parents. I already have a working algorithm, but I'm looking for improvements. The ...
3
votes
2answers
156 views

Heap Implementation in C#

I am learning fundamental data structures, and I want to know if this is a valid implementation of a heap. Can any C# features be used to improve or extend the implementation? In addition to heapsort, ...
2
votes
2answers
52 views

Importing data into Excel

Is there an easier way of importing data into an Excel array or other data structure? I've tried researching collections but I have found the documentation hard to comprehend. MSDN The code I have ...
4
votes
1answer
139 views

Data Stream as Disjoint intervals

I was asked the following question: Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen so far as a list of disjoint intervals. For example,...
1
vote
3answers
85 views

RadixSet - A growing-only Radix/Patricia Tree

I'm looking for a structure to store large amounts of strings (5k to 100k) and then test for existence of new strings against the previous inserted data, in the least possible amount of time (memory ...
4
votes
1answer
77 views

Managing IDs using AVL trees

In a txt file there are IDs and next to them there are their neighbours like this: 1 1 1 2 1 3 2 1 2 4 2 8 3 5 Using AVL trees I store the IDs in one AVL ...
3
votes
1answer
41 views

Queue implementation using two stacks

Here's my code and I want to know if there's a better method for doing so. While the question has stated two stacks I wonder if we could do only with one as well? ...
4
votes
0answers
26 views

implementing a StringEnum

this is to be used like an Enum (as parameter mostly), but for string using .net 3.5 Actual Implementation ...
4
votes
1answer
67 views

Clean Way of marshaling data

I've been working on a game that I used to play as a kid. This game was disassembled then converted to C# by someone else and they hosted it on Github. I've forked it and started working on it some. ...
2
votes
1answer
41 views

Flatten a nested dict structure in Python

For some post-processing, I need to flatten a structure like this ...
2
votes
1answer
35 views

Creating List of String elements that occur a certain amount of times using only the List ADT

I am tasked with creating a list with no duplicates of all String elements, in this case first names, of an ArrayList. The method is passed a threshold, and the ...
3
votes
2answers
96 views

Avoiding misuse of optional unwrapping: LinkedList

Below is my implementation of a generic linked list in swift. Unfortunately, Swift playgrounds won't run until the compiler is totally happy - often, that involves clang making me explicitly unwrap ...
1
vote
4answers
344 views

Reading HTML files, removing HTML tags, and writing content and summary to a file

Write a multithreaded C++ application (executable) for Windows Platform. This program uses the two threads to read and process the input data and store it into an output file. Candidate is free to ...
4
votes
1answer
160 views

A one change boolean value

I have the case of repeated very similar logic that is used to check if a boolean value was changed from the initial value and prevent it from changing back, or to summarize multiple boolean return ...
3
votes
3answers
36 views

Array-based queue implementation using C

I wrote this header for generic use of a queue. The one thing I'm wondering is if I understood the usage of void*. I hope that if somebody teach me some conventions ...
3
votes
1answer
67 views

Running shell commands in a pipeline

I'm writing a shell in C for Linux and BSD. My code was unreadable before but I did a rewrite and now it is much more readable. The purpose of the code is to create a command pipeline and execute it. ...
2
votes
3answers
91 views

C++ Node class template

I'm working on building understanding of data structures in general, and specifically linked lists in this example. I'm also trying to increase my ability with templates. In cross-referencing dozens ...
5
votes
1answer
78 views

Write a program that, given an age in seconds, calculates how old someone is in terms of a given planet's solar years

Problem: Write a program that, given an age in seconds, calculates how old someone is in terms of a given planet's solar years. Earth: orbital period 365.25 Earth days, or 31557600 ...
1
vote
1answer
61 views

Reverse a linked list recursively

This recursive calls reverseList on each node of the linked list. When returned from the function call, it changes the next link to the previous node. ...
0
votes
0answers
18 views

Flattened Data Model and noSQL data structure

I am currently building a small application using a service which requires and advocates the use of a "flattened" data model (the service is Firebase). As I had no experience with data models before, ...
4
votes
0answers
39 views

No-copy cache line aligned function storage object with small object optimization

I have implemented a std::function-like class, that is optimized for storing lambdas, that never copies the stored function, that has a small buffer to store ...
3
votes
1answer
72 views

Write a small archiving program that stores students' names along with the grade that they are in

Problem: Write a small archiving program that stores students' names along with the grade that they are in. In the end, you should be able to: Add a student's name to the roster for ...
4
votes
2answers
89 views

Let me fix thou number

Problem Statement: Write a program that cleans up user-entered phone numbers so that they can be sent SMS messages. The rules are as follows: If the phone number is less than 10 ...
4
votes
1answer
45 views

Transparent wrapper class for data structure in Python

I needed a deque who's maxlen can be set again after it has been initialized. So, since new-style classes in Python are treated ...
-3
votes
1answer
44 views

Creating a struct

Mat told me to create a struct create a struct for the individual commands and arguments. It should have something like the "executable" name, number of args and arg list. Create a few ...
5
votes
1answer
57 views

Let's have a meetup

Problem statement: Calculate the date of meetups. Typically meetups happen on the same day of the week. Examples are the first Monday the third Tuesday the Wednesteenth the ...
3
votes
2answers
113 views

FindTwoSums using Tuple

I am writing a function that, given a list and a target sum, returns zero-based indices of any two distinct elements whose sum is equal to the target sum. If there are no such elements, the function ...
0
votes
1answer
25 views

C function for copying array into matrix

I want a matrix that can grow dynamically and build up a structure in RAM as input arrives from standard input och terminal (shell). First I tried with a matrix like ...
16
votes
5answers
1k views

Generating Robot Name

Problem: Write a program that manages robot factory settings. When robots come off the factory floor, they have no name. The first time you boot them up, a random name is generated, such ...
1
vote
0answers
36 views

Union Find implementation

I am trying to complete this challenge. The user should enter a sequence of instructions, = to link two numbers, and ? to query ...
3
votes
3answers
100 views

Calculate the Hamming difference between two DNA strands

Write a program that can calculate the Hamming difference between two DNA strands. GAGCCTACTAACGGGAT CATCGTAATGACGGCCT ^ ^ ^ ^ ^ ^^ The Hamming distance between these two DNA ...
2
votes
0answers
49 views

Concurrent resizable ring buffer Golang

I'm trying to find the fastest way to enqueue and dequeue items concurrently in Go. There are some restrictions: it needs to be unbounded memory allocation should be low. multiple producers (...
2
votes
0answers
50 views

Binary search tree class in Java

I am trying to create a binary search tree class in Java and am wondering how I did. I am fairly confident on most of the methods, but fear I may have messed up the delete method. I know I am ...
1
vote
0answers
35 views

A stack optimized for filter queries, written in C++ preprocessor

Given a stack with N elements and a query Q we need to find all elements of stack, for which ...
7
votes
3answers
211 views

Nucleotide Count

I am learning Java and hence practicing it from here. The solution seems pretty trivial to me but still I would like to have a honest review which would guide me to following ideas: Am I maintaining ...
4
votes
1answer
90 views

Implementing Binary Tree using Queue in C#

I am in the process of learning data structures and I am trying to implement Binary Tree using Queue in C#. Below are my Tree implementation classes. ...
0
votes
2answers
55 views
4
votes
1answer
129 views

VERY simple C# Set implementation

This is not meant to solve any insane real world problems. I just want to make sure my Set logic is right and the code looks okay. It feels weird implementing it with a ...