Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrderBook Efficiency #3

Open
liamasman opened this issue Feb 2, 2016 · 0 comments
Open

OrderBook Efficiency #3

liamasman opened this issue Feb 2, 2016 · 0 comments

Comments

@liamasman
Copy link
Contributor

Would using a LinkedList over an ArrayList be more efficient, with the highest buy/lowest sell at the head of each list.

New buy (sell) orders will in most cases be higher (lower) than the current highest (lowest), so will go to the head of the list. Doing it as an insertion means it'll take normally 1 comparison and at most n. Thus inserting n elements should be AvgO(n) WorstO(n^2) instead of AvgO(n_lgn) WorstO(n^2_lgn) that we have currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant