Fundamentals: Typing, SQL vs NoSQL, Indexes, Python Generators and Decorators, URLs
Company: Squarepoint
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Technical Screen
The technical screen opened with a set of fundamentals questions covering programming languages, databases and networking. Answer each one clearly, with the mechanics behind it and the trade-offs involved.
### Clarifying Questions
- For SQL versus NoSQL, should NoSQL be treated as one family or broken down by type (key-value, document, wide-column, graph)?
- For indexes, is a particular database engine assumed, or should the answer describe the common B+ tree design?
- For the URL question, how deep should the answer go: networking steps only, or also how the browser renders the page?
### Part 1 — Static versus dynamic typing
Compare static and dynamic typing, and give the advantages and disadvantages of each.
```hint When is the type known
Think about when a type error is reported in each model, and what that timing costs and buys you.
```
#### What This Part Should Cover
- When type checking happens and which errors it catches
- Effects on tooling, refactoring, performance and development speed
- Example languages and a bug each model catches or misses, kept separate from the strong-versus-weak typing distinction
### Part 2 — SQL versus NoSQL
Compare relational (SQL) databases with NoSQL databases.
```hint Start from the access pattern
Think about which workloads need joins and multi-row transactions, and which need one key space spread across many machines.
```
#### What This Part Should Cover
- Schema, query model with joins, and ACID transactions
- Horizontal scaling and the consistency and query trade-offs it brings
- How to choose for a given workload
### Part 3 — Database indexes
Explain how a database index works, what it costs, and how a composite index is used.
```hint Count the page reads
Compare how many disk pages a lookup touches with and without the index, and what every insert must now update in addition to the table.
```
#### What This Part Should Cover
- B+ tree structure, and why lookups and range scans are fast
- The costs: slower writes, extra storage, and cases where an index does not help
- Composite indexes and the leftmost-prefix rule, with queries that can and cannot use one
### Part 4 — Python generators and decorators
Explain Python generators and decorators.
```hint Paused functions and wrapped functions
For generators, think about what happens to a function's local variables between the values it produces. For decorators, think about what the line starting with the at sign rewrites the function definition into.
```
#### What This Part Should Cover
- `yield`, lazy evaluation, memory savings and the iteration protocol
- Decorators as higher-order functions, the at-sign syntax, `functools.wraps`, and decorators that take arguments
- A short, correct example of each
### Part 5 — What happens after you enter a URL in the browser
Describe what happens between typing a URL into the browser's address bar and seeing the page.
```hint Before the first request byte
List what the browser must know before it can send the HTTP request, and which step supplies each piece.
```
#### What This Part Should Cover
- DNS resolution and the caches it passes through
- TCP and TLS handshakes
- The HTTP request, server-side processing and the response
- Parsing and rendering the page, including fetching sub-resources
### What a Strong Answer Covers
- Accurate mechanics in each part, not just labels
- A trade-off for every comparison, with an example of when each side wins
- Short, correct code for generators and decorators
- The URL walk-through in the right order, with the layer each step belongs to
### Follow-up Questions
- Given a composite index on `(a, b, c)`, which of `WHERE a = 1 AND c = 3`, `WHERE b = 2` and `WHERE a = 1 ORDER BY b` can use it, and how?
- How would you write a decorator that takes an argument, such as a retry count?
- Python has type hints but stays dynamically typed. What do hints give you, and what don't they?
- On a second visit to the same HTTPS site a few seconds later, which steps can be skipped?
Overview: A rapid-fire fundamentals screen for a software engineering internship covering static versus dynamic typing, SQL versus NoSQL databases, and how B+ tree and composite indexes work. It also tests Python generators and decorators and the full sequence of events after a URL is entered in a browser.
Read the full Squarepoint Software Engineer interview experience this question came from