SWE Fundamentals Part 2 Flashcards
What is a trie used for?
Efficient prefix matching, like autocomplete or dictionary lookups.
What is a union-find data structure?
A structure that tracks disjoint sets, useful for Kruskal’s algorithm and cycle detection in graphs.
What is topological sort used for?
Ordering nodes in a Directed Acyclic Graph (DAG) where dependencies matter (e.g. task scheduling).
What is a segment tree?
A tree used for range queries and updates (e.g. sum, min, max over ranges).
What is the time complexity of inserting into a binary heap?
O(log n)
What is the difference between preorder, inorder, and postorder traversal?
Preorder: root → left → right, Inorder: left → root → right, Postorder: left → right → root.
What is the difference between DFS recursive and iterative?
Recursive uses the call stack; iterative uses an explicit stack.
What are the time complexities of DFS and BFS?
O(V + E), where V is vertices and E is edges.
What is bit manipulation used for?
Space-efficient operations and optimizations (e.g. toggling bits, checking power of 2).
What is a shallow copy?
A copy where nested objects still reference the original.
What is a deep copy?
A full independent copy including all nested objects.
What is the difference between mutable and immutable types?
Mutable types (like lists) can be changed; immutable types (like tuples or strings) cannot.
What is a static method?
A method that doesn’t access instance data and is bound to the class.
What is the difference between an abstract class and an interface?
Abstract classes can have partial implementations; interfaces define method signatures only.
What is the difference between object-oriented and functional programming?
OOP centers around objects and state; functional emphasizes pure functions and immutability.
What happens during program compilation?
Source code is translated to machine code (or bytecode), optionally optimized, and linked.
What is a memory leak?
Allocated memory that’s never released, leading to increased usage over time.
What is garbage collection good for?
Automatically cleaning up unused memory, preventing memory leaks.
What is DNS?
A system that translates domain names to IP addresses.
What’s the difference between HTTP and HTTPS?
HTTPS is HTTP over TLS/SSL – it’s encrypted and secure.
What is the client-server model?
Client sends requests; server processes them and returns responses.
What is latency in networking?
The time it takes for data to travel from source to destination.
What is caching?
Storing previously retrieved or computed data to speed up future access.
How does a browser fetch a webpage?
DNS lookup → HTTP request → server response → HTML rendered by browser.