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
vote
0answers
24 views

Concurrent hash map for memoization

I'm developing a concurrent hash map for DP memoization. The assumptions behind its design are the following: no erase operations are possible once the value corresponding to a key is written, it is ...
1
vote
0answers
68 views

What is this structure called?

So I've been writing this data structure for a few days, and now I'm really curious about what it actually is, and to get some critique on my logic. A branch, based on this usage, exists when a HEAD ...
1
vote
2answers
54 views

Correct way to delete elements from a ConcurrentDictionary with a predicate

I have written a caching wrapper class for ConcurrentDictionary. Basically it has a timer that checks if items are expired and removes them. Since ConcurrentDictionary does not have RemoveAll method ...
3
votes
1answer
57 views

Writing/reading data structure to a file using C++

I wrote some piece of code which reads and write multiple data structures on a file using C++. I would be grateful to get your feedback on what you think about the code (it works at least when I ...
1
vote
1answer
65 views

Create palindrome by rearranging letters of a word

Inspired by a recent question that caught my interest, I wrote a function in Python 3.3 to rearrange the letters of a given string to create a (any!) palindrome: Count the occurrences of each letter ...
0
votes
1answer
75 views

Dictionary Structure

I am brand new to dictionaries and coding and am hoping to get some suggestions on how I should structure my dictionary. I have a collector number which has meters connected to them. Each of the ...
1
vote
2answers
80 views

Check if a Binary Tree <String> is aBinary Search Tree

i'm understanding the question but wanna make sure if my implementation is correct or not =| The Q is : Write a method that accepts as its argument a BinaryTree object and returns true if the ...
1
vote
1answer
86 views

Singly Linked List (strings only)

This is my attempt at constructing a singly-linked-list with basic functions. I initially tried to build the whole list as a series of nodes, but ran into problems when trying to remove or pop ...
6
votes
4answers
155 views

Readability and Performance of my Trie implementation

As an interesting exercise in Python 3.3, I implemented a Trie (also known as a Prefix Tree). Example usages Create from list of key-value-tuples mapping = (('she', 1), ('sells', 5), ('sea', 10), ...
-1
votes
2answers
82 views

What is a good name for bidirectional dictionary structure? [closed]

I'm writing a generic bidirectional dictionary which will be a part of a (somewhat) public API. This is how the dictionary works: It will hold key-key pairs where key1 and key2 will be two different ...
1
vote
0answers
30 views

Is this code for getting the dependency tree of a file correct?

function dep_tree(graph,node,prev_deps){ return uniq(flatten(graph[node].map(function(child_node){ if (contains(prev_deps,child_node)) throw "Circular reference between ...
1
vote
1answer
98 views

Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the ...
1
vote
2answers
39 views

Mapping enum to enum - is this an efficient and elegant implementation

I need to map from one enum type to another. Here is the enum I am given: enum CfgFruitType { CFGNoFruit, CFGApple, CFGApricot, CFGBanana, CFGMango, CFGKiwi, CFGFig, CFGGrape, CFGMelon, CFGLemon, ...
1
vote
1answer
41 views

Refactor making a tree with hash input?

I initialized a tree using a nested hash as input, but when I recursively call Tree.new on the children, it doesn't seem to pass each child as a hash. As a pretty ugly, but working, alternative, I ...
1
vote
1answer
56 views

Double linked list with different dependencies

I need to connect different Task with a double linked list and different Dependencies which affect a calculation for which I need the values of both Task: public class Task { private ...
1
vote
2answers
98 views

remove all nodes with same value in a linked list

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
vote
3answers
110 views

remove duplicates from linked list

Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. The following is my code: ...
0
votes
1answer
53 views

2D Array: Retrieve the “Left” Item

I am creating a game that contains a Board and Pieces. The Board is basically a 2D array of Pieces. [Think smaller chess board] One of the things that I want to accomplish is to be able to retrieve ...
6
votes
3answers
356 views

Two Key HashMap

Background Would like to create a two-key map that is fairly generic. In the existing system, there are a number of ways to name a parameter for a report. Rather than re-writing each report (too much ...
2
votes
2answers
107 views

Need a suggestion for invert index structure in C++

I am trying to create an invert index structure in C++. An invert index, in this case, refers to image retrival system, where each invert index refers to a numbers of "Patch ID". (simply called "ID" ...
5
votes
1answer
118 views

STL-style deque class, please critique

I'm a C++ newb. I decided to write an STL-style class as an exercise. I followed a tutorial of sorts that I found online, but I also made some modifications. I'd like to hear any criticisms you folks ...
4
votes
1answer
80 views

Improving a priority queue sketch in Racket/Scheme

I just put together the skeletons for a priority queue using a binary heap in racket/scheme. Using racket/scheme is all about the educational experience and I was wondering if anyone wants to ...
4
votes
1answer
116 views

Need help optimizing orthogonal range search for a static kd tree

I'm trying to optimise my implemention of a static kd tree to perform orthogonal range searches in c++. My problem: The code performs slowly even for a small number of queries when the number of ...
1
vote
1answer
73 views

Standard Library-Like Linear Interpolation Table

Looking for a general review of a generalized linear interpolation table. Design decisions, anything that's missing, anything that could be clearer or simplified, any style considerations. Keep in ...
0
votes
0answers
69 views

Mapping ReadOnlyObservableCollection to another collection

I'm writing a WPF application and I have several ReadOnlyObservableCollection fields in my models. Suppose that I wanted to create a FooViewModel instance for each FooModel instance. FooModel has an ...
3
votes
1answer
64 views

delete a key in a trie

To delete a key from a trie, there are four cases: For the explanation of trie data structure, please check the following link: http://www.geeksforgeeks.org/trie-insert-and-search/ (1) Key is not in ...
1
vote
2answers
109 views

How can this code become cleaner and less error prone? Especially the binary search part

How could this code become cleaner? I think that the way I handle the interfaces and binary search could be improved. I am trying to understand how to structure such a code 9and usage of APIs) in a ...
1
vote
2answers
88 views

Partition a linked list arround an element

This is my code to partition a list into two parts according to a value. I.e. nodes smaller than value x should precede nodes larger than the value x. It seems correct. Any corner cases I am ...
2
votes
1answer
220 views

Returning Binary Search Tree Nodes in Zig Zag manner

I tried to implement an answer for the algorithm question given below. I implemented two different solutions. I couldn't decide which one is better. ( Maybe none ) Note: Node class and ZigZag ...
2
votes
2answers
142 views

Undirected, connected and weighted graph implementation

I was thinking in a way of implementing a graph in such that would let find a minimum spanning tree. I have this: Graph.h #ifndef GRAPH_H #define GRAPH_H #include <list> #include ...
2
votes
2answers
169 views

A* shortest path algorithm optimization request

Good day to ya'll. I had this programming excericise of mine where I had to find the shortest path to an exit in an NxM -grid maze in under a second (both N and M would be anywhere between 3 and ...
1
vote
0answers
357 views

Breadth- and Depth-first search code

Here is my breadth-first search (bfs) and depth-first search (dfs) code for graph traversal. Please give me some constructive reviews on it. Thanks for any help. #include<stdio.h> ...
1
vote
1answer
150 views

Is this a valid implementation of trie Data structure?

i am trying to learn Trie Data Structure and just implemented it without giving much attention to the code standards , its a raw implementation , can you guys help me to understand whether this ...
0
votes
3answers
190 views

Using a Dedicated Class & Constructor to initialize Stored Procedure for SQL Transaction

as i thought it will be sutible as a Quetion for SO... i started to describe the issue of my Problem, though as i completed Editing the post , i could see that it will better fit here, In CR. so to ...
3
votes
2answers
462 views

Inverse Document Frequency (IDF) implementation

I would like to share my class IDF with experts. Sorry for the poor data structure, but we are humans and still learning. Any Suggestion/ Modification please ?? many Thanks. public class IDFMeasure ...
2
votes
0answers
72 views

JavaScript basic game code structure tips

I'm learning JavaScript and came up with this basic game code structure (using the CreateJS framework): var stage; var totalLoaded = 0; var manifest; var game = game || {}; game.init = { ...
0
votes
2answers
84 views

How can I improve the run-time of my Java program?

I have a project for solving Diophantine equations, where a solution exists if A^5 + B^5 + C^5 + D^5 + E^5 = F^5, where 0 < A <= B <= C <= D <=E <= F <= N The program ...
2
votes
1answer
241 views

Objective-C Stack implementation

I'm a S.O. user, and this is my first question on Code Review, so please be lenient. (i actually thought about making a site like this myself at one point, but i LOVE this Code Review idea!). I just ...
6
votes
2answers
263 views

Which is the most correct pattern for using Stack.Pop?

There at least 2 patterns of using Stack.Pop private Stack<T> availableResources; ... if (availableResources.Count > 0) { resource = availableResources.Pop(); ... } private ...
2
votes
3answers
121 views

How to make a program bettter. Does it come with experience?

Hi guys look at the code given below. It is from my class work. It is a simple demonstration of a singly linked list. #include <stdio.h> #include <stdlib.h> #include <wctype.h> ...
5
votes
1answer
276 views

How can I improve my algorithm?

This is a problem from Interview Street in Dynamic Programming section. https://www.interviewstreet.com/challenges/dashboard/#problem/4f2c2e3780aeb Billboards(20 points) ADZEN is a very ...
5
votes
2answers
362 views

In Java, how to operate the sublists efficiently?

In my Java program, I need to operate on the sublists a of ArrayList or LinkedList often, like removing a sublist, comparing two sublists. For ArrayList or LinkedList, I didn't find any good APIs to ...
5
votes
1answer
99 views

Sparse Bitarray Class in Python (or rather frequently having contiguous elements with the same value)

Sparse is probably the wrong word - this is for encoding arrays of booleans where contiguous values tend to be the same. It'd be great to know a proper name for this data structure so I could read ...
9
votes
3answers
279 views

Reversing a linked list

I implemented reversing a linked list in iterative way, just by knowing we need 3 pointers and I have never seen a code before, when I coded. I ran this code and tested it, it works fine. Even for ...
7
votes
0answers
293 views

Scala: Disjoint-Sets

I would like to get some feedback on the following implementation of disjoint sets, based on disjoint-sets forests (Cormen, et.al., Introduction to Algorithms, 2nd ed., p.505ff). It should have the ...
4
votes
1answer
200 views

Partitioning Array

Problem: Given a randomly ordered array of n-elements, partition the elements into two subsets such that elements <=x are in one subset and elements > x are in the other subset. one way to do this ...
5
votes
1answer
814 views

A trie implementation for left to right wild card search

I was working on a task to implement auto suggest from an array of couple of thousands of strings. Ofcourse the first and the easiest implementable was to go through each element and do ...
3
votes
1answer
211 views

Javascript PriorityQueue based on object property

I am pretty new to javascript development and its temperaments. I wrote this class which is a priority queue based on a numeric property of any object. As far as I can tell, the following code is ...
5
votes
2answers
1k views

atomic_queue - thread-safe and lock-free implementation of the FIFO data structure pattern

please review my implementation of a FIFO data structure that guarantees thread-safe access without locking. I removed the license header block and all Doxygen comments. The original version (along ...
3
votes
1answer
74 views

mapM for both keys and values of Data.Map

I'm writing a monadic parser instance that transforms Data.Map.Map's: instance (Ord a, FromEDN a, FromEDN b) => FromEDN (M.Map a b) where parseEDNv (E.Map m) = mapMmap parseEDNv parseEDN m ...

1 2 3