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.
2
votes
1answer
11 views
Dynamic array stack and bag implementation
I've have methods for a stack and bag using a dynamic array in C. As far as I can tell everything is implemented correctly, but I'm wondering what I can do to improve this code.
dynArray.h
...
0
votes
1answer
21 views
Detecting cycle in LinkedList
Is this a fair/clean way to detect a cycle in a LinkedList? Should work for both single and double LinkedLists'.
...
0
votes
1answer
11 views
Generic LinkedList with add/exists/delete/dlear/iteration functionality
I've just been going through core data structures and algorithms recently, wanting to get back in touch with the core fundamentals. I'm starting simple with a ...
-1
votes
1answer
17 views
Singly linked list abstraction in ES5 JavaScript
Below is the code for, Singly linked list implementation,
...
-2
votes
1answer
80 views
3 exams, 20 students: calculating the per-student average score [closed]
I'm a little curious... I have to work on a program in which a student takes 3 exams and the average is taken from the 3 exams that a student takes. It then goes into a form of a table, where one ...
2
votes
2answers
61 views
A linked list with push pop append and destructor
I tried to implement a linked list that can do pop(), push(), append(), printall(), and so on, and also I tried to handle the wraparound features, and de-wrap it when check if the list is cyclic to ...
2
votes
2answers
96 views
C++ Generic Linked List
My goal is to write a reasonably robust c++ linked list class. The current code represents the latest phase in this attempt. My future goal is to implement a doubly linked list along with more member ...
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
35 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
35 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
52 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
51 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
323 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
309 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
28 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
81 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
63 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
159 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.
...
1
vote
1answer
49 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
69 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
83 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
44 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
66 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
73 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
57 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
64 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
26 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
88 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
78 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
72 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.
...
4
votes
1answer
83 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
84 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
163 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
40 views
Draw a graph using braille characters
I hacked together a way to make a small graph using Braille unicode codepoints by abusing unicodedata:
...