Tagged Questions

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
0answers
27 views

A reversed-string Trie data structure

This is a simple Trie data structure for strings, except it puts the strings into the structure backwards. The insert method simply iterates over chars from the string-to-be-inserted backwards, and ...
5
votes
2answers
99 views

Limited memory priority queue

I'm trying to implement a highly efficient limited memory priority queue. The interface is the same as a std::priority_queue. Can anyone suggest any performance ...
3
votes
1answer
84 views

Public interface for nearest neighbor data structures

I am making a small library of metric data structures. That is data structures, which associate points in the n-dimensional space with objects and allow the user to find objects which are closest to a ...
2
votes
1answer
38 views

Graph Implementation in Java 8

Here is my code which implements a simple directed graph in Java 8. Here are some of the things I am unsure about: I am fairly new to Java 8 concepts. Have I used the new API correctly (and not ...
4
votes
1answer
91 views

Generate Cartesian product of List in Java

My code, which generates Cartesian product of all lists given as arguments: ...
2
votes
1answer
37 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
2answers
57 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 ...
2
votes
0answers
35 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
57 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
64 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
36 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
3answers
90 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
192 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
56 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
62 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
126 views

Implementing an ArrayList

I implemented ArrayList functionality in C as follows: ...
3
votes
3answers
111 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
54 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
26 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
67 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
264 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
82 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
80 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
79 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
121 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
365 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
68 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
61 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
233 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
61 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
72 views
1
vote
0answers
51 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
215 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
671 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
39 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
469 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
211 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
77 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
102 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
168 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
71 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
68 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
133 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 ...