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.
0
votes
0answers
13 views
Movable object design in Haskell [migrated]
Suppose I have an object which has a point denoting it's location and shape.
...
1
vote
0answers
23 views
In memory B+ Tree in C++
I know B+ trees are not meant to be use in memory, I just implemented it as an exercise. I'm looking for a general review.
Code:
...
3
votes
1answer
23 views
Tracking orders efficiently using a Python class
I've written a Ledger class for a daemon process, which is supposed to keep track of an exchange's orderbook. My main concern is the way I keep track of the orders -...
3
votes
1answer
80 views
Using a LinkedList type of adjacency list to create the word game: WordLadder
Goal
The user puts in a starting word and an ending word. My code creates a ladder between these words of words that are different by one letter.
Start: gain End: fire
Output:
gain
gait
wait
wart
...
-3
votes
0answers
13 views
6
votes
1answer
117 views
Circular Buffer Implementation
I'm implementing a "live analytics" feature and I need to always keep track of the last N items that were added to a collection so I figured I'd make a circular buffer since I couldn't find one.
I ...
5
votes
3answers
237 views
Finding the duplicate with an array with 1,000,000 integers between 1 and 1,000,000
I recently had an interview and got to phase 2 which is a coding assessment. One of the questions was:
Given an array with 1,000,000 integers between 1 and 1,000,000, one integer is in the array ...
2
votes
1answer
35 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 ...
3
votes
2answers
140 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
26 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
51 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.
...
7
votes
5answers
686 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
73 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
64 views
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
120 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
126 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
157 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
55 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
161 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
86 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
43 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
34 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
69 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
44 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
100 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
363 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
162 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
68 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
96 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
81 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 ...
3
votes
2answers
81 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
75 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
45 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
58 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
124 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
101 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
58 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 ...