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
28 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. ...
0
votes
0answers
14 views

Validating constant assignments in C at compile time [on hold]

This is a way to check constant variable assignments for meeting conditions, e.g. exceeding limits at compile time. That is, anything the compiler can optimize to be constant. The Program should emit ...
7
votes
2answers
219 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 ...
4
votes
2answers
64 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 ...
3
votes
2answers
61 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
58 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
99 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
105 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
255 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
59 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
56 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
118 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
218 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
57 views
1
vote
2answers
39 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
57 views
1
vote
0answers
31 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 ...
5
votes
3answers
66 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
647 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
29 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
111 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
200 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
51 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 ...
2
votes
2answers
63 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
131 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
64 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
51 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
62 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
88 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
55 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
351 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
60 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 ...
5
votes
2answers
143 views

Family finances - tracking and reporting

I am looking for clean way to accumulate amounts within a input dataset. In this example, there are 18 rows of data, and the output is a 3 rows of data, accumulated by Key, by ExpenseType. My ...
3
votes
3answers
92 views

Delete alternate nodes of a linked list

If the linked list is 1->2->3->4 then the output should be 1->3. If the linked list is 1->2->3->4->5, then the output should be 1->3->5. The question is attributed to GeeksForGeeks. I'm looking ...
1
vote
1answer
41 views

Remove all nodes which don't lie in any path with sum >= k

Given a binary tree, a complete path is defined as a path from root to a leaf. The sum of all nodes on that path is defined as the sum of that path. Given a number K, you have to remove (prune the ...
1
vote
1answer
59 views

Extract Leaves of a Binary Tree in a Doubly Linked List

Given a Binary Tree, extract all leaves of it in a Doubly Linked List (DLL). Note that the DLL need to be created in-place. Assume that the node structure of DLL and Binary Tree is same, only the ...
3
votes
4answers
1k views

Given only a pointer to a node to be deleted in a singly linked list, how do you delete it?

Example: If a linkedlist list contains 10->20->30->40, and 2nd node has to be deleted then the output should be 10->30->40 This question is attributed to Geeksforgeeks. Looking for code-review, ...
1
vote
1answer
108 views

Should this container be a struct or a class?

I have a class that serves purely as a data container for passing values from a parsing class to a class responsible for saving the data. I have been wondering whether it would be more appropriate as ...
3
votes
1answer
56 views

Getting the index (x,y) of a char in a “2D” list in Haskell

I have this working function circuitFind that I really don't find nice because I feel there is a better and simpler way to accomplish what it does. ...
1
vote
1answer
51 views

Delete nodes in linkedlist whose next node is greater

Given a singly linked list, remove all the nodes which have a greater value on right side. Examples: a) The list 12->15->10->11->5->6->2->3->NULL should be changed to ...
1
vote
3answers
66 views

Check if all leaves are at same level

Check if all leaves are at same level. This question is attributed to geek for geeks. Looking for code-review, optimization and best practices. ...
1
vote
1answer
84 views

Find union and intersection of linked list

Find the union and intersection of linked list, given that elements don't repeat in a single linked list. This question is attributed to GeeksForGeeks. Looking for code-review, optimizations ...
0
votes
1answer
87 views

Convert a doubly linked list into balanced binary search tree in-place

Given a doubly linked list which has data members sorted in ascending order, construct a balanced binary search tree which has same data members as the given doubly linked list. The tree must ...
2
votes
0answers
26 views

Binomial Heap in Haskell

Here's a partial binomial heap implementation in Haskell (just merge and insert): ...
10
votes
1answer
101 views

Object pool implementation

Below is my implementation of a pool. It is based on a hash table and supports using strong, soft or weak references to store objects. At the start there is a builder class to configure and create ...
1
vote
1answer
74 views

Deepest left leaf node in a binary tree

Given a Binary Tree, find the deepest leaf node that is left child of its parent. This question is attributed to GeeksForGeeks. Looking for code-review, optimizations and best practices. ...
6
votes
2answers
136 views

Flatten a multilevel linked list

Given such a structure the output should be ...
3
votes
1answer
65 views

Reverse values of alternate nodes of the tree

Given a Perfect Binary Tree, reverse the alternate level nodes of the binary tree. Given tree: ...
0
votes
2answers
56 views

Return the next right node

Given a binary tree, return the next right node. This question is attributed to GeeksForGeeks. For example, consider the following Binary Tree. Output for 2 is 6, output for 4 is 5. Output for 10, 6 ...
4
votes
1answer
33 views

Synchronized LinkedHashed map

I've written the following code ages ago (10+ years) which is part of a simple chat server. I'm going to refactor it a bit in java and then for fun I'm going to convert it to Scala and use Akka actors ...