Professional Documents
Culture Documents
Scenarios For C# Datastructure
Scenarios For C# Datastructure
Javarevisited
Blog about Java, Programming, Spring, Hibernate, Interview Questions, Books and Online Course Recommendations from Udemy, Pluralsight, Coursera, etc
Home cor e java spr ing hiber nate collections multithr eading design patter ns inter view questions coding data str uctur e OOP java 8 books About M e
Java Cer tifications JDBC jsp-ser vlet JSON SQL Linux Cour ses online r esour ces jvm-inter nals REST Eclipse jQuer y Java IO Java XM L
T UE SDA Y , M A R C H 2 8 , 2 0 1 7
2 Scenario Based Data Structure and Algorithm Design Interview Questions from
Investment Banks
This sounds me really interesting, because this not only test your knowledge of existing data
structure e.g. array, linked list, trees, graphs, stack, queue, ring buffer, Map but also test how
well you can apply and use this data structure in a given situation, and in some cases, can
you come up with a new innovative data structure.
Of course, classical questions on data structure e.g. finding middle element of linked list in
one pass or internal working of HashMap still matters, but these new questions will give you
more fun and edge while preparing for Java, C++ or C# developer roles.
1 of 6 8/19/2019, 6:58 PM
2 Scenario Based Data Structure and Algorithm Design Interview Questi... https://javarevisited.blogspot.com/2017/03/2-practical-data-structure-algo...
financial services firms or not familiar with stock trading. hiber nate inter view questions (6)
In Stock trading, exchanges like NYSE (NewYork Stock Exchange) maintains an order book for Best of Jav ar ev isited
every security or stock which is traded on their exchange e.g. GOOG, which is a symbol of How Spr ing MVC w or ks inter nally?
Google's stock. There are mainly two kinds of orders customers can send, a buy order, and a How to design a vending machine in Java?
sell order. When we use Limit Price, which means buy order with a limit price of $50 can be How HashMap w or ks in Java?
executed if it found a sell order of $50 or an order of lower price says $49, but it can not be Why Str ing is Immutable in Java?
executed with a sell order of price $51. Similarly, a sell order can execute for a price, which is 10 Ar ticles Ever y Pr ogr ammer Must Read
either equal to or higher than limit price. In general, a LIMIT order executes if it found a How to conver t lambda ex pr ession to method
specified price or better price(lower in the case of a buy, and higher in the case of sell). r efer ence in Java 8?
10 Tips to impr ove Pr ogr amming Skill
10 OOP design pr inciples pr ogr ammer should know
Orders are executed in first come first serve basis, so exchange also maintains a time priority. How Synchr onization w or ks in Java?
Now, let's see the flow, an order comes to exchange, exchange looks order book for that 10 tips to w or k fast in Linux
symbol, if it found a match it executes order otherwise, it adds that order at the end of a price 5 Books to impr ove Coding Skills
queue, which represents time priority, head of the queue represent the order with highest time
priority i.e. the order which comes before all the order below it. Jav a Tutor ials
Now our goal is to perform above operation as quickly as possible. If you look at closely, it FIX pr otocol tutor ial (15)
involves finding opposite order of matching the price, which is equal to or less/greater than Java Cer tification OCPJP SCJP (25)
specified price, removing the order from order book if it matched or canceled, adding order java collection tutor ial (73)
into order book at an appropriate place if not matched. java IO tutor ial (28)
Java JSON tutor ial (12)
Java multithr eading Tutor ials (56)
Java Pr ogr amming Tutor ials (18)
Java x ml tutor ial (16)
JDBC (29)
jsp-ser vlet (37)
online r esour ces (136)
Follower s
In all these operations, traversing is a key, which hints towards binary search tree data
structure. If we use a Binary Tree for storing order, we can find a matching order using binary Follow
search which is of order O(log2N), not quite fast as O(1) but still decent one. Subscr ibe to Download the E-book
Similarly adding and removing orders will also cost that much time, because they involve
traversal. Now in order to tackle different symbol, since the order of one symbol can not match
to order of another symbol, an OrderBook must be associated with a symbol. This is just a
basic idea, without going into exact requirement i.e. methods required to be supported by an
order book.
Btw, If you are not familiar with tree data structure and its variants e.g. binary search tree,
balanced tree-like AVL and Red-Black tree and Tries then I suggest you first read a good book
on Data Structure and Algorithms e.g. Introduction to Algorithms by Thomas H. Cormen
Categ or ies
2 of 6 8/19/2019, 6:58 PM
2 Scenario Based Data Structure and Algorithm Design Interview Questi... https://javarevisited.blogspot.com/2017/03/2-practical-data-structure-algo...
Eclipse (28)
Java Cer tification OCPJP SCJP (25)
JVM Inter nals (23)
JQuer y (18)
REST (17)
Maven (12)
Testing (11)
gener al (11)
Blog A r chiv e
► 2019 (211)
► 2018 (54)
▼ 2017 (781)
► December (90)
► November (31)
► October (44)
So in short, you can use something like this:
► September (40)
► August (51)
► July (55)
class MathcingEngine{
► June (54)
} ▼ Mar ch (99)
How to use EnumSet in Java w ith Ex ample
concurrency, thread-safety and all those things which are quite important while designing 3 w ays to Find Fir st Non Repeated Char acter in
a S...
structures for high volume, low latency application, but that's a topic for separate discussion.
Differ ence betw een Stack and Queue Data
Str uctur e ...
Here our goal is to focus on choosing right data-structure. Also, if you think the binary tree is
How to Rever se Ar r ay in Place in Java? Solution
not a right data structure for representing a limit order book, you can definitely share your Wi...
thoughts and solution with us. We will see if it solves the problem with better performance in Differ ence betw een WeakRefer ence vs
terms of time and development effort. SoftRefer ence ...
Java 1.5 Gener ics Tutor ial: How Gener ics in Java
w ...
On the other hand, if you are not familiar with essential data structures like the array, linked
10 Ex ception handling Best Pr actices in Java
list, binary search tree, balanced trees like AVL and Red-Black Tree and hash tables, I Pr ogr ...
suggest you read a good book on data structures. For Java developers, I recommend reading Differ ence betw een star t and r un method in
Algorithms Made Easy" by Narasimha Karumanchi. Thr ead ...
Differ ence betw een Wait and Sleep, Yield in Java
Top 10 Ser vlet Inter view Question Answ er s -
J2EE
Differ ence betw een Stack and Heap memor y in
Java
Why use Pr epar edStatement in Java JDBC –
Ex ample T...
3 of 6 8/19/2019, 6:58 PM
2 Scenario Based Data Structure and Algorithm Design Interview Questi... https://javarevisited.blogspot.com/2017/03/2-practical-data-structure-algo...
frequency trading and electronic trading, market data quickly become stale. 2 Ex amples of Str eams w ith Collections in Java 8
Differ ence betw een Fir st and Second Level Cache
in...
Suppose your system is storing market data to analyze and found under-valued or over-
How to enclose a list of values into single
valued stocks to make a buying or selling decision, and you need to store only recent market quotes...
data for that purpose. Now this gives us an idea, that as soon as we receive an update, we Can You Over load or Over r ide Static methods in
should discard old market data, even if it's not yet processed. Jav...
Java Synchr onization Tutor ial : What, How and
Why?...
Since Market data is processed by another thread and it subsequently removed from the
How to Check if a Number is Binar y in Java -
store, we need to also think of a data structure which provides consume kind of functionality.
Pr ogr ...
Initially, I thought of using an unbounded Queue for storing market data, which is
What is Daemon thr ead in Java and Differ ence to
simultaneously processed by another thread, typical producer-consumer design, but this No...
design has a problem in terms of updating prices at high speed. How to get Ser vletContex t in Ser vlet, JSP, Action
...
How to Conver t an Ar r ay to Comma Separ ated
Str ing ...
Top 15 Data Str uctur es and Algor ithm Inter view
Que...
Why char acter ar r ay is better than Str ing for
Stor ...
JDBC - java.lang.ClassNotFoundEx ception:
com.mysql...
How to find Lar gest Pr ime Factor of a Number
in Ja...
Mix ing static and non static synchr onized
method -...
For example, if you receive an update before earlier market data get processed, you can not
Why use Under scor e in Number s fr om Java SE 7 -
update that, which means your application will process old data, which is stale and even if a Und...
better data is available. Though you can tackle this problem by introducing a check and What is Method Refer ences in Java 8? An Ex ample
update method i.e. if a market data for that symbol already exists then remove it and add new Differ ence betw een Str uts 1 and Str uts 2 Web
data to the queue. Devel...
10 Hiber nate Inter view Questions and Answ er s
for J...
You can do that by using the contains() method but got to be careful while overriding
How to delete a dir ector y w ith files in Java -
, because if you are wrapping symbol and price in an object say Ex a...
ith different price will be treated as differently. So Queue data structure Bitw ise and BitShift Oper ator s in Java - AND, OR,
r this problem, let me know if you come across any other solution. ...
How to Clone Collection in Java - Deep copy of
Ar r ...
LinkedHashMap you can get your order of insertion, and being
How to Remove Fir st and Last Char acter of
te Market data in constant time, but Consumer thread, which needs to
Str ing i...
market data will have a hard time over traversing, as Map will constantly
Differ ence betw een Singleton Patter n vs Static
updating. Cla...
4 of 6 8/19/2019, 6:58 PM
2 Scenario Based Data Structure and Algorithm Design Interview Questi... https://javarevisited.blogspot.com/2017/03/2-practical-data-structure-algo...
That's all on this list of Practical Data structure and algorithm questions for Java, C++, and 10 ex ample of chmod command in UNIX Linux
C# developers. These are just a way of approaching the problem, you may have another Java 8 Date Time - 20 Ex amples of LocalDate,
Local...
approach or another data structure to solve these problems, and until you can justify your use
Top 50 Java Thr ead Inter view Questions Answ er s
of particular data structure in terms of benefits, you are perfectly fine to use that. In fact, for ...
improving your own solution, almost always create a better impression during interviews. How to Incr ease Console Buffer Size in Eclipse
IDE...
At the same time don't forget to prepare basic data structure and algorithms questions on How to Implement Stack in Java Using Ar r ay and
Gen...
linked list, array, queue, and stacks. Stay tuned, I will share few more such data structure
Top 10 EJB Inter view Question and Answ er asked
questions as and when I come across, mean while you are always welcome to share
in ...
something similar. Till then you can also use problems given in Algorithm Design Manual by
java.lang.UnsatisfiedLinkEr r or : no dll in
Steven S Skiena to improve your data structure and problem-solving skill. java.lib...
Reentr antLock Ex ample in Java, Differ ence
Further Learning betw een ...
Data Structures and Algorithms: Deep Dive Using Java Why w e use Thr eads in Java?
Algorithms and Data Structures - Part 1 and 2 How to r ead Pr oper ties File in Java – XML and
Tex t...
Data Structures in Java 9 by Heinz Kabutz
Top 20 FIX Pr otocol Inter view Questions
Top 10 MQ Ser ies Inter view Questions Answ er s -
Related Data Structure and Algorithm Interview Questions from Javarevisited Blog Web...
How to add or list cer tificates fr om keystor e or
Top 15 Data Structure and Algorithm Interview Questions (see here)
t...
Top 20 String coding interview questions (see here)
10 Ex amples of cur l Command in UNIX and Linux
133 core Java interview questions of last 5 years (see here)
How to cr eate Immutable Class and Object in
Top 30 Array Coding Interview Questions with Answers (see here) Java -...
Top 30 linked list coding interview questions (see here) Tibco tutor ial : Tibco RV tips and commands
Top 50 Java Programs from Coding Interviews (see here) Tibco Tutor ial: Fundamentals of Tibco RV
Top 5 books on Programming/Coding Interviews (list) messaggi...
TIBCO Tutor ial : TIBCO Rendezvous or TIBCO RV
Thanks for reading this article so far. If you like this article then please share with your friends me...
and colleagues. If you have any question or doubt then please let us know and I'll try to find an What is the use of class “java.lang.Class” in
Java...
answer for you.
Why Compar ing Integer using == in Java 5 is Bad?
What is Abstr action in Java? Abstr act Class or
Int...
Fundamentals of Object Or iented Pr ogr amming
in Jav...
How to check if a thr ead holds lock on a
par ticula...
Why Str ing is Immutable or Final in Java
Differ ence betw een map() and flatMap() in Java 8
S...
Covar iant Method Over r iding of Java 5 - Coding
Bes...
10 Singleton Patter n Inter view Questions in Java
-...
What is differ ence betw een Enumer ation and
Iter ato...
What is differ ence betw een HashMap and
Hashtable i...
java.lang.NoSuchMethodEr r or : main Ex ception in
thr ...
How to cr eate and ex ecute JAR file in Java –
Comma...
inter view questions , pr ogr amming 130+ Java Inter view Questions Answ er s for 2 to
7 Y...
How to for mat Decimal Number in Java -
DecimalFor m...
Steps to Cr eate JUnit Test in Eclipse and
Netbeans...
5 of 6 8/19/2019, 6:58 PM
2 Scenario Based Data Structure and Algorithm Design Interview Questi... https://javarevisited.blogspot.com/2017/03/2-practical-data-structure-algo...
Pr ivacy Policy
6 of 6 8/19/2019, 6:58 PM