You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: