Home|Contents|Prev|Next|Chat


DAA Answers 5 - Problem types & data structures

DAA-Q34 Important problem types

DAA-Q35 Classical geometric problems

Closest-pair (find the closest pair among n points) and convex-hull (smallest convex polygon containing all points).

DAA-Q36 Stable and in-place sorts

Stable preserves order of equal elements; in-place uses constant extra memory. Bubble: stable/in-place/O(n^2). Insertion: stable/in-place/O(n^2). Selection: not stable/in-place/O(n^2). Merge: stable/not in-place/O(n log n). Quick: not stable/in-place/O(n log n) avg. Heap: not stable/in-place/O(n log n).

DAA-Q37 Data structure; arrays vs linked lists

A scheme of organising related data. Array: contiguous, same type, index access. Linked list: nodes with data + pointers, traversal access; singly or doubly linked.

DAA-Q38 Stack, queue, priority queue

Stack: one end (top), LIFO. Queue: front dequeue, rear enqueue, FIFO. Priority queue: find-largest, delete-largest, insert; implemented with a heap.

DAA-Q39 Graph; representations

A graph is vertices some joined by edges (undirected/directed). Path = adjacent vertices (simple if distinct). Cycle starts and ends at one vertex. Connected = a path between every pair. Adjacency matrix n x n (1 if edge), or adjacency list of linked lists; weighted versions store weights.

DAA-Q40 Trees, rooted trees, BSTs

Free tree = connected acyclic graph; |E|=|V|-1, one simple path between any two vertices. Rooted tree fixes a root (level 0); parent, child, leaf, depth, height. Binary tree: at most two children. BST: left subtree keys smaller, right larger. Ordered tree encoded as first-child / next-sibling.

DAA-Q41 Sets and dictionaries

A set is an unordered collection of distinct items (membership, union, intersection); bit vector or list. A dictionary searches, adds, deletes; hashing or balanced trees. Set union maintains a dynamic partition under union/search.


Home|Contents|Prev|Next|Top|Chat