Standard Algorithms – Sorting, Searching, QuickSort, MergeSort & BubbleSort
This post is a definition of terms for standard algorithms – including exam questions and tags.
In a Nutshell
Standard algorithms are fundamental, frequently used procedures for solving typical problems such as sorting, searching, traversal, or computation. They form the foundation of algorithmic thinking in software development.
Compact Technical Description
Standard algorithms are established, optimized procedures for recurring tasks such as sorting (e.g., QuickSort, MergeSort), searching (e.g., binary search), traversing data structures (e.g., depth-first and breadth-first search), or mathematical operations (e.g., Euclidean algorithm). Their complexity is usually described using Big-O notation, which indicates efficiency in terms of runtime and memory requirements. In almost all programming languages, they are available as library functions, but they should also be manually understood and implemented at their core – particularly for the IHK exam.
Exam-Relevant Key Points
- Standard algorithms efficiently solve common basic problems
- Typical categories: sorting, searching, traversing
- Compared based on complexity (O-notation)
- Knowledge is part of the written IHK exam
- Practical use e.g., in tables, reports, database queries
- Choosing the right algorithm significantly improves performance
- Must be documented (e.g., pseudocode, flowchart) and tested
Core Components
- Sorting algorithms (e.g., BubbleSort, MergeSort)
- Search algorithms (e.g., binary search, linear search)
- Traversal algorithms (e.g., DFS, BFS for graphs/trees)
- Recursive algorithms (e.g., QuickSort, Fibonacci)
- Iterative algorithms (e.g., counting loops)
- Complexity analysis (O-notation)
- Memory consumption analysis
- Data structure dependency (array, list, tree)
- Security through avoiding infinite loops
- Verification through test cases and dry-runs
Practical Example
// Example: Linear search in an array
function search(array, target)
for i from 0 to array.length - 1
if array[i] == target
return i
return -1
Explanation: This function searches the array sequentially for the target value and returns the index or -1 if not found.
Advantages and Disadvantages
Advantages
- Efficient for known use cases
- Well documented and proven
- Usually included in standard libraries
Disadvantages
- Must be adapted to the specific case
- Wrong use can be inefficient or incorrect
- More complex algorithms difficult to understand for beginners
Typical Exam Questions (with Short Answer)
- Two standard sorting algorithms and complexity? QuickSort (O(n log n)), BubbleSort (O(n²))
- O(n) in complexity analysis means? Runtime grows linearly with input size.
- Binary search is suitable when? Only with previously sorted arrays or lists.
- Depth-first search in a graph works? Through recursive or stack-driven traversal to the leaf nodes.
- Why is BubbleSort inefficient? Because of the quadratic runtime for any input size.
- Dry-run of an algorithm? Manual step-by-step execution for verification.
- Ensure correctness of an algorithm? Through test cases, edge cases, and runtime comparisons.
- Recursive vs. iterative algorithms? Recursive use function calls, iterative use loops.