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

3
votes
2answers
37 views

HTML/Attrs Tester Environment

I have a few objectives (which are working fine, but I want tips in case I can improve it). Let me try to make this as clear as possible, as this is a much larger project: There are three move ...
1
vote
0answers
19 views

numpy array as quasi-hash table

Motivation: I have a large number of large read-only dicts with large string keys mapped to tuples of two floats. They are taking up a large amount of heap space. Proposed solution: a 3xn numpy ...
2
votes
1answer
36 views

What's more idiomatic in Haskell?

I'm writing the data structures for my program (a toy compiler), and I'm trying to understand what's the best way to define the AST: Current code ...
4
votes
1answer
70 views

Ring buffer - can I do any improvements?

I was just reading about ring buffer the other day and I was fascinated by how simple yet efficient it is. So I've implemented a ring (circular) buffer in ruby and I'm just wondering if there's ...
11
votes
2answers
94 views

Parsing Valve Map Files (VMF) into a tree like structure

I've written a small library of objects for parsing of Valve Map Files (VMF). These files are always generated and exported from either the Hammer World Editor, or a Source engine built in map making ...
5
votes
2answers
275 views

Comparing list elements in an effective way

I have a list of opened nodes, with each step about 3000 nodes are opened and I want to put to the opened list only those nodes that are not already there. For now I'm just comparing each new one to ...
3
votes
1answer
36 views

Converting float from arbitrary base to arbitrary base

I needed to write a small program to convert floats from any base to any other base. The thing is, it got big. I know there are other ways to implement the conversions (such as doing subtractions ...
9
votes
1answer
63 views

Binary Tree/ Amorphous Binary Tree Creator

I suppose this is a two-part question. The first part is just a simple implementation of a Binary Tree (BTree), with pre-order, post-order, and in-order searches ...
5
votes
2answers
76 views

Binary Tree/Knowledge Base design C++

Currently I have a binary tree template setup where my main is using it with strings to make a question/answer game. I'm using a knowledge base that works as an interface to the binary tree that main ...
6
votes
3answers
115 views

How to extract elements from multiple sorted list efficiently?

Problem Statement:- I was ask this interview question recently.. I was able to come up with the below code only which runs in O(k log n)- Given k <= n sorted arrays each of size n, there exists ...
5
votes
4answers
86 views

Array of Objects or Array of arrays?

I build phone apps and I use JSON a lot in my APIs. The problem is sometimes I don't know how to format the JSON data. For example, an iOS UITableView takes ...
6
votes
1answer
181 views

Implementation of binary heap in C++

Things I can think of include integer overflow, if the input type is int, etc. But other than that, what do you think is wrong with this code, design-wise, style-wise, and also in terms of other ...
2
votes
1answer
73 views

Printing the values on each level of a Binary Tree

The below code is for printing level-by-level in a binary tree: ...
10
votes
2answers
130 views

Thread-safe prime number source

I am working on some multi-threaded code that requires a prime-number source. The following code keeps an array of primes in memory, extending it as needed. It works in the 'int' domain, being ...
5
votes
2answers
114 views

Linked list implementation in C

I'm learning C for mainly for fun and to get a better understanding of how things work under the hood (most of my experience lies with high-level languages). I've been following quite a few books and ...
2
votes
1answer
60 views

Best structure for a Person in PHP classes (and databse)

I am (in the process of) creating a system to store People and their details - names, date of birth (dob), addresses, phone numbers, etc. - and I'm curious how it is best achieved. Below is an an ...
2
votes
1answer
60 views

Bidirectional map based on memory manipulation

This is a bidirectional map implementation that stores the values as pairs on the heap, and uses pointer arithmetic for efficient lookup. codepad link, may be easier to read ...
9
votes
3answers
284 views

Checking brackets nesting in a string

I took a training challenge on Codility that checks for the proper nesting of brackets in a string. The brackets to be checked are {,},(,),[,]. I have written the ...
5
votes
2answers
106 views

Conjugation Tables - Efficiently Handling the Data

I'm in the process of structuring a model for conjugation tables for French. There are noun inflections, adverb inflections, and (19) verb conjugations. I'm trying to model the data so that every ...
3
votes
2answers
63 views

Partial octree implementation

I am just now learning Scala a bit on my own time. I wrote some code that works, but was wondering if you could eyeball it to see if its structure can be improved. It is a partial octree ...
0
votes
1answer
115 views

Find the mean of the medians of two equal sized sorted arrays [closed]

A corrected solution is found here Looking for code review, clever optimizations, adherence to best practices. etc. As an example: a1[1, 3, 5, 7] a2[2, 4, 6, 8] The median for each array is the ...
4
votes
2answers
57 views

What's the fastest way to get the points I want out of a huge blob?

In MATLAB I have a set of 5393280 points in the form of a decimal-valued vector (x,y,z). How do I represent them in a way that I can quickly collect all the points within some rectangular x-y domain? ...
3
votes
1answer
83 views

Inorder traversal of a tree without recursion or stack

Please review the code for code cleanup, smart optimizations and best practices. Also verify my complexity: O(n2), where n is the number of nodes ...
4
votes
1answer
34 views

structure for dependent picklists

I have 3 dependent picklists so that Category picklist values depend on Group values and SubCategory values depend on Category. What is a good way to define the structure in Javascript that ...
5
votes
1answer
54 views

Unbalanced binary search tree

I wrote this unbalanced binary tree and would like to know how to improve the code and performance. If you can point out any situations that are not being handled appropriately, that would be great ...
3
votes
2answers
100 views

Dynamic stack in C - new version

Not long ago, I posted this dynamic stack for review. Now I wrote a new version, which is hopefully a better one. Please take a look and let me know how I could improve performance and increase code ...
2
votes
0answers
826 views

Reading columns and rows in a .csv file

I have some data in a .csv file, which looks roughly like this: ...
10
votes
3answers
160 views

Please review my C code for a double linked list. Are there memory leaks I'm not seeing?

I've run my code through Valgrind and managed to not get any memory leaks based on the test code in main. I'm looking for things that I may not have thought to check for, and ways to improve my code ...
3
votes
2answers
88 views

Constructing a binary tree in java

I am constructing a binary tree. Let me know if this is a right way to do it. If not please tell me how to?? I could not find a proper link where constructing a general binary tree has been coded. ...
6
votes
2answers
132 views

Holding server response header data after parsing it

I'm creating a program to retrieve web content in order to learn how these things work. I would like it to be as correct as possible, ideally fully compliant. But I'm not sure this is the right ...
4
votes
1answer
135 views

In-memory data cache architecture for data transfer

I am writing a cron job to manipulate and transfer remote data. I need to cache data from a table, process it, merge with previous table, iterate the process, and eventually send the result data to ...
4
votes
2answers
81 views

Making an array whose elements are defined by a struct [closed]

This might be a basic question for C. I'm making a struct called check_t and I want to make an array whose elements are of type ...
2
votes
1answer
49 views

Join of two databases

This is the most basic code to join two tables in a database. For tables it uses a simple list. Solved this using brute force, sorting and using hashtable. ...
1
vote
0answers
81 views

In-memory data cache architecture

I am designing basic in-memory cache storage with thin CRUD (actually CRD) interface. The design is inspired by the Backend solutions such as Parse and StackMob. Main requirements: Cache consists ...
1
vote
1answer
95 views

Combinatorial searching of Huffman trees

I need to search some data encoded by a Huffman tree, but not by simply walking the tree: I need test combinations of the data for a property and continue searching based on whether the test is ...
0
votes
1answer
29 views

Optimised library database code for sorted array of structures

I have an array of structure records and function intersection and difference. The ...
2
votes
2answers
7k views

Stack implementation using linked list

This is a working stack implementation using a linked list. I'm just curious to know if this is a good way of doing it. Any suggestions are welcome. Can we keep track of the number of elements in ...
1
vote
1answer
1k views

Design LRU cache interview questions

Code reviewers, I request you review the code and suggest all tips for improvement. ...
4
votes
3answers
776 views

Flatten iterator for nested list

Given a list which can can contain elements as well as lists, write an iterator to flatten a nested list. Please make this code better and suggest any improvements. ...
5
votes
2answers
584 views

Implementation of Dijkstra's algorithm

Please pick my code apart and give me some feedback on how I could make it better or more simple. ...
4
votes
2answers
100 views

Can someone review my Rational implementation?

The header file can be viewed here. ...
1
vote
1answer
34 views

Can someone review my Polynomial data structure?

The following is working but I just want to know if I can make it better in any way. The header file can be viewed here. ...
1
vote
1answer
243 views

Can someone review my doubly linked list?

Here is the implementation with the interface below: ...
1
vote
1answer
42 views

FixedSizePriorityQueue - Review Request

I implemented the FixedSizePriorityQueue class. The intended purpose is that, you can add as many elements as you want, but it will store only the greatest ...
2
votes
2answers
248 views

Generic binary search tree implementation

I use this interface for my BST node class: ...
6
votes
1answer
173 views

MaxHeap implementation

I'd like this to be reviewed: ...
2
votes
1answer
114 views
1
vote
1answer
340 views

Trie - code review request for improvement

Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple. ...
-1
votes
1answer
173 views

Join levels of binary tree

Please ignore feedback to include generics and function renaming while giving me feedback. Names of functions have been deliberately kept the way they are for time-being. Also please let me know if ...
1
vote
1answer
2k views

Create a binary tree, code review request

Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple. ( Generics would be added a bit later). ...