Basis Lab

Answers

One question, answered the whole way through, with the arithmetic actually done rather than named. Every one of them ends at the page of a course that carries it further, because an answer you cannot build on is a fact you will look up again next month.

300 questions so far, page 4 of 6

Making it fast enough

5 to 23 of 23
  1. What's the difference between memoized recursion and filling a DP table bottom-up?Memoised recursion keeps the calls and only solves states it reaches; a bottom-up table removes the calls, fills every entry in a dependency-safe order, and is usually faster when most entries are needed.
  2. Why can a hash table find something without scanning everything else?A hash table does not search its contents faster. It computes where the item must sit from the key itself, so the number of stored items never enters the calculation.
  3. Why can't a hash table give me the next key in order?Because a good hash deliberately scatters neighbouring keys, so the table keeps no record of which key comes after which; finding the next key means reading every entry.
  4. Why does a hash table need to grow before it is completely full?Because what makes lookup fast is how full the table is, not how big it is: near full, a lookup turns into a scan well before the last slot is taken.
  5. Why does breadth-first search always find the path with the fewest links?Breadth-first search meets points in order of how many links they are from the start, so the first time it reaches a point it has used the fewest possible links.
  6. Why do databases use B-trees rather than binary search trees for indexes?Because a database index pays for disk blocks read, not comparisons made, and a wide shallow tree needs only a few block reads per lookup.
  7. How does a heap know the smallest item without keeping the whole collection sorted?A heap only keeps each parent no larger than its children, so the top is always the smallest even though the rest is not sorted.
  8. How does merge sort get n log n by splitting and merging?Splitting halves the number of runs each round, so there are about log base 2 of n rounds; merging every item once per round gives n log n.
  9. Why is merge sort O(n log n) when it keeps splitting the array in half?Splitting in half gives about twenty levels for a million items, and merging at every level still touches all million items, so the total is twenty million rather than a million times a million.
  10. How do I know when there is no order that satisfies all the dependencies?If you repeatedly remove anything with nothing still waiting on it and cannot remove everything, the dependencies contain a loop, so no valid order exists.
  11. Which grows faster, n log n or n squared?The squared option grows faster: doubling the input multiplies the log-times-linear option by a little over two, but multiplies the squared option by four.
  12. Why do nested loops multiply their running times instead of adding them?Because the inner loop runs in full once for every pass of the outer loop, so the cost is one count times the other, not one plus the other.
  13. How does binary search find something in a sorted list so fast?Binary search is fast because each comparison halves the remaining sorted range, so a thousand items need about ten probes and a million need about twenty, rather than one probe per item.
  14. Why does binary search only work if the list is sorted?Because only in a sorted list does one comparison against the middle tell you that half the items cannot be the one you want.
  15. Why does inserting already sorted numbers turn a binary search tree into a linked list?Because each new number is bigger than every number already stored, so it is always attached down the right side, and the tree becomes a chain as deep as the number of items.
  16. When is picking the locally best option actually guaranteed to give the best overall answer?Only when a proof shows that some best overall answer can contain the locally best first choice, and the same holds for every later step; otherwise one counterexample can break it.
  17. What is memoization and why does caching recursive results make it so much faster?Memoisation stores each answer once and reuses it, so a recursion that repeats the same subproblems stops redoing work and becomes a table lookup instead.
  18. How do I find out if a graph is really in two separate pieces?Walk from one point, mark everything you can reach, then start again at any unmarked point; the number of walks is the number of separate pieces.
  19. Why is it safe to keep taking the cheapest link that doesn't create a loop?Because the cheapest link joining two separate pieces is the cheapest way across a split, and swapping it into any rival solution cannot raise the total cost.

The physics underneath

10 answers
  1. How can light travel through empty space if there's nothing to wave?Light is a self-sustaining ripple of electric and magnetic fields, each one creating the other, so it needs no material to travel through.
  2. How can you predict the shape of a plucked string a moment after you let go?Write the starting corner as a sum of the string's allowed standing shapes, let each shape oscillate at its own rate, then add them back together.
  3. Why is momentum conserved in a collision when kinetic energy is not?Momentum is conserved because the internal pushes in a collision cancel in pairs, while kinetic energy can be turned into heat and deformation.
  4. Why does a planet speed up when it gets closer to the Sun?A planet speeds up near the Sun because its fixed angular momentum forces its sideways speed up as its distance falls, and gravity does work as it falls inward.
  5. Why does an object speed up as it falls?Because a falling object has a fixed total of height energy plus motion energy, so every bit of height it loses turns into speed. Gravity converts rather than adds.
  6. Why does pushing a swing at just the right moment make it go much higher?A swing goes higher when each push arrives in step with the motion already there, so many small pushes add up instead of cancelling.
  7. Why does a wave on a string travel at the same speed no matter how hard you pluck it?A harder pluck makes a bigger wave, but the speed of the wave is fixed by the string's tension and mass per length, so amplitude does not change it.
  8. Why is the fastest way down a hill not a straight line?Because time is distance divided by speed, and a steeper path gives the bead more speed early even though it is longer.
  9. Why do two waves moving in opposite directions make a standing wave that doesn't go anywhere?Two travelling waves going opposite ways add point by point; where one rises the other falls they cancel permanently, so the pattern stays put even though both waves keep moving through it.
  10. Why does a spinning book suddenly start tumbling instead of staying on its axis?Spinning a book about its middle-sized axis is unstable: the conserved quantities still allow it to turn over, and any tiny wobble grows until it flips.

Putting a model into service

1 to 21 of 39
  1. Why does the model return JSON wrapped in extra text when I asked for JSON?A request for JSON does not force the model to return only JSON, so you need to validate the reply and repair it once rather than assume it will parse.
  2. Why do the numbers look good while users keep complaining?Because the score measures a fixed set of cases with a fixed rule, and the users are living through behaviour that the set and the rule never covered.
  3. How do I make the model answer from the documents I give it instead of its own memory?Fence the documents as labelled reference material, put them before the question, tell the model to prefer them over memory, and require a passage number for each claim.
  4. Why does the memory used by a model keep growing as the conversation gets longer?The model's weights do not grow. It keeps a cache of keys and values for every earlier token, so memory rises with conversation length and with how many conversations run at once.
  5. How many legitimate requests should I be willing to block in order to catch the bad ones?Block no more legitimate requests than one prevented harmful answer is worth: the break-even count is the harm cost divided by the refusal cost.
  6. What does a p-value actually tell me?A p-value is the chance of seeing a difference at least as large as yours if the change did nothing; it is not the chance the result was luck or that there is no effect.
  7. My score went up two points — is that a real improvement or just noise?No. At four hundred cases a two point gain is inside the noise, so treat it as no result.
  8. Why bother with a confidence interval when the result is already significant?A significant result only rules out zero; the interval shows how large the effect might be and whether it is worth acting on.
  9. What does the model actually see when I send a prompt?It sees one assembled string: your typed prompt is a small clause near the end of a document that code stitched together from instructions, examples, retrieved passages and earlier turns.
  10. Why does the model pick the wrong tool when two of them sound almost the same?The model only sees the written description, so when two descriptions overlap it cannot tell the tools apart and confidently picks the more familiar reading.
  11. At what point does the conversation history cost more than the model itself?With sixty-four conversations grouped together, reading their history overtakes reading the model at roughly six and a half thousand words per conversation.
  12. How can I tell if a prompt change actually helped or if I just got a lucky answer?Compare two versions on the same written set of cases, before and after, and call a change real only when it beats the wobble of that set.
  13. Why do I still need exact keyword search when I'm searching by meaning?Because meaning matching compresses text into a few hundred numbers and need not keep a rare part number or error code intact; exact keyword matching weights rare strings so heavily it finds them immediately.
  14. Why does a long conversation with a model use so much more memory than a short one?The model keeps a growing summary for every word inside every layer, so a long chat uses memory in proportion to its length, not to the size of its text.
  15. If someone fully jailbreaks the model, what actually stops it from deleting my database?Nothing in the model stops it. What stops it is your code: the delete tool either cannot name your database or cannot delete irreversibly.
  16. Why is writing a long answer slower than reading a prompt of the same length?Reading a prompt happens in one parallel pass, while writing a reply happens one word at a time, so the reply rereads the model for every word.
  17. How do I decide whether a small but significant win is actually worth shipping?Ship only if the chance the gain is real beats the cost of being wrong divided by that cost plus the gain. That bar is rarely five per cent.
  18. Why does one outlier weight wreck 4-bit quantization for the whole layer?A single huge value sets the rounding step for the whole layer, so ordinary weights fall below one step and round to zero.
  19. Can a web page my agent reads make it do something I never asked for?Yes. A fetched web page can contain a sentence aimed at the model, and nothing in the model's view marks it as different from something you wrote yourself.
  20. How do I stop a retrieved document from being read as an instruction?You cannot stop it completely, but fencing each passage in a labelled block, with a line saying it is information to use and not instruction to follow, makes the model far less likely to obey it.
  21. How do I write a safety rule I can actually test, instead of just saying 'be harmless'?Name the action, the cases it covers, the cases it deliberately leaves out and what happens when it fires; then check that two readers label the same twenty borderline requests the same way.

If you want the whole thing

Behind every answer here is a course that works through its subject from the beginning, with problems under each idea and a reason rather than a tick when one is marked. An answer settles the question you came with; the course is what makes the next one easier.

The libraryAsk for a course