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
0answers
16 views

Linked List in the form a a stack [on hold]

I created a stack using a linked list, and while most of the code works correctly, I am having issues with the pop method. The program pushes in numbers correctly, and while it can pop values if they ...
2
votes
0answers
22 views

Union-find implementation

Here are a few questions on my mind: What improvements to the above code can you think of? I want to say new UnionFind(x) where ...
4
votes
1answer
34 views

Evicting an entry from a size-limited HashMap<T, Integer>

I have a HashMap with a limited size of 1000 elements. When I want to put one more, the T with the lowest related Integer in the map should be replaced with the new one. I already have this working ...
0
votes
0answers
28 views

Using actors to collect paged data structures exposed through REST API

I've come up with a small exercise to learn scala consisting of making a client that assembles a graph available as a resource. The API server responds with a paged list of edges, in the form of ...
0
votes
1answer
34 views

Simple weighted directed graph in Python

I have this simplistic Python class for representing directed weighted graphs (digraphs for short): Digraph.py ...
5
votes
1answer
48 views

Data structure for expression evaluation in Haskell

Program behaviour Hi! New haskeller here. I've made a data structure for mathematical expressions. I want to parse mathematical expressions like ...
3
votes
1answer
26 views

A class (actually a structure) to help decode an HRESULT

HRESULTs are the common way for Microsoft technologies like COM and Win32 to return either an error code or messages that mean a specific type of success. They are usually returned as the result of a ...
0
votes
1answer
50 views

A Java subclass of ArrayList that supports rotation in constant time - follow-up

(See the previous (and initial) iteration.) Compared to the previous iteration, I have added more methods that maintain the invariant required for constant time rotations, such as bulk add/remove, ...
7
votes
3answers
317 views

A Java subclass of ArrayList that supports rotation in constant time

(See the next iteration.) I have subclassed java.util.ArrayList in order to be able to "rotate" it in constant time simply by moving a finger index. See what I ...
9
votes
2answers
294 views

Circular Buffer in C - Follow Up

This is a follow up to this post I uploaded a few days back on my alternative account about a circular buffer in C. I'm confident that I fixed most of the warnings and even added an iterator. ...
0
votes
0answers
18 views

Merging trees in scalaz

I just built a function to merge a set of List[A]s into a single scalaz.Tree[A]. Specifically, if I have the following three ...
3
votes
2answers
46 views

Generic Vector Implementation

I'm in the process of writing a Generic Container Library in C called CGCL (https://github.com/ta5578/C-Generic-Container-Library). One of the generic containers I'm implementing is the vector ...
1
vote
1answer
80 views

Find pairs in binary search tree in which sum of nodes keys is equal key

There is a task: Given a binary search tree of \$n\$ nodes, find all the pair of nodes whose sum is equal to a given number \$k\$ in \$O(n)\$ time and constant space. Please let me know if you ...
2
votes
1answer
62 views

Find all distinct subsets that sum to a given number

The function wants to achieve to find all distinct subsets that sum up to an given number. ...
1
vote
1answer
71 views

Java Stack Implementation with Generics

I've written an implementation of a Stack data structure using a linked list. Stack.java ...
10
votes
3answers
157 views

Pokemon stats calculator

I have a simple working (so it's not a hypothetical stub) framework for calculating Pokemon stats that will later be incorporated in a game. It uses the LCRNG from the first game in order to be as ...
2
votes
1answer
47 views

Custom OrderedLinkedList class with nested OrderedListNode class

Everything works with this program. It takes both Strings and ints, however, I feel like my add method is simply too verbose. Does anyone believe I can implement a shorter version of this, or is it ...
3
votes
2answers
39 views

SortedList implementation in Java

I've implemented a SortedList which takes in streams of floats and returns a median at any point. ...
0
votes
1answer
47 views

Finding Kth Permutation Sequence

I have written a program to display the kth permutation sequence of a string made up of letters 'O' and 'Z' . I tried optimizing it but my code have not passed test cases due to timeout issues.Looking ...
3
votes
1answer
67 views

Uploading .dll files to a local computer

I have created a simple application that has grown a little bit. Though most likely it won't grow anymore, I have looked back and I realized that it has become a little monster in terms of how many ...
0
votes
1answer
42 views

Tree processing for series and parallel execution

I have a tree processing application where some of the nodes are "executed" in parallel and some in series. I managed to do this but I feel that the solution looks a bit "hacked up" and can be ...
4
votes
2answers
82 views

DoublingQueue in Java

Inspired by this CR question, I decided to create my own queue! If you guys see anything taboo or have any improvements, please let me know. Ultimately I want it to be feature rich and bug free, with ...
5
votes
0answers
43 views

Tracking the bounding box of a map

Context I have a bunch of data points that look roughly like this: ...
3
votes
1answer
43 views

Nesting a flat array in on itself

I have an extremely large function for turning my database output of menu links into a multidimensional array that nests each of the links in a menu fashion. I'm wondering if anyone sees a way this ...
3
votes
0answers
28 views

D trie implementation

I just started to learn D and ported my a bit over-templated trie. It looks way better than on C++. I'm sure there is still room for improvement and to make it be real D code. I checked an the array ...
1
vote
2answers
64 views

Finding all root-to-leaf paths in a binary tree

The task is to return all root-to-leaf paths, given a binary tree (from leetcode). This is my approach. Take a helper array and a counter, keeping track of what has been traversed so far. If it is ...
1
vote
1answer
72 views

Program to find queue

This is my first time using C++ and Templates to make a data structure I am writing a program to find queue till 5 spaces. ...
4
votes
1answer
56 views

C++ class for disjoint-set/union-find on integers

I have implemented the disjoint-set data structure. The purpose is to group integers together. For example, if I want to find out the groups of integers where each adjacent neighbors are same: ...
2
votes
2answers
91 views

Array-based deque in Java

Are the conditions which I have included for insertion and deletion from front and rear sufficient and necessary? Have I missed some condition check? Or have I included some redundant condition? ...
-2
votes
1answer
53 views

Finding Closest Sibling in a BST efficiently

Trying to print the closest sibling in a BST. How can I improve on this algorithm in terms of space/time efficiency? Please point out any potential bugs too! I'd appreciate that. ...
1
vote
2answers
42 views

Function that assigns names to a struct using strtok

I worked around using strtok function so to assign first name and last name to a struct PERSONNE from a ...
3
votes
1answer
62 views

Matching parenthesis

This is a simple implementation of a parenthesis-matcher. Given an expression, I want to find out if it is balanced.For example, the expression '{{[[()]]}}' is balanced while '{]{{}}]]' is not. I will ...
2
votes
0answers
25 views

Reformatting a structured string like “a-b-c|A-B-C” into “a-A|b-B|c-C”

The code below was inspired by this post in Code Review. Here is how it was first intended by its author: I have the following code that converts a string that looks like : ...
3
votes
2answers
83 views

Implementation of stack

Task: Create a class RPNStack which represents a stack of objects of type Node. Class RPNStack contains only one private field top of type Node. Objects of type Node represent data that ...
2
votes
1answer
72 views

Persistent set (Red black tree)

This is a partially persistent data structure using a red black tree. It will copy \$O(lg(n))\$ items for each remove or add operation. ...
3
votes
1answer
39 views

Simple stack structure in C

I just started to learn C, and for practicing, I tried to implement a simple stack data structure, and I want to know if I'm making any mistakes, or how could I improve it: My stack.h: ...
3
votes
2answers
71 views

C Stack data structure

I have implemented a Stack data structure in C and I would like to know if there is something that could be improved. Stack using linked list: ...
3
votes
0answers
39 views

Refactored version of Okasaki's skew-binomial heaps in Standard ML

In his book, Purely Functional Data Structures, Chris Okasaki provides an implementation of skew-binomial heaps (p. 137). Unfortunately, the book isn't (legally) freely available anywhere, but his ...
1
vote
1answer
60 views

Templated linked list in Java

I recently reviewed some data structure concepts, so I implemented my own templated linked list. I am very interested about the code efficient and performance. ...
3
votes
1answer
68 views

Skip list in Python

I've made an attempt at writing a skip list in Python. I'm using NumPy to generate geometric random variables, but since that's a bit of a heavy dependency to drag around I could easily implement that ...
5
votes
1answer
83 views

Octree for voxels

I am creating a game with destructive terrain. Before I used a flat array to store the blocks, in chunks of 32^3. As I am aiming for detail and long view distance I would of course need some sort of ...
3
votes
1answer
162 views

Fibonacci heap in C

(See the next iteration.) I have rewritten a Fibonacci heap implementation from Java to C. fibonacci_heap.h: ...
8
votes
2answers
129 views

Report Building (Data Retrieval, Validation, Aggregation, Business Logic, Report Building, Visual Presentation)

This: Is a data table we get from our financial platform with lots of useful information. For reference, "--" is also the string they use to denote empty values. This: Is a spreadsheet I built ...
2
votes
2answers
39 views

Draw a graph using braille characters

I hacked together a way to make a small graph using Braille unicode codepoints by abusing unicodedata: ...
1
vote
1answer
86 views

Optimum Tree traversal algorithm Topcoder

I'm practicing a 1000 point algorithm problem on the topcoder.com arena. The problem is as follows:      You work for an electric company, and the power goes out in a rather large apartment complex ...
3
votes
2answers
71 views

Generic Singly Linked List in C

I decided to learn generic programming in C (and take a break from templates in C++) by implementing my first simple data structure in C : the singly linked list. What I'm looking to gain out of ...
4
votes
0answers
35 views

Hash Based Data Structure in Java for Collision Calculation

I have started a project on my free time were I'm writing a 2D game engine in Java. One of the more challenging and interesting aspects of such a project is collision detection between sprites on the ...
8
votes
2answers
169 views

Vector Implementation C++

I have attempted to implement a similar version of the STL Vector; several functions are missing but I'd like a few words of advice on whether I am indeed on the right track or whether I should change ...
6
votes
2answers
200 views

Skip List implementation

Skip lists are a probabilistic alternative to balanced trees, they are balanced by consulting a random number generator, that determines how many pointerscalled node level to successive elements a ...
2
votes
0answers
22 views

Repetative object attribute definition [closed]

The concept of "defining an object which holds repetitive information" has been something on my mind for quite a while, and I've come across it again recently. Hoping that someone can inform me on ...