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.
7
votes
3answers
74 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 following Java program which passes ...
5
votes
2answers
81 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
30 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
75 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 ...
3
votes
2answers
37 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
64 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
/**
* This class traverses the tree and returns ...
4
votes
1answer
29 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
49 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
90 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
114 views
Reading columns and rows in a .csv file
I have some data in a .csv file, which looks roughly like this:
[fragment1, peptide1, gene1, replicate1, replicate2, replicate3]
[fragment1, peptide2, gene1, replicate1, replicate2, replicate3]
...
9
votes
3answers
147 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
57 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
86 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
107 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
78 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 check_t. This array is called enqueued. The struct check_t contains an ...
2
votes
1answer
45 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.
final class SportsMan {
private final ...
1
vote
0answers
72 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
83 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
27 views
Optimised library database code for sorted array of structures
I have an array of structure records and function intersection and difference.
The intersection function take list1,list2,list3(an array of records),and size of both list1 and list2.
Here, ...
2
votes
2answers
4k 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
721 views
Design LRU cache interview questions
Code reviewers, I request you review the code and suggest all tips for improvement.
public class LRU<K, V> {
private final Map<K, Entry<K, V>> map;
private Entry<K, ...
4
votes
3answers
381 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.
public class FlattenIterator ...
4
votes
2answers
289 views
Code review request for dijkstra
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.
final class Edge {
private final Node node1, node2;
private final ...
3
votes
2answers
68 views
Can someone review my Rational implementation?
The header file can be viewed here.
#include <stdio.h>
#include <stdbool.h>
#include <math.h> // searches default library classpaths
#include "Rational.h" // searchs my directory
// ...
1
vote
1answer
33 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.
#include <stdbool.h>
#include <stdlib.h>
#include "Polynomial.h"
...
1
vote
1answer
168 views
Can someone review my doubly linked list?
Here is the implementation with the interface below:
public class DoublyLinkedList<E> implements ListInterface<E>, ListIteratorInterface<E> {
private ...
1
vote
1answer
36 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 maxSize elements.
I would like any ...
2
votes
2answers
201 views
Generic binary search tree implementation
I use this interface for my BST node class:
public interface BinNode<E> {
public E getValue();
public void setValue(E value);
public BinNode<E> getLeftChild();
public ...
2
votes
0answers
78 views
Can someone review my MaxHeap implementation?
public class MaxHeap<E extends Comparable<E>> {
private E[] heap;
private int capacity; // maximum size of heap
private int numberOfNodes; // number of nodes in current heap
...
1
vote
1answer
102 views
Can someone review my implementation of an ArrayList?
public class ArrayList<E> implements List<E> {
private static final int defaultMaxSize = 10;
private int maxSize;
private int size;
private int currentPosition;
private ...
1
vote
1answer
208 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.
public class Trie {
private static final int ASCII = 256;
...
1
vote
0answers
102 views
Join levels of binary tree - Code review request
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
657 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).
public class CreateABinaryTree {
...
3
votes
2answers
143 views
Creating a binary search tree
I want you to pick my code apart and give me some feedback on how I could make it better or simpler. Although, agree that generics should be used, instead of integers, let's punt on generics as a ...
2
votes
2answers
186 views
Implement data structure overflow queue
Implement data structure overflow queue. Overflow queue is a normal queue with one extra property. It never throw Stack overflow exception. So whenever queue becomes full, it replaces the oldest ...
1
vote
1answer
109 views
Given preorder array construct a BST
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. Also its really hard to make this code work if preorder array contains ...
1
vote
1answer
548 views
Find height of a tree without using recursion, 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.
public int heightHelper(TreeNode node) {
int height = -1;
...
1
vote
0answers
42 views
Print duplicate and its frequency in BST assuming duplicates allowed only on right subtree.
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.
public class DuplicateCountInBST {
private TreeNode root;
...
1
vote
1answer
101 views
Print all path from root to leaves - 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.
public class PrintAllPath {
private TreeNode root;
private class ...
3
votes
1answer
314 views
non-recursive tree traversal, 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.
public class NonRecursiveTraversal {
private TreeNode root;
...
1
vote
1answer
418 views
Print path(leaf to root) with max sum in 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.
public class MaxSumPath {
private TreeNode root;
private static ...
4
votes
1answer
1k views
Create a tree from a list of nodes with parent pointers only. Critique 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.
class TreeNode {
private TreeNode left;
private TreeNode right;
...
2
votes
1answer
243 views
Finding inorder successor
I want you to pick my code apart and give me some feedback on how I could make it better or more simple. This code finds inorder successor in a binary tree.
public class Successor {
private ...
2
votes
4answers
186 views
What are the drawbacks of this “multi-key” dictionary?
I was making a relatively large-scale project in Python as a learning experiment, and in the process I found that it would be useful to have a map (or, in Python, I guess they're called dictionaries) ...
1
vote
2answers
35 views
Print periphery of a binary tree, critique 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. This code will traverse peripheri ( clock and anticlockwise ) in O(n) just ...
4
votes
1answer
512 views
LinkedList and Binary Search Tree in Javascript
I recently decided to make a LinkedList and Binary Search Tree using JavaScript. I wanted to reach out to a wider audience and see how I did, and where could I improve.
Linked List: ...
2
votes
1answer
221 views
Least common ancestor for binary search tree
I want you to pick my code apart and give me some feedback on how I could make it better or more simple. This code finds a common ancestor for binary search tree. This code accounts duplicates as ...
1
vote
0answers
91 views
Least common ancestor in binary tree
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. This code finds a common ancestor. If one of the input does not exist in ...
3
votes
1answer
202 views
Singly linked list in C
Here's my version of singly linked list. Any constructive criticism is highly appreciated.
First header file "sll.h":
#ifndef _SLL_H_
#define _SLL_H_
#include <stdio.h>
#include ...
3
votes
2answers
141 views
Is the use of Struct or Class personal preference?
I have a solution in which I instantiate a class with various types inside of it. I feel it is becoming to cumbersome to instantiate and then create variables for each of the types I want to access ...