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.
3
votes
3answers
37 views
Implementing a singly LinkedList and IList interface
I have implemented a LinkedList in C#. What would you change/make better? What naming conventions are misused? What would you add? Some of my ideas are to make it ...
3
votes
1answer
36 views
Finding the shortest substring containing keywords
Problem: Write a function that takes a String document and a String[] keywords and returns the smallest substring of ...
6
votes
4answers
401 views
Recursive binary search tree - follow-up
This is a follow-up to
Recursive binary search tree
changes:
Used raw pointers rather than std::unique_ptr
const correctness
Made variable names more beautiful
implemented at()
How can I improve ...
4
votes
3answers
292 views
Preorder, inorder, postorder for tree in C++11
Please review my code for preorder, inorder and postorder of a tree. I am using C++11 (or wanted to use), so let me know if anything is deviating from the C++11 standard.
...
1
vote
0answers
25 views
Hash Table Implemented by Javascript
I recently tried to implement a simple hash table using Javascript. Could anyone help me review my implementation?
...
1
vote
2answers
74 views
Counting a cycle
An interview question I got -
Each element of an int array points to the another element,
eventually creating a cycle. Starting at ...
4
votes
1answer
49 views
Circular linked list in C
Let me know if it seems right to you and if anything can be optimized. My concern is that I'm unsure if circular linked lists are supposed to have a tail. I've implemented it just using a head. Is ...
2
votes
2answers
44 views
Doubly linked list code in C
Let me know if it seems right to you and if anything can be optimized.
...
0
votes
0answers
18 views
Implementing Binary Search Tree in JavaScript - remove function [closed]
Here's my implementation for a Binary Search Tree in JavaScript. In addition to asking for a code review, I'm also hoping you can help me with the remove function I ...
3
votes
1answer
73 views
Circular queue implementation using two regions
Inspired by the "bip buffer", I coded a fixed-size circular queue that uses two regions (two pairs of begin/end pointers) to account for the wrap-around.
The main goal of this design was to simplify ...
3
votes
0answers
51 views
Binary heap with O(1) lookup and O(log n) change key
I needed a priority queue that allowed efficient searching and changing of keys. I tried std::priority_queue, but the interface was extremely limiting. Not being ...
5
votes
2answers
86 views
Find if a word with wildcard exists in dictionary [closed]
This is a question from a phone interview I had.
The question was in 2 parts:
a. find("cat") -> T/F suggest a data structure to find is if a word
exists in a large dictionary, how will one node ...
6
votes
1answer
66 views
Networking in iOS Swift
This piece of code is working - It gives me a lot of JSON back, which I have yet to parse, but I'd like to show my code here first to get tips on how to improve what I already have:
...
2
votes
1answer
111 views
Graph implementation adjacency list 1.0
Please note the following:
All edges are directed
Removal of edges/nodges is not implemented yet
A user of the class Graph can never (hopefully) access a ...
4
votes
0answers
62 views
Find all the paths of tree that add to a input value
This code is attributed to Stack Overflow itself here. The path which adds to the sum, which need not be starting from the root, not be ending at the leaf, i.e. a path can be between root and a leaf.
...
6
votes
3answers
70 views
Removing duplicates without using a temporary buffer
This question is from Cracking the Coding Interview and in this question they have asked to solve without using temporary buffer.
I have used Iterator interface. Can I use it or need to re-implement ...
6
votes
1answer
57 views
Simple Linked Hash Map in JS (node/browser)
I needed a simple data structure to cache the most recent few directory contents for this project I was working on. I thought a Linked Hash Map would be the right approach since we will cache only one ...
6
votes
2answers
222 views
HashTable implementation
I have been trying to implement the Hash Table function in Java and here is what I came up with. I would just like to get an opinion on this work. Would there be a better way or any improvement to ...
0
votes
1answer
57 views
Implementing a stack using a simple array, dynamic array and linked list
I have implemented a stack using simple array, dynamic array and linked list. I am requesting a review of this code.
Interface for stack:
...
3
votes
1answer
79 views
Deepest node in tree
I have written two classes, one to represent the tree and a Util class to get the deepest node from the tree. Can you please review the code?
Below is the class ...
3
votes
1answer
42 views
AVL tree implementation in C
I have an assignment. I need to write an AVL tree. This is what I have written so far. It works on all of my tests, but suddenly fails in checking system with TL(time limit exceeded).
Personally I ...
4
votes
3answers
170 views
Custom SkipList implementation in Java
I recently studied SkipList and thought i would create one on my own. This implementation uses a 2 layer Skip list where the size of the support list is roughly square root of the size of the original ...
2
votes
1answer
33 views
Manipulate JSON data from the client with JavaScript
I am making an application in which the user has the ability to add, remove, and edit JSON data through DOM interaction. I have created a working JavaScript-only prototype that accepts certain ...
3
votes
3answers
149 views
AVL tree for inserting and searching
I have made an AVL tree. It works and does what it needs to do. I only need it to insert and search. I am comparing how long it takes to load and search a dictionary file in relation to other various ...
3
votes
0answers
59 views
Djkistra shortest path implementation for adjacency list represented graph
Please review the implementation of Djkistra algorithms. Points on which I have doubt:
My Graph doesn't have any ID for nodes. Nodes are accessed based on their ...
4
votes
1answer
81 views
School which registers students by preferred courses
The point of the application is to create a school, create courses for that school, create students and register them to the school, assigning them courses based off the courses they prefer.
There ...
2
votes
1answer
72 views
File input and sorting averages with movies
So far I have Java code that will:
take in two .csv files
store each line as a string in a string array
split it into a 2D string array where a comma would act as the separator
sum the number found ...
3
votes
0answers
54 views
Treap with implicit keys
I implemented an implicit treap and tested it a little. It works fine but I'd like to know if there are ways to improve/simplify things and/or if some parts are incorrect. Later, I'll augment code to ...
0
votes
1answer
64 views
Pure fixed length queue
I am modeling an infectious disease with a fixed incubation period. I chose a queue to keep track of when people become symptomatic. I imagined using some operations like so:
...
11
votes
3answers
498 views
Implementation of an Stack without Linked Lists in C
I'm a beginning C programmer. As an exercise, I have attempted to implement a stack of strings in C. This is my first real exercise working with pointers. I looked at some other similar posts on here, ...
2
votes
0answers
61 views
Binary Index tree optimization
I have written code for binary index tree. My problem is there are many functions based on the binary index tree the function stores the sum of element within a given range of binary index tree and my ...
0
votes
0answers
58 views
Freeing a binary tree data structure in C
I have this function that I hope to be a good alternative to the recursive (thus performance expensive) approach.
...
2
votes
2answers
74 views
Assign a unique number to duplicate items in a list
I made a program, but I not happy with the quantity of code. The end result is good, but I believe it can be made much easier, only I don't know how.
The functionality: If equal items > 1 in list, ...
4
votes
2answers
165 views
Rotating an array by position n
Input is 1,2,3,4,5,6,7,8
If rotateOrder = 2
Output should be 7,8,1,2,3,4,5,6
If rotateOrder = 3
Output should be 6,7,8,1,2,3,4,5
Here is my program to do it:
...
4
votes
2answers
62 views
Make a map using a splay tree
In my data structures and algorithms class, we were introduced to the splay tree, a BST with the additional property that recently accessed elements are quick to access (because they stay at the top ...
5
votes
1answer
49 views
Retrieve annotation from a tree annotated with a Monoid
Working on this homework from 2013 for self-learning.
For the following Algebraic Data Type:
...
2
votes
2answers
72 views
Parse a value to a given datatype
For our (internal) automated test project, I am writing a part where parameters can be passed to an SSIS Package before it gets executed. The tester delivers the parameter name, value and desired ...
6
votes
2answers
90 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 ...
6
votes
2answers
174 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
116 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
191 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 ...
6
votes
1answer
252 views
Generate Cartesian product of List in Java
My code, which generates Cartesian product of all lists given as arguments:
...
2
votes
1answer
55 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
179 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
165 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
67 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
112 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
25 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
45 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
440 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 ...