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)

1
vote
1answer
13 views

Interfaces & Factory for generic container supporting PeekMax, PeekMin, Sum, and PeekNextToMax

This is a partial update of this question. To summarize, the class is a generic container similar to MaxHeap, but only needs to support the following operations. create from an existing collection ...
4
votes
1answer
63 views

Matching strings

Basically I solved this question on one of the competitive websites: Given the total n number of String on first input, n input follows: We have to find such pairs of string (i,j) such that ...
0
votes
1answer
36 views

Remove Duplicates from Sorted List — LeetCode Solution in C

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Given 1->2->3->3->4->4->5, return 1->2->5. Given ...
10
votes
1answer
63 views

Compile-time data structure generator

In response to another recent question I mentioned that one mechanism to avoid runtime overhead for creating a data structure was to create it at compile time and use it directly. Since there was ...
3
votes
1answer
41 views

Priority stack in Java

I have this (simple) data structure that maintains multiple LIFO stacks. Each such stack is assigned a priority. The less is the value of a priority key, the higher the priority. Pushing operation ...
7
votes
1answer
63 views

Simple inventory system - Part 2

I've refactored my previous inventory system, and added a few features like removing items from the Inventory class, easily obtaining the current selected item ...
2
votes
3answers
41 views

Transforming data from an array of objects to a nested array of objects

I have an array of objects where each object has a datetime key/value pair: ...
6
votes
1answer
340 views

Very simple inventory system

To learn F#, I've implemented this very simple inventory system. While I'm proud that that it's my first program, and that it works, there are still a few areas that I'd like tips on, namely these: ...
2
votes
1answer
26 views

Chained hash table implementation to store student's information

This is my implementation of a Hash Table to store information about a student. Everything seems to work as expected, but I'd like some feedback on the following: Is my style good? Is it easy to ...
3
votes
1answer
76 views

Detecting cycles

This is a challenge question from codeeval.com: Given a sequence, write a program to detect cycles within it. Input sample: Your program should accept as its first argument a path to a ...
4
votes
1answer
69 views

Trie data structure in Java

I have implemented a trie data structure in my way, though it is very similar to what major implementations I found but would like to get it reviewed by experts. I don't see the need to store ...
2
votes
0answers
31 views

Inheritance across data in JavaScript

I'm creating a JavaScript app for a esoteric language, Marbelous. One of the features of this language are the devices. Each cell has a device, and each device has certain properties. In order to ...
-5
votes
1answer
66 views

Date Range Tree

...
5
votes
0answers
34 views

Finding most frequent words from Google N-Gram dataset

I have written a program to process Google 1-Gram dataset in order to obtain the list of most frequent words. This is my second more or less working program in Haskell, so I really want to know if it ...
0
votes
1answer
46 views

Implementing find middle element of singly linked list without using 2 pointers

There is a solution floating around about using 2 pointers. But I decide to keep the implementation much simpler by using basic constructs that works use to build basic methods of a singly list list ...
8
votes
5answers
559 views

Find longest lines from a file

This is a challenge question from codeeval.com: Write a program which reads a file and prints to stdout the specified number of the longest lines that are sorted based on their length in ...
7
votes
1answer
47 views

Querying houses similar to a given house

I was given this task as an interview coding challenge and was wondering If the code is well structured and follows python guidelines. I chose to sort the houses based on a similarity metric and then ...
3
votes
5answers
205 views

Making ArrayList.containsAll run faster

Whenever using ArrayList, the method containsAll(collection) runs in time \$\mathcal{O}(mn)\$, where \$n\$ is the size of ...
5
votes
1answer
125 views

Caterpillar uneaten leaves

K caterpillars are eating their way through N leaves, each caterpillar falls from leaf to leaf in a unique sequence, all caterpillars start at a twig at position 0 and falls onto the leaves ...
11
votes
3answers
962 views

Fastest and minimal random access data structure in Java

I have written up a data structure in Java that supports the following features: get(i) set(i, e) ...
1
vote
1answer
36 views

Interface for fixed-size container supporting max, min, sum

I had posted this previously as part of Generic container similar supporting PeekMax, PeekMin, Sum, and PeekNextToMax but I think it was to big a morsel for people to chew on. So I'm splitting it up. ...
3
votes
3answers
68 views

Dynamic resizeable array

How can I improve this code for a dynamic and re-sizable array data structure? Array.h ...
6
votes
1answer
63 views

List querying capabilities in Python 3.x

Either out of boredom, or my odd fascination with LINQ and SQL, this, thing, was created. Essentially, it provides list querying capabilities. At the moment, you can only query lists based on ...
3
votes
2answers
55 views

Linked list insertion

I have written the code below for inserting an element at the position specified by the user. I have seen the code in multiple books, and they have always used two pointers in the function that ...
2
votes
2answers
77 views

Maintaining a single collection subdivided by a value's property

I'm working on a networked game. In this game, the base entity is called an actor. An actor can either be replicated or local, with each instance having a "replicates" field that represents this. ...
-1
votes
1answer
60 views

Singly linked list with generics and comparable data [closed]

I am currently reading about the thread-safe implementation of a linked list. Although I implemented this linked list while keeping in mind the issues from the first code review (Binary Tree). I would ...
5
votes
1answer
54 views

Generic container similar supporting PeekMax, PeekMin, Sum, and PeekNextToMax

I needed to implement a data structure that supports the following operations: create from an existing collection get the maximum item ("Alpha") get the nearest-to-maximum item ("Beta") get the ...
0
votes
1answer
31 views

Implementing quicksort with pivot of first, median or random

I am attempting to implement the quick sort algorithm whereby the pivot will be chosen by the user, and can either be median, first, or random. I am supposed to return a ...
3
votes
2answers
76 views

Add two numbers represented by linked lists

I've just encountered this question and am trying to solve it using Java. Here is my solution to it, which may not be optimized or might not be right way to do it. Someone please review whether it is ...
3
votes
0answers
51 views

Representing trajectory points using inheritance

Problem Background I need to represent trajectory points and trajectories (encapsulating these points) in the form of a collection of classes. All trajectory points have two essential elements: time ...
4
votes
1answer
84 views

F# sudoku game logic

I am trying to create a sudoku game in f# and I'm having a bit of trouble with the file reading and writing. But since I've also just started programming in f# I would like to check if my thinking is ...
1
vote
3answers
317 views

Isomorphic Strings

Two strings are isomorphic if the characters in s can be replaced to get t. Can efficiency be increased further for this code? ...
3
votes
3answers
168 views

Speed up large calculation of intersections

I have the following data: trains is a dictionary with 1700 elements. The keys are the IDs of trains and the value for each train is an array with every station ...
2
votes
1answer
42 views

Linked List Operations in C Read Proof

I am trying to write up all the linked list basic operations (push, pop, add_at_end, pop_from_end, add_at_index, pop_from_index). This is not a school assignment, even though it may look like one. I ...
2
votes
0answers
105 views

A map class based on an AVL tree

Here's an implementation of a class which is similar to std::map, but it's not a complete/identical implementation. I know C pretty well, but am a beginner with ...
11
votes
1answer
134 views

Data item prototype in a Javascript data structure where object instance functions see own data

I'm working on a complex Javascript application which includes its own data structure. The previous version's data structure was rather chaotic, and I'm looking to replace it with something where: ...
4
votes
1answer
96 views

Self Implemented Hash Map Performance

I have written two hash map implementations, one that stores Vertices and one that stores self implemented vectors of Edges. They are all fully functioning, however in my application they are quite ...
1
vote
0answers
20 views

Container with allocator copy assignment

I am trying to write a simple Buffer container class that will behave like std::vector. It should construct only elements that ...
1
vote
1answer
64 views

Graphs processing in Scala

I've just started to learn Scala and decided to implement small graph library to train. Here is the basic version, that describes graph and nodes structure and also provides implementation of ...
6
votes
2answers
155 views

Building in the built-in declarations

In order for Rubberduck to be able to "recognize" the built-in VBA functions, procedures and objects, I added yet another constructor parameter to my Declaration ...
2
votes
2answers
96 views

Better method structure for insertion in doubly linked list

Here is my insertion method for a doubly linked list. It works, but passing two parameters for the method seems cumbersome. Can anyone suggest a cleaner approach than this? ...
2
votes
0answers
43 views

Representing a dataset and a 'window' of data

This bit of code defines a structure which represents a dataset (in this case, a GDAL dataset and some meta-information) and also a 'window' into that dataset. The window is a portion of data from ...
3
votes
2answers
106 views

Suffix array construction in \$ O(n \log^2 n) \$

Here is my implementation of the suffix array construction algorithm which follows this paper (specifically, pages 4 and 6). ...
8
votes
3answers
249 views

Suffix tree implementation in Java

I was trying to solve the problem where given a larger string and an array/list of smaller string, we need to make the determination whether the larger string contains each of the smaller strings. I ...
1
vote
1answer
43 views

Minimal Map implementation with weak values

What follows is an implementation of the java.util.Map interface with weak values. This means that entries should be removed from the map when their values become ...
4
votes
1answer
98 views

Simple stack and linked list

I know that Python has a built-in list data structure, but I want to implement my own linked list and stack data structures for practice. I have three classes ...
1
vote
1answer
75 views

Max-heap implementation with List

I am trying to create max-heap for practice. Are there any bugs? Are there ways that I can improve the code quality? ...
12
votes
1answer
169 views

Torus Maze Generator

I have been working on a project to randomly generate a torus made through the use of an adjacency list and disjoint set structure (to be extended to solve the maze later), made from scratch. I think ...
2
votes
2answers
105 views

Find non duplicate Triangle Triplets from a list of given numbers- version 3

It is a continuation of my previous question: Find non duplicateTriangle Triplets from a list of given numbers After I realized triplet structure using less space than ...
2
votes
2answers
146 views

Graph adjacency list implementation in C++

I have been playing around with an adjacency list implementation of a graph class, on which I'd like to be able to run a build and test several graph algorithms. The code I have below works and I have ...