InterviewStack.io LogoInterviewStack.io

Python Data Structures and Algorithms Questions

Core Python data structure and algorithm knowledge used for manipulating collections and solving common data processing problems. Candidates should know built in types such as lists, dictionaries, sets, and tuples and their performance characteristics; be able to implement and reason about searching, sorting, counting, deduplication, and frequency analysis tasks; and choose appropriate algorithms and data structures for time and space efficiency. Familiarity with Python standard library utilities such as collections.Counter, defaultdict, deque, and heapq is expected, as is writing Pythonic, clear code that handles edge cases. Questions may include algorithmic trade offs, complexity analysis, and applying these techniques to practical data manipulation problems where custom logic is required beyond what pandas or NumPy provide.

HardTechnical
0 practiced
Design an algorithm in Python to normalize deeply nested JSON records into multiple relational tables (e.g., users, events, attributes) in a streaming fashion that uses O(1) memory per record. Explain how to handle arrays (one-to-many), missing fields, schema evolution, surrogate keys, and referential integrity for downstream analytics.
EasyTechnical
0 practiced
Write a Python function count_frequencies(items: Iterable[str]) -> Dict[str, int] that returns counts for each item. Provide two implementations: one using a plain dict and one using collections.Counter. For very large lists (tens of millions), compare performance and memory trade-offs and explain when Counter's C-optimized code is beneficial in a data pipeline.
HardSystem Design
0 practiced
For deduplicating events at massive scale across distributed workers, propose a hybrid design that uses hash partitioning to route likely-duplicates to the same worker and Count-Min Sketch (CMS) to filter obvious uniques before shuffle. Describe how to choose CMS parameters, mergeability of sketches, error rates, and how this reduces network shuffle compared to a full-key shuffle.
EasyTechnical
0 practiced
Compare methods to reverse a Python list: list.reverse(), reversed(list), slicing [::-1], and list(reversed(list)). For each method state whether it reverses in-place or returns an iterator/new list, and analyze time and space complexity. Which approach should you use in memory-constrained ETL jobs where large lists of primitives are common?
HardTechnical
0 practiced
Python has a Global Interpreter Lock (GIL). As a data engineer, discuss options to implement thread-safe concurrent data structures for a high-throughput pipeline: threading with locks, multiprocessing, asyncio, and C-extensions. Provide a code sketch for a producer/consumer queue safe for multiple producers and consumers and comment on performance trade-offs.

Unlock Full Question Bank

Get access to hundreds of Python Data Structures and Algorithms interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.