๐Ÿงฎ
๐Ÿ“ Data Structures & Algorithms ยท DS-101 ยท Assignments

Data Structures & Algorithms โ€” Assignments

Work each problem yourself first, then open the worked solution to check your thinking. This is where the course sticks.

๐Ÿ“ 5 problemsโœ๏ธ Worked solutions
Problem 1

Give an example where switching a data structure would make code faster or cleaner.

Show worked solution

A strong answer identifies a real scenario - e.g. repeated membership checks against a list (slow scan) replaced by a set (near-instant), or finding-by-id scans replaced by a dict keyed by id - and explains that choosing the structure is often the real optimisation, not tweaking lines.

Problem 2

List the fast and slow operations of a list, and when you'd use a set/dict/deque instead.

Show worked solution

Good answers note lists are fast for indexing/appending/iterating and slow for value search and front inserts, and that you'd switch to a set/dict for fast membership/lookup and a deque for efficient front operations - matching structure to access pattern.

Problem 3

Explain how hashing makes dict/set lookups fast, in your own words.

Show worked solution

Strong answers convey that the structure computes where an item belongs from the item itself (a hash), so it jumps straight there instead of scanning - giving near-constant lookup however big the data, unlike a list's scan. No need for the maths of hash functions.

Problem 4

Identify a real problem that needs a stack, one that needs a queue, and one that's a graph.

Show worked solution

Good answers correctly match access patterns: a stack for LIFO (undo, back-navigation, reversing), a queue for FIFO (fair processing, scheduling, buffering), and a graph for connected/network data (social network, map, dependencies) - showing they can recognise the shape of a problem.

Problem 5

Explain Big-O in your own words, and why an O(n^2) approach can be a problem.

Show worked solution

A strong answer describes Big-O as how an algorithm's work grows with data size (the growth shape, not exact time), names the common classes (O(1)/O(log n)/O(n)/O(n^2)), and explains that O(n^2) (often nested loops) grows fast and becomes slow on big data - so you watch for and avoid it, preferring faster-scaling approaches.

More in this course

Course home → · Browse all courses →