# AI Engineer > A free site for learning AI engineering and preparing for AI interviews: LLMs, RAG, agents, evals, model serving, mobile systems, protocols, coding patterns and system design. Lessons explain the basics first, and include tested code. Full text of the AI interview paths: https://aie-bp24.onrender.com/llms-full.txt ## Crack AI interviews - [All paths](https://aie-bp24.onrender.com/paths/ai-interviews/): Hacks, rounds, a study plan and a project. - [Critical basics](https://aie-bp24.onrender.com/paths/ai-interviews/basics/): Essentials to read, memorise and practise. ## AI interview hacks The most useful ideas people share, tested and turned into drills: hint ladders, planted bugs, recorded mocks, and more. Plus where the line sits. - [Never ask AI for the answer](https://aie-bp24.onrender.com/paths/ai-interviews/hacks/hint-ladder/): How do you get unstuck with AI and still learn the problem? - [Make AI plant bugs in good code](https://aie-bp24.onrender.com/paths/ai-interviews/hacks/plant-bugs/): How do you get faster at spotting mistakes in code you didn't write? - [Measure how you sound](https://aie-bp24.onrender.com/paths/ai-interviews/hacks/talk-track/): How do you know whether you explain things well under pressure? - [Reverse the job post, then cross-examine your resume](https://aie-bp24.onrender.com/paths/ai-interviews/hacks/cross-examine/): How do you find out what they'll ask, and whether your own stories hold up? - [Turn every miss into a card](https://aie-bp24.onrender.com/paths/ai-interviews/hacks/mistake-ledger/): How do you stop making the same mistake in every mock? - [The hacks that get you rejected](https://aie-bp24.onrender.com/paths/ai-interviews/hacks/the-line/): Which uses of AI are fair, and how do you find out for your interview? ## AI interview rounds Every round you may meet now, from coding beside an assistant to RAG, agents, evals and a customer role-play. What each tests, with code you can run. - [The new interview map](https://aie-bp24.onrender.com/paths/ai-interviews/rounds/the-map/): What rounds will you actually face now, and who says so? - [The AI-enabled coding round](https://aie-bp24.onrender.com/paths/ai-interviews/rounds/ai-coding/): How do you use an assistant in a live round so that it counts in your favour? - [The code comprehension round](https://aie-bp24.onrender.com/paths/ai-interviews/rounds/comprehension/): How do you find what's wrong in code you've never seen, in under an hour? - [The LLM fundamentals screen](https://aie-bp24.onrender.com/paths/ai-interviews/rounds/llm-screen/): What do you need to know about models to pass a first technical screen? - [The RAG design round](https://aie-bp24.onrender.com/paths/ai-interviews/rounds/rag-round/): How do you design a system that answers questions from your own documents? - [The agent design round](https://aie-bp24.onrender.com/paths/ai-interviews/rounds/agent-round/): How do you design an agent that can act without doing damage? - [The evals round](https://aie-bp24.onrender.com/paths/ai-interviews/rounds/eval-round/): How do you prove an AI feature works, and that the next change didn't break it? - [The customer conversation round](https://aie-bp24.onrender.com/paths/ai-interviews/rounds/customer-round/): A customer says your bot feels dumb. What do you do in the next ten minutes? ## Crack it with AI, the best way A plan that works from any starting point: an honest baseline, a daily loop, and a final stretch with AI off to prove the skill is yours. - [Start with an honest baseline](https://aie-bp24.onrender.com/paths/ai-interviews/playbook/baseline/): Where do you actually stand today, with no help? - [The daily loop and your plan](https://aie-bp24.onrender.com/paths/ai-interviews/playbook/daily-loop/): What should each day look like, and how do you use AI across it? - [The AI-off test](https://aie-bp24.onrender.com/paths/ai-interviews/playbook/ai-off/): How do you know the skill is yours, and that you're ready? ## Build your own AI interviewer Our pick. Build a mock interviewer that you'll really use, and walk away with a true project story, with real measurements behind it. - [Build your coach: the interview loop](https://aie-bp24.onrender.com/paths/ai-interviews/build/state-machine/): How do you build an AI interviewer that behaves like an interviewer? - [Build your coach: the prompt and the model call](https://aie-bp24.onrender.com/paths/ai-interviews/build/prompt/): What should the model see, and what must it never see? - [Build your coach: scoring you can trust](https://aie-bp24.onrender.com/paths/ai-interviews/build/scoring/): How do you get reliable structured output from a model? - [Build your coach: evals, cost and your story](https://aie-bp24.onrender.com/paths/ai-interviews/build/eval-and-story/): How do you prove it works, and how do you talk about it in an interview? ## Deep dives - [Front-end architecture for offline, real-time and AI apps](https://aie-bp24.onrender.com/deep/frontend-arch/): Front ends in data-heavy apps own far more than pixels: what the user sees, each screen's state machine, perceived speed, offline behaviour… - [The sync engine](https://aie-bp24.onrender.com/deep/sync-engine/): Sync engines move local changes to the server and server changes into the local database. No UI, and no business logic beyond merging. The … - [The transfer manager](https://aie-bp24.onrender.com/deep/transfer-manager/): Transfer managers move large files between phone and object storage. They hash, split and send parts that succeed or fail alone, record pro… - [The background-work layer](https://aie-bp24.onrender.com/deep/background-layer/): Background layers adapt your app to the OS scheduler. They turn many triggers (app open, network back, push, timers, user actions) into a f… - [The server sync service](https://aie-bp24.onrender.com/deep/server-sync/): Server sync completes the protocol. It accepts pushes idempotently, applies merge rules, gives every change a sequence number in a per-tena… - [How an LLM works inside](https://aie-bp24.onrender.com/deep/llm-internals/): LLMs map a token sequence to a probability for every possible next token. Generation repeats that function, appending one token at a time. … - [Making inference fast and cheap](https://aie-bp24.onrender.com/deep/inference-accel/): Inference limits come in three kinds: GPU compute during prefill, memory bandwidth during decode, and memory capacity for weights and KV ca… - [Embeddings and vector search](https://aie-bp24.onrender.com/deep/embeddings/): Embedding models turn text, images or audio into vectors, so similar meanings land close together. Approximate indexes find the nearest vec… - [Prompting, RAG or fine-tuning?](https://aie-bp24.onrender.com/deep/adapt-models/): Three levers fit a general model to your product: better prompts, retrieval at query time, and new weights. Prompts and retrieval change wh… - [Tool use, agents and MCP](https://aie-bp24.onrender.com/deep/agents-mcp/): Tool use lets a model call your functions: it outputs a structured request, your code runs it, and the result returns to the conversation. … - [Integrating LLMs into products](https://aie-bp24.onrender.com/deep/llm-integration/): LLM features behave like ordinary software with one unreliable, slow, expensive dependency. The patterns from payments or search apply: a g… - [Using AI to accelerate engineering teams](https://aie-bp24.onrender.com/deep/ai-dev-accel/): AI adoption questions test principal engineers: how AI changes the way teams build, and how you roll it out responsibly. Cover tools, workf… ## AI systems modules - [vLLM High-Throughput Engine Architecture](https://aie-bp24.onrender.com/modules/vllm-engine-internals/): PagedAttention treats the KV cache like virtual memory, so one GPU holds 2–4× more concurrent requests. - [Block-Allocated PagedAttention Triton Kernel](https://aie-bp24.onrender.com/modules/paged-attention-kernel-impl/): Build the block table and the kernel that reads it, so multi-tenant batches never fragment GPU memory. - [Continuous Batching & Iteration-Level Scheduling](https://aie-bp24.onrender.com/modules/continuous-batching-scheduler/): Iteration-level scheduling ends the wait for a batch's longest request; prefill stalls become the next bottleneck. - [Tensor Parallelism & Ring-AllReduce Communication](https://aie-bp24.onrender.com/modules/tensor-parallelism-allreduce/): Every transformer layer pays for two collectives on NVLink, which explains why tensor parallelism stays inside one server. - [Speculative Decoding Target-Draft Pair Verifier](https://aie-bp24.onrender.com/modules/speculative-decoding-verifier/): Modified rejection sampling accepts draft tokens without changing the target model's distribution. - [vLLM Automatic Prefix Caching Architecture](https://aie-bp24.onrender.com/modules/vllm-prefix-caching/): Chained block hashes skip prefill for shared system prompts, and salts keep tenants apart. - [Fused Flash-Softmax Triton Kernel](https://aie-bp24.onrender.com/modules/triton-softmax-fused/): Fusing softmax into one kernel cuts memory reads from 4n to n and writes from 2n to n. - [Hierarchical Navigable Small World (HNSW) Graphs](https://aie-bp24.onrender.com/modules/hnsw-vector-graph-indexing/): Layered small-world graphs answer nearest-neighbour queries in milliseconds, trading exact recall and memory for speed. - [Reciprocal Rank Fusion (RRF) Hybrid Search](https://aie-bp24.onrender.com/modules/reciprocal-rank-fusion-algorithm/): Merges BM25 and vector rankings without normalising scores that live on different scales. - [Parent-Child Hierarchical Context Retrieval](https://aie-bp24.onrender.com/modules/parent-child-chunking-strategy/): Embed small chunks for precise matching, and send large parents to the model for enough context. - [Entity-Relation Graph Mining & GraphRAG Pipeline](https://aie-bp24.onrender.com/modules/graph-rag-knowledge-extractor/): Entity graphs and community summaries answer corpus-wide questions that chunk retrieval cannot. - [Redis Vector Semantic Response Caching](https://aie-bp24.onrender.com/modules/semantic-cache-redis/): Answers repeat questions from a vector cache, cutting LLM cost, as long as false hits stay rare. - [Inverted Indexing & BM25 Scoring Engine](https://aie-bp24.onrender.com/modules/bm25-sparse-indexer/): Inverted indexes and BM25 still win on exact terms: product codes, names and error strings. - [BGE-Reranker Multi-Stage Retrieval Pipeline](https://aie-bp24.onrender.com/modules/bge-reranker-integration/): Retrieve 100 with fast search, rerank to 5 with a cross-encoder, and degrade safely on timeout. - [Selective Context Window Token Compression](https://aie-bp24.onrender.com/modules/context-window-compression/): Spend the token budget on evidence: prune sentences and summarise history before they reach the model. - [Low-Rank Adaptation (LoRA) Weight Decomposition](https://aie-bp24.onrender.com/modules/lora-parameter-efficient-tuning/): Trains two thin matrices instead of every weight, so fine-tuning fits one GPU and merges with no added inference latency. - [PyTorch LoRA Linear Layer Implementation](https://aie-bp24.onrender.com/modules/custom-lora-layer-from-scratch/): Writes a drop-in replacement for nn.Linear with trainable low-rank adapters and dropout. - [QLoRA NormalFloat4 & Double Quantization](https://aie-bp24.onrender.com/modules/qlora-4bit-quantization-nf4/): NF4 and double quantisation shrink a 7B base to about 3.4 GiB, so training fits a small GPU. - [Direct Preference Optimization (DPO) Loss Function](https://aie-bp24.onrender.com/modules/dpo-direct-preference-optimization/): Trains on preference pairs directly, with no separate reward model or PPO loop. - [DeepSpeed ZeRO-3 Memory Partitioning](https://aie-bp24.onrender.com/modules/deepspeed-zero-stage3/): Shards optimiser state, gradients and weights across GPUs, trading extra communication for models that otherwise cannot fit. - [PyTorch Fully Sharded Data Parallel (FSDP)](https://aie-bp24.onrender.com/modules/fsdp-sharded-grad/): PyTorch's native sharding: wrap per block, and each block gathers its weights only while it runs. - [Merging LoRA Adapters into Base Model Weights](https://aie-bp24.onrender.com/modules/peft-adapter-merging/): Bakes an adapter into the weights for faster serving, and shows when merging is the wrong call. - [Unsloth Gradient Calculation Acceleration](https://aie-bp24.onrender.com/modules/unsloth-fast-gradient/): Unsloth claims faster, lighter fine-tuning through patched model code. Verify its numbers on your own hardware. - [LLM-as-a-Judge Evaluation & Calibration Architecture](https://aie-bp24.onrender.com/modules/llm-as-a-judge-eval-suite/): LLM judges scale evaluation, but only once you correct position, verbosity and self-enhancement bias. - [Llama-Guard Jailbreak & Safety Classifier](https://aie-bp24.onrender.com/modules/llama-guard-prompt-injection-checker/): Moderates input and output with a dedicated classifier, and fails closed whenever actions are at stake. - [Faithfulness, Answer Relevance & Context Recall Metrics](https://aie-bp24.onrender.com/modules/ragas-retrieval-eval-metrics/): Separates retrieval failures from generation failures, so you fix the right half of a RAG system. - [Guardrails AI Structured Pydantic Output Validation](https://aie-bp24.onrender.com/modules/guardrails-ai-validator/): Never passes unvalidated model output downstream: validate against a schema and re-ask with the exact errors. - [Evaluating Multimodal LLMs on Visual Reasoning](https://aie-bp24.onrender.com/modules/bimodality-eval-benchmark/): Many vision benchmark items can be answered without the image. Control for that before trusting a score. - [Automated Adversarial Red-Teaming Suites](https://aie-bp24.onrender.com/modules/red-teaming-adversarial-prompt/): Turns one-off safety testing into a regression suite that gates every release. - [SLURM GPU Cluster Job Scheduling & Failure Recovery](https://aie-bp24.onrender.com/modules/slurm-cluster-gpu-orchestration/): Requeues multi-node training on failure, and resumes from the last checkpoint with no one watching. - [Async Zero-Redundancy Optimizer Checkpointing](https://aie-bp24.onrender.com/modules/distributed-checkpointing-zarr/): Saves sharded state in the background, so checkpoints stop stalling GPUs. - [Triton Compiler JIT Codegen Pipeline](https://aie-bp24.onrender.com/modules/triton-compiler-internals/): Follows one Python function down to GPU binary, which explains caching, specialisation and autotuning. - [NCCL Inter-Node Transport Protocols & Infiniband](https://aie-bp24.onrender.com/modules/nccl-socket-transport/): Reads an NCCL debug log and finds the moment training silently falls back to TCP. - [Ray Serve Distributed Actor Deployment](https://aie-bp24.onrender.com/modules/ray-serve-deployment/): Runs LLM replicas as autoscaled actors, with health checks and per-replica request limits. - [Prompt Patterns: Chain of Thought, Few-Shot, Structured Output](https://aie-bp24.onrender.com/modules/prompt-patterns-structured-output/): Four patterns cover most prompts. Test each against an eval set rather than trusting folklore. - [CLIP and ViT Multimodal Embeddings](https://aie-bp24.onrender.com/modules/clip-vit-multimodal-embeddings/): CLIP places images and text in one vector space, which enables image search with no labels. - [App Startup: Cold Start From Tap to First Frame](https://aie-bp24.onrender.com/modules/mobile-startup-performance/): Startup is the first performance number users feel, and most of it is work you chose to do too early. - [Mobile Observability: Crashes, ANRs, Traces and Rollout Gates](https://aie-bp24.onrender.com/modules/mobile-observability-rollouts/): You cannot roll back a phone, so telemetry has to catch a bad release while only 1% of users have it. - [Mobile Security: Tokens, Keystore, Pinning and Tampering](https://aie-bp24.onrender.com/modules/mobile-security-tokens/): Assume the phone can be lost, rooted or reverse-engineered, then decide what an attacker still cannot do. - [Live Location Tracking for a Driver App](https://aie-bp24.onrender.com/modules/live-location-tracking/): A location stream combines every mobile constraint at once: battery, background limits, bad networks and scale. - [Push Notification Platform at Scale](https://aie-bp24.onrender.com/modules/notification-platform-mobile/): Push looks like one API call until you need priority, retries, per-user limits and delivery you can measure. - [Feature Flag and Experimentation SDK](https://aie-bp24.onrender.com/modules/experimentation-sdk-mobile/): Flags are how mobile teams change behaviour without a store release, and bad assignment logic silently ruins experiments. - [React Native New Architecture: JSI, Fabric, TurboModules and Threads](https://aie-bp24.onrender.com/modules/rn-new-architecture/): Most older React Native advice is about the bridge. Knowing what replaced it shows which advice still holds. - [React Native State: Server Cache, Client Store and Render Storms](https://aie-bp24.onrender.com/modules/rn-state-render-storms/): Putting every kind of state in one global store makes one change redraw half the screen. - [Modular React Native for Many Apps: The Modularity Ladder](https://aie-bp24.onrender.com/modules/rn-white-label-modularity/): Codebases rarely fail from network speed. They fail from merge conflicts and features that can't be removed. - [Memory Leaks in React Native: Three Heaps, One Staircase](https://aie-bp24.onrender.com/modules/rn-memory-leaks/): A leak can hide in the JavaScript heap, the native heap or the boundary between them, and each needs a different tool. - [Offline Sync in React Native: What to Persist and Where](https://aie-bp24.onrender.com/modules/rn-offline-queue/): A queue held in memory loses unsent changes when the OS kills the app. Persist the mutations, and keep them atomic with the local write. - [The 95/5 Rule and Performance Budgets in CI](https://aie-bp24.onrender.com/modules/rn-native-boundary-budgets/): Most code can stay in React Native. A few pieces belong in native code, and CI should stop performance from slipping. ## System design rounds - [Offline-first inspection app with huge uploads](https://aie-bp24.onrender.com/interview/offline-field/): We’re building an app for 200,000 field technicians who inspect pipelines. They work underground for hours with no signal, capture 30 to 60… - [Real-time chat with offline delivery](https://aie-bp24.onrender.com/interview/chat/): Design the messaging feature for a service marketplace: customers and providers chat one-to-one and in small groups of up to 50. Messages m… - [Infinite feed with images and video](https://aie-bp24.onrender.com/interview/feed/): Design the home feed for a social shopping app: an endless scroll of posts with photos and short videos. It must open instantly, scroll at … - [Checkout and payments that never double-charge](https://aie-bp24.onrender.com/interview/payments/): Design checkout for a mobile commerce app processing 50,000 orders an hour at peak sales. Cards, UPI and wallets. Networks are flaky, users… - [Healthcare appointment booking without double-booking](https://aie-bp24.onrender.com/interview/booking/): Design a booking platform for 3,000 clinics: patients book slots in a mobile app, practitioners manage availability in a partner app, and a… - [Mobile platform for 150 engineers: builds, releases, flags](https://aie-bp24.onrender.com/interview/release/): You join as principal engineer. The company has one Android and one iOS app built by 150 engineers in 20 teams. Builds take 40 minutes, rel… - [An AI assistant inside a mobile app](https://aie-bp24.onrender.com/interview/ai-assistant/): Our wellness booking app has 2 million daily users. Product wants an in-app assistant that answers questions about services, recommends pra… - [On-device AI versus cloud: a hybrid design](https://aie-bp24.onrender.com/interview/on-device/): We want three AI features in our app: smart replies in chat, summarising long service descriptions, and identifying products in photos. Lea… - [Retrieval-augmented answers over company documents](https://aie-bp24.onrender.com/interview/rag/): Our support and sales teams want an assistant that answers questions from 5 million internal documents: policies, product manuals, tickets … - [Serving an open LLM on your own GPU fleet](https://aie-bp24.onrender.com/interview/llm-serving/): For cost and data-residency reasons we will self-host a 70-billion-parameter open model for our assistant and internal tools. Expected load… - [Shipping LLM features safely: evals, guardrails, monitoring](https://aie-bp24.onrender.com/interview/ai-evals/): Three teams are shipping LLM features: a support assistant, ticket summarisation, and marketing copy generation. Each has had embarrassing … ## Protocols - [DHCP · Dynamic Host Configuration Protocol](https://aie-bp24.onrender.com/protocols/dhcp/): How a device with nothing gets an address. - [IP · Internet Protocol (IPv4)](https://aie-bp24.onrender.com/protocols/ip/): Addresses and hops: how a packet finds its way. - [ICMP · Internet Control Message Protocol](https://aie-bp24.onrender.com/protocols/icmp/): The network’s way of telling you what went wrong. - [UDP · User Datagram Protocol](https://aie-bp24.onrender.com/protocols/udp/): Fast, simple, no promises. - [DNS · Domain Name System](https://aie-bp24.onrender.com/protocols/dns/): The internet’s phone book. - [TCP · Transmission Control Protocol](https://aie-bp24.onrender.com/protocols/tcp/): A reliable, ordered byte stream over an unreliable network. - [TLS · Transport Layer Security](https://aie-bp24.onrender.com/protocols/tls/): Privacy, integrity and identity for any connection. - [HTTP · Hypertext Transfer Protocol](https://aie-bp24.onrender.com/protocols/http/): The request and response language of the web. - [HTTPS · HTTP over TLS](https://aie-bp24.onrender.com/protocols/https/): HTTP inside a TLS tunnel. - [SMTP · Simple Mail Transfer Protocol](https://aie-bp24.onrender.com/protocols/smtp/): How email is sent and relayed. - [POP3 · Post Office Protocol v3](https://aie-bp24.onrender.com/protocols/pop3/): Download the mail, then it’s yours. - [IMAP · Internet Message Access Protocol](https://aie-bp24.onrender.com/protocols/imap/): Mail that stays on the server and syncs everywhere. - [FTP · File Transfer Protocol](https://aie-bp24.onrender.com/protocols/ftp/): The classic file transfer protocol with two connections. - [SSH · Secure Shell](https://aie-bp24.onrender.com/protocols/ssh/): An encrypted tunnel for logins, commands and files. ## Coding patterns - [Two pointers pattern](https://aie-bp24.onrender.com/coding/two-pointers/): Walk inwards from both ends of a sorted sequence. - [Sliding window pattern](https://aie-bp24.onrender.com/coding/sliding-window/): Grow the right edge, shrink the left edge while invalid. - [Fast and slow pointers pattern](https://aie-bp24.onrender.com/coding/fast-slow/): One pointer moves twice as fast; they meet in a cycle. - [Binary search pattern](https://aie-bp24.onrender.com/coding/binary-search/): Halve the search space, including the answer space. - [Prefix sums and hashing pattern](https://aie-bp24.onrender.com/coding/prefix-hash/): Remember what you have seen to answer in O(1). - [Monotonic stack pattern](https://aie-bp24.onrender.com/coding/monotonic-stack/): Keep a stack in sorted order to find the next greater or smaller. - [Heap / top-K pattern](https://aie-bp24.onrender.com/coding/heap/): Keep the best K so far in a size-K heap. - [Intervals pattern](https://aie-bp24.onrender.com/coding/intervals/): Sort by start, then sweep and merge. - [BFS and DFS pattern](https://aie-bp24.onrender.com/coding/graphs/): Explore grids and graphs; BFS gives shortest steps. - [Topological sort pattern](https://aie-bp24.onrender.com/coding/topo-sort/): Order tasks so every dependency comes first. - [Union-find pattern](https://aie-bp24.onrender.com/coding/union-find/): Merge groups and ask 'same group?' almost instantly. - [Backtracking pattern](https://aie-bp24.onrender.com/coding/backtracking/): Choose, explore, un-choose. - [Dynamic programming pattern](https://aie-bp24.onrender.com/coding/dynamic-programming/): Define the state, write the recurrence, fill the table. - [Trie pattern](https://aie-bp24.onrender.com/coding/trie/): A tree of characters for fast prefix lookups. - [Greedy pattern](https://aie-bp24.onrender.com/coding/greedy/): Take the locally best choice, and prove it is safe. ## Machine coding - [LRU cache with a memory budget](https://aie-bp24.onrender.com/mobile-coding/lru-cache/): O(1) get and put, evicting the least recently used item when bytes exceed a limit. - [Image loader with coalescing and two cache tiers](https://aie-bp24.onrender.com/mobile-coding/image-loader/): Memory, then disk, then network, and fifty identical requests become one download. - [Offline outbox with idempotent sync](https://aie-bp24.onrender.com/mobile-coding/outbox/): Writes persist first, sync later, survive kills, and are never applied twice. - [Retry with exponential backoff and jitter](https://aie-bp24.onrender.com/mobile-coding/backoff/): Retries that recover calmly instead of stampeding a struggling server. - [Search-as-you-type with debounce and cancellation](https://aie-bp24.onrender.com/mobile-coding/search-debounce/): One request per pause in typing, and never a stale result on screen. - [Cursor-based infinite feed](https://aie-bp24.onrender.com/mobile-coding/feed-pagination/): Prefetch before the bottom, one request at a time, no duplicates, no stale pages. - [Resumable multipart uploader](https://aie-bp24.onrender.com/mobile-coding/resumable-upload/): Upload a 4 GB video in parts, a few at a time, and resume after a kill. - [Client-side token bucket rate limiter](https://aie-bp24.onrender.com/mobile-coding/rate-limiter/): Allow bursts, then a steady rate, so your app cannot DDoS your own API. - [List diffing for animated UI updates](https://aie-bp24.onrender.com/mobile-coding/list-diff/): Turn old and new lists into deletes, inserts, moves and reloads, in O(n log n).