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)

4
votes
1answer
60 views

Generate Cartesian product of List in Java

My code, which generates Cartesian product of all lists given as arguments: ...
2
votes
1answer
34 views

Binary Search in C

The standard C library function bsearch wasn't giving me correct results, apparently. So I decided to implement a binary searching function in place of it. It ...
0
votes
1answer
37 views

Optimizing Dijkstra implementation using PriorityQueue in Java

I am trying to make Dijkstra implementation more efficient. Below is the code for class Node which implements Comparable so it ...
0
votes
0answers
24 views

Best approach to a defined datascructure [on hold]

I've here a TXT file with some data that I can't change. So I have to create a datastructure to read this file and with that datastructure do some thousands of iteractions. The file follows a ...
2
votes
0answers
30 views

Binary Search Tree in Ruby

Binary Search Tree, with preorder traverse. What other methods should I add? How can I improve it? ...
3
votes
1answer
52 views

Bloom filter implementation using a BitArray

I am following the Wikipedia definition of the Bloom filter. My implementation uses the BitArray I created in Bit Array in Ruby using integer as a storage. An ...
3
votes
1answer
60 views

Bit Array in Ruby using integer as a storage

Ruby's Fixnum & Bignum can hold very large integers and automatically handle overflow. I decided to implement BitArray using an integer as storage. Please let me know what you think about code and ...
1
vote
0answers
20 views

Multiset implementation in Ruby -Take 2

This is a follow up to question. I fixed the issues mentioned in the answer as far as my understanding. The union and intersection now return new object instances with new implementation. I also wrote ...
2
votes
1answer
34 views

Multiset implementation in Ruby

I am trying to implement the wikipedia definition of a MultiSet. Need feedback on implementation. Also I am not sure how to implement cartesian product. ...
6
votes
2answers
58 views

Making backtracking Knight's Tours solution more efficient

This was a previous homework assignment I was required to do. While I did the assignment and turned it in for credit, I am not completely satisfied with the result I have. The rule for the assignment ...
17
votes
2answers
189 views

Wait, is this… LINQ?

Context I'm working on a little project that consists in a series of Microsoft Excel add-ins (.xlam). The code being submitted for review here, is located in the ...
0
votes
0answers
5 views

Normalized Database Diagram [migrated]

So I am working on my DB design skills, and have tried to create a normalized MySQL database. Here is the diagram: The reason I added the Address table is to break the address fields into separate ...
0
votes
2answers
54 views

Populate inorder successor for all nodes

Given a binary tree where each node has following structure, write a function to populate next pointer for all nodes. The next pointer for every node should be set to point to inorder ...
0
votes
1answer
28 views

Get Height of Tree

Given the following Abstact Data Type: ...
1
vote
1answer
56 views

Create a complete binary tree

Write a program to create a complete binary tree, which includes an addItem method such that an individual element can be inserted into the tree to maintain the ...
4
votes
3answers
125 views

Implementing an ArrayList

I implemented ArrayList functionality in C as follows: ...
3
votes
3answers
107 views

Speeding up storage of about 220000 values in Core Data

I use this code on the app's first run to save about 220000 values into core data. The file Navaids.txt has about 200000 and Waypoints.txt has about 20000 lines, where I get data from each line and ...
-1
votes
1answer
50 views

ArrayList implementation in C [closed]

Although I know I can use calloc then realloc to make a dynamic array in C, and that I also need a variable to keep track of the ...
2
votes
2answers
25 views

Enforcing Type with Boiler Plates

This is an implementation of Mat's List using by Pseudo-inheriting my Pythonic-List. Inheritance is not built into VBA, but it can be simulated by composing the inherited class and mimicking all it's ...
1
vote
1answer
66 views

Creating a Custom Set Data Structure in Ruby

I wrote a set DS with some useful functions. Not sure if it is a good implementation and if there are other essential functions that a set should support. ...
10
votes
2answers
259 views

Simple key-value store in C, take 2

Followup to Simple key-value store in C. Response to previous reviews You may want to hide the KVSstore structure Done. Add a comparison function pointer to KVSstore. If this pointer is ...
5
votes
2answers
79 views

Simple key-value store in C

I needed a simple key-value store. Here's what I came up with. Usage Use kvs_create and kvs_destroy to create stores and clean ...
4
votes
2answers
79 views

Traversing and printing complex Dictionary types (Scripting.Dictionary) - Dictionary inside of a Dictionary

Based on this SO post - also reposted on vba4all.com with a few more details and explanations. Please notice there currently is no error handling whatsoever as I didn't analyse and consider any traps ...
2
votes
1answer
78 views

Autocomplete Trie Optimization

I'm currently playing with the Typeahead problem on Talentbuddy. There are already 2 questions on this subject (Typeahead Talent Buddy and Typeahead autocomplete functionality challenge), but none of ...
10
votes
3answers
120 views

VBA Python-like List Class

VBA's Collection class is lacking so I created a basic List class using Python's as a template. This could make future derived ...
5
votes
4answers
109 views

Dynamically-sized stack - follow-up 3

Follow up of - Dynamically-sized stack - follow-up 2 I've took the tips given to me, and what I did now is: Use same case type for type stack and it's functions Returning 1 if push failed due to an ...
4
votes
1answer
349 views

Queue Implementation using a Linked List

For understanding the concepts, I've implemented the Queue data structures using a linked list. Is there anything to improve? LinkList.java ...
9
votes
1answer
65 views

Yet Another Fraction

A recent question inspired me to implement a Fraction class. I decided to write this one in vba, because I like writing tools for the poor souls that still have to ...
6
votes
1answer
60 views

Dynamically-sized stack - follow-up 2

Follow up of - Dynamically-sized stack - follow up I've took the tips given to me, and what I did now is: changing the function names to have a prefix making the ...
4
votes
2answers
129 views

Dynamically-sized stack - follow up

Follow up of - Which is a better implementation of a stack data structure (based on an array)? Please review my stack implementation from before. I've made it dynamically sized if needed and made a ...
1
vote
3answers
229 views

Find the Max Width Of Tree

1 / \ 2 3 / \ \ 4 5 8 / \ 6 7 Width of a tree is maximum of widths of all levels. For the above tree, width ...
2
votes
1answer
60 views
1
vote
2answers
45 views

Number of maximal PAIRS-values

I had an interview question like this: In a company there are different people. One can measure how well they suits for pair coding as follows: First, let us compute the PAIRS-value which ...
2
votes
2answers
70 views
1
vote
0answers
47 views

Lightweight tabulation written in Python

I wrote this module in python for some minor tabulation needs in my science projects. This was very helpful for testing, debugging and plotting various data. I often use dictionaries for storing such ...
7
votes
3answers
211 views

Bubble sorting in C

I've been into algorithms lately, so I wanted to apply a simple algorithm using a language of my choice, which was C in this case. I've implemented the bubblesort algorithm (for strings) in a simple ...
7
votes
3answers
663 views

Managing student budgets

I have just started to play around with C++ and I want to make my code efficient and clutter free. Please critique this code constructively and give feedback that will help me in my programming ...
0
votes
1answer
35 views

Find swapped nodes in BST

A BST has two nodes swapped. Figure out which two nodes. Looking for code-review, optimizations and best practices. ...
0
votes
2answers
361 views

Josephus Problem in Java

Problem The Josephus Problem is a famous mathematical puzzle that goes back to ancient times. There are many stories to go with the puzzle. One is that Josephus was one of a group of Jews who ...
10
votes
3answers
209 views

Scorekeeper for a game

The code is not for any project, I just want to know the best coding practices. The code is also on GitHub. ...
4
votes
1answer
68 views

Implementation of a AVL Tree

I attempted to write a AVL Tree in a functional style and I am hoping to get it reviewed. I am looking for the code to be clear and concise, any opportunity for improvement would be greatly ...
3
votes
2answers
101 views

Print all nodes that are at distance k from a leaf node

Given a binary tree and a positive integer \$k\$, print all nodes that are distance \$k\$ from a leaf node. Here, the meaning of distance is different from the previous post. Here, \$k\$ ...
3
votes
3answers
167 views

Find floor and ceiling in the BST

Find ceiling and floor in the BinarySearchTree. Looking for code-review, optmizations and best practices. ...
1
vote
3answers
70 views

Find all possible interpretations of an array of digits

Consider a coding system for alphabets to integers where 'a' is represented as 1, 'b' as 2, .. 'z' as 26. Given an array of digits (1 to 9) as input, write a function that prints all valid ...
0
votes
1answer
64 views

Maximum sum between two leaf nodes

Given a binary tree in which each node element contains a number. Find the maximum possible sum from one leaf node to another. The maximum sum path may or may not go through root. For ...
-2
votes
2answers
66 views

A struct within a class [closed]

I have a struct lying in a class as below, which I think is not good. Structs should be in a separate file, however, in this case, this struct is only used in a ...
0
votes
1answer
125 views

Check if two nodes are cousins in a Binary Tree

Given the binary Tree and the two nodes say ‘a’ and ‘b’, determine whether the two nodes are cousins of each other or not. Two nodes are cousins of each other if they are at same level and have ...
1
vote
2answers
56 views

Implementing DAO with SOLID

I might not be keeping with Single Responsibility with my DAO. I also implement a custom observable through update. It makes sense because when something changes in the data, then it makes sense for ...
3
votes
4answers
565 views

Delete duplicates from unsorted linked list

E.g: if a linked list contains 2->3->1->3->4 then the result should be 2->3->1->4. Notice that 3 has been eliminated. This code is attributed to GeeksforGeeks. I'm looking for code-review, ...
2
votes
2answers
74 views

Find a triplet from three linked lists with sum equal to a given number

Given three linked lists, say a, b and c, find one node from each list such that the sum of the values of the nodes is equal to a given number. For example, if the three linked lists are ...