How to study cracking the coding interview
One way to measure the strength of measles is to count the number of lines (N) and then print them from N-10 to
Nth line. However, this requires two reads from the file; it can be very expensive if the file is large.
We need a solution that allows us to read once and print the last K lines. We're
able to create additional space how to study cracking the coding interview for K lines and then store each set of K lines in the matrix. So first of all
our matrix has lines 0 to 9, then 1 to 10, then 2 to 11, etc. (if K = 10). Everybody
every time we read a new line, we delete the oldest line from the array. Instead of
edit each time (very inefficient), we will use a circular array. This will allow us to always know
oldest characteristic at time 0 (1).
Compare and contrast Hash Table vs STL map
In a hash table, a value is stored by applying a hash function to a key. Therefore, there are no values
stored in a hash table in ordered order. Also, since hash tables use the key to
index that will store the value, insert / display can be done at amortization time 0 (1) (assuming
with just a few collisions in the hash table). One must handle possible collisions in a
picadillo board.
In an STL map, a key / value pair is entered in the sort order of the key. He uses a tree to store
values, so input / view 0 (log N) is required. No need to drive either
collisions. The STL map works fine for things like:
»Find the element min
»Get the most
»Print items in order
»Find the exact item, or if you can't find the item, look for the next smaller number
How is a hash table implemented?
1. A good hash function is required (for example:% prime number operation) to ensure that
Hash values are evenly distributed.
2. A collision resolution method is also required: chaining (good for compact table entries),
tests (good for thin table entries), etc.
3. Apply methods to dynamically increase or decrease the size of the hash table in a given
criterion. For example, when the proportion [number of elements] is greater in [table size]
than the fixed threshold, increase the size of the hash table by creating a new hash table and
move the entries from the previous table to the new table by calculating the index using
new hash function.
What can be used instead of a hash table, if the number of entries is small?
You can use an STL map. Although this takes 0 (log n) time, since the number of entries
little, this time it is insignificant.
The virtual function depends on "viable table" or "virtual table". If any function of a class is declared
as virtual, a table v is constructed that stores the addresses of the virtual functions of this class.
The compiler hides the vptr variables in all those classes, indicating that it is workable
that class. If a virtual function is not violated in the derived class, the derivative becomes viable
the class stores the address of the function in its parent class. Table v is used to
the address of the function, as long as the virtual function is called. Dynamic connection in C ++
so it is done through the viable mechanism.
So when we assign the derived class object to the elementary pointer, the vptr focuses on the
Derived viable class. This task ensures that it is the most derived virtual function
is called.