Computational Thinking in Computer Science: 30 Top-
ics
This document presents 30 computer science tasks analyzed through the lens of com-
putational thinking principles: Decomposition, Pattern Recognition, Abstraction, and
Algorithm Design. Each topic is explained concisely, with real-world applications and
challenges, tailored for IBDP Computer Science students.
Contents
1 Searching for a Student Record in a Database 5
1.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 5
1.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 5
1.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 5
1.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 5
2 Encrypting a Message Before Transmission 6
2.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 6
2.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 6
2.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 6
2.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 6
3 Handling Invalid User Input in a Form 8
3.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 8
3.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 8
3.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 8
3.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 8
4 Implementing a Login System 10
4.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 10
4.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 10
4.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 10
4.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 10
5 Sorting a List of Books by Title Alphabetically 12
5.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 12
5.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 12
5.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 12
5.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 12
6 Checking for Palindrome Words 13
6.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 13
6.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 13
6.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 13
6.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 13
7 Counting Occurrences of a Character in a String 14
7.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 14
1
7.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 14
7.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 14
7.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 14
8 Validating Email Format 15
8.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 15
8.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 15
8.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 15
8.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 15
9 Encrypting Passwords with Hashing 16
9.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 16
9.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 16
9.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 16
9.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 16
10 Handling File Uploads 17
10.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 17
10.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 17
10.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 17
10.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 17
11 Generating a Report of Student Grades 18
11.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 18
11.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 18
11.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 18
11.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 18
12 Implementing Two-Factor Authentication 19
12.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 19
12.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 19
12.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 19
12.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 19
13 Checking if a Number is Prime 20
13.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 20
13.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 20
13.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 20
13.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 20
14 Implementing Auto-Save Feature in an Editor 21
14.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 21
14.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 21
14.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 21
14.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 21
15 Compressing Files to Reduce Size 22
15.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 22
15.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 22
15.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 22
2
15.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 22
16 Tracking User Session 23
16.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 23
16.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 23
16.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 23
16.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 23
17 Designing a Chat Application 24
17.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 24
17.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 24
17.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 24
17.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 24
18 Implementing Undo and Redo in Software 25
18.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 25
18.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 25
18.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 25
18.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 25
19 Validating a Password Strength 26
19.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 26
19.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 26
19.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 26
19.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 26
20 Handling Date and Time Inputs 27
20.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 27
20.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 27
20.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 27
20.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 27
21 Implementing a Voting System 28
21.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 28
21.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 28
21.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 28
21.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 28
22 Detecting Duplicate Entries in a Dataset 29
22.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 29
22.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 29
22.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 29
22.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 29
23 Handling Pagination in Web Pages 30
23.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 30
23.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 30
23.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 30
23.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 30
3
24 Implementing Dark Mode Toggle 31
24.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 31
24.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 31
24.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 31
24.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 31
25 Designing a Calculator Application 32
25.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 32
25.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 32
25.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 32
25.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 32
26 Implementing Auto-Complete Feature 33
26.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 33
26.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 33
26.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 33
26.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 33
27 Detecting Anomalies in Sensor Data 34
27.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 34
27.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 34
27.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 34
27.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 34
28 Implementing Auto-Backup Feature 35
28.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 35
28.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 35
28.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 35
28.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 35
29 Building a Recommendation System 36
29.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 36
29.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 36
29.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 36
29.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 36
30 Implementing User Roles and Permissions 37
30.1 Decomposition (Breaking down the problem) . . . . . . . . . . . . . . . . 37
30.2 Pattern Recognition (Finding similarities & differences) . . . . . . . . . . 37
30.3 Abstraction (Focusing on important details) . . . . . . . . . . . . . . . . 37
30.4 Algorithm Design (Step-by-step solution) . . . . . . . . . . . . . . . . . . 37
4
1 Searching for a Student Record in a Database
1.1 Decomposition (Breaking down the problem)
We split the task of searching for a student record into smaller sub-tasks:
• Input a search query (e.g., student ID or name).
• Access the database containing student records.
• Compare the query with record fields.
• Retrieve and display matching record(s).
• Handle cases where no match is found.
1.2 Pattern Recognition (Finding similarities & differences)
• Searching mirrors looking up contacts in a phonebook or items in a catalog.
• Common search patterns:
– Iterate through records and compare fields.
– Use linear search for unsorted data or binary search for sorted data.
• Student data varies (e.g., IDs are numbers, names are strings), but the comparison
logic is similar to searching other datasets.
1.3 Abstraction (Focusing on important details)
• Ignore irrelevant details like student address or enrollment date.
• Focus only on key attributes:
– ID → Numeric comparison.
– Name → String comparison.
• The search logic applies to any database, regardless of size or structure.
1.4 Algorithm Design (Step-by-step solution)
Example: Searching by student ID (linear search)
1. Take the student ID as input.
2. Iterate through database records.
3. Compare the input ID with each records ID.
4. If a match is found → display the records details.
5. If no match → output Record not found.
Real-World Application: Used in school management systems (e.g., PowerSchool) to
retrieve student profiles. Challenges: Handling partial matches, case sensitivity, and
securing database access.
5
2 Encrypting a Message Before Transmission
2.1 Decomposition (Breaking down the problem)
We split the task of encrypting a message into smaller sub-tasks:
• Input the plain text message.
• Choose an encryption method and key.
• Transform the message into cipher text.
• Transmit the encrypted message.
• Decrypt at the receivers end.
2.2 Pattern Recognition (Finding similarities & differences)
• Encryption mirrors secure communication in emails or messaging apps.
• Common encryption patterns:
– Substitute characters (e.g., Caesar cipher).
– Use a key for transformations.
– Reverse the process for decryption.
• Message content varies, but the transformation logic is similar to other encryption
tasks.
2.3 Abstraction (Focusing on important details)
• Ignore details like key generation or message content.
• Focus only on:
– Message → String to encrypt.
– Key → Transformation rule.
• The encryption logic applies to any text, regardless of length or language.
2.4 Algorithm Design (Step-by-step solution)
Example: Encrypting with a Caesar cipher
1. Take the message and shift key (e.g., 3).
2. For each character → shift its ASCII value by the key.
3. Handle wrap-around (e.g., Z → C).
4. Output the cipher text.
5. Decrypt by shifting back.
6
Real-World Application: Used in secure messaging (e.g., Signal) or HTTPS. Chal-
lenges: Secure key exchange, handling special characters, and performance for large
data.
7
3 Handling Invalid User Input in a Form
3.1 Decomposition (Breaking down the problem)
We split the task of handling invalid input into smaller sub-tasks:
• Define the expected input format (e.g., numeric, email).
• Accept user input from the form.
• Validate input against rules.
• Display error messages for invalid input.
• Allow retry until valid.
3.2 Pattern Recognition (Finding similarities & differences)
• Validation mirrors checking inputs in login forms or surveys.
• Common validation patterns:
– Check data type (e.g., number vs. string).
– Verify format (e.g., email structure).
– Loop through rules until all are satisfied.
• Input types vary, but the validation logic is similar to other form-processing tasks.
3.3 Abstraction (Focusing on important details)
• Ignore UI elements like colors or layout.
• Focus only on:
– Input → String or number to validate.
– Rules → Constraints like length or format.
• The validation logic applies to any form field, regardless of purpose.
3.4 Algorithm Design (Step-by-step solution)
Example: Validating a numeric input
1. Take the users input.
2. Check if its a number and within range (e.g., 1100).
3. If invalid → display an error message.
4. If valid → proceed.
5. Prompt retry for invalid input.
8
Real-World Application: Used in web forms (e.g., Google Forms) or registration sys-
tems. Challenges: Handling edge cases, providing clear error messages, and balancing
strictness with usability.
9
4 Implementing a Login System
4.1 Decomposition (Breaking down the problem)
We split the task of implementing a login system into smaller sub-tasks:
• Input username and password.
• Retrieve stored credentials from a database.
• Compare input with stored data.
• Grant or deny access based on comparison.
• Handle invalid attempts.
4.2 Pattern Recognition (Finding similarities & differences)
• Authentication mirrors unlocking a phone or accessing a bank account.
• Common authentication patterns:
– Compare input with stored credentials.
– Use hashing for secure password comparison.
– Handle failed attempts with retries or lockouts.
• Credential formats vary, but the verification logic is similar to other secure systems.
4.3 Abstraction (Focusing on important details)
• Ignore UI elements like login buttons or styling.
• Focus only on:
– Username → Identifier string.
– Password → Securely hashed string.
• The authentication logic applies to any system, regardless of platform.
4.4 Algorithm Design (Step-by-step solution)
Example: Basic login with hashed passwords
1. Take username and password as input.
2. Retrieve stored credentials from the database.
3. Hash the input password and compare with stored hash.
4. If both match → grant access.
5. If not → display Invalid credentials and prompt retry.
10
Real-World Application: Used in school portals, social media (e.g., X), or banking
apps. Challenges: Preventing brute-force attacks, secure password storage, and han-
dling recovery.
11
5 Sorting a List of Books by Title Alphabetically
5.1 Decomposition (Breaking down the problem)
We split the task of sorting books into smaller sub-tasks:
• Input a list of books (title, author, etc.).
• Select the title field for sorting.
• Compare titles alphabetically.
• Rearrange books in order (AZ).
• Display the sorted list.
5.2 Pattern Recognition (Finding similarities & differences)
• Sorting mirrors organizing a dictionary or phonebook.
• Common sorting patterns:
– Compare two items at a time.
– Swap if out of order.
– Repeat until sorted.
• Book titles are strings, but the sorting logic is similar to sorting names or words.
5.3 Abstraction (Focusing on important details)
• Ignore irrelevant fields like author or ISBN.
• Focus only on:
– Title → String comparison (AZ).
• The sorting logic applies to any list of books, regardless of size or source.
5.4 Algorithm Design (Step-by-step solution)
Example: Sorting books by title (Bubble Sort)
1. Take the list of books.
2. Compare titles of adjacent books.
3. If the first title comes after the second → swap them.
4. Repeat until no swaps are needed.
5. Output the sorted list.
Real-World Application: Used in library systems or e-commerce (e.g., Amazon book
sorting). Challenges: Performance for large lists, case sensitivity, and handling special
characters.
12
6 Checking for Palindrome Words
6.1 Decomposition (Breaking down the problem)
We split the task of checking palindromes into smaller sub-tasks:
• Input a word from the user.
• Reverse the words characters.
• Compare the original and reversed word.
• Output whether its a palindrome.
6.2 Pattern Recognition (Finding similarities & differences)
• Palindromes mirror symmetrical patterns in DNA or word games.
• Common palindrome patterns:
– Reverse the string.
– Compare with the original.
• Word content varies, but the reversal logic is similar to other string checks.
6.3 Abstraction (Focusing on important details)
• Ignore case, spaces, or punctuation.
• Focus only on:
– Word → Sequence of characters.
• The palindrome logic applies to any string, regardless of length.
6.4 Algorithm Design (Step-by-step solution)
Example: Checking if a word is a palindrome
1. Take the word as input.
2. Convert to lowercase.
3. Reverse the words characters.
4. If original equals reversed → output Palindrome.
5. Else → output Not a palindrome.
Real-World Application: Used in word games or DNA sequence analysis. Chal-
lenges: Handling special characters, optimizing for long strings, and supporting Unicode.
13
7 Counting Occurrences of a Character in a String
7.1 Decomposition (Breaking down the problem)
We split the task of counting characters into smaller sub-tasks:
• Input a string and target character.
• Iterate through the string.
• Count matches of the target character.
• Output the total count.
7.2 Pattern Recognition (Finding similarities & differences)
• Counting mirrors keyword searches or data analysis.
• Common counting patterns:
– Iterate through items.
– Increment a counter for matches.
• Strings vary, but the counting logic is similar to tallying items in a list.
7.3 Abstraction (Focusing on important details)
• Ignore string content or context.
• Focus only on:
– Character → Item to match.
– String → Sequence to search.
• The counting logic applies to any string or character.
7.4 Algorithm Design (Step-by-step solution)
Example: Counting occurrences of a
1. Take the string and target character.
2. Initialize a counter to 0.
3. For each character in the string → if it matches, increment counter.
4. Output the counter value.
Real-World Application: Used in text analysis or search engines. Challenges: Case
sensitivity, Unicode support, and optimizing for long strings.
14
8 Validating Email Format
8.1 Decomposition (Breaking down the problem)
We split the task of validating an email into smaller sub-tasks:
• Input an email string.
• Check for @ and domain structure.
• Validate characters in username and domain.
• Output whether the email is valid.
8.2 Pattern Recognition (Finding similarities & differences)
• Email validation mirrors URL or phone number checks.
• Common validation patterns:
– Check for specific symbols (e.g., @, .).
– Parse string into parts (username, domain).
• Email formats vary, but the structural logic is similar to other format checks.
8.3 Abstraction (Focusing on important details)
• Ignore unrelated features like spam detection.
• Focus only on:
– Email → String with @ and domain.
• The validation logic applies to any email address.
8.4 Algorithm Design (Step-by-step solution)
Example: Validating email format
1. Take the email string.
2. Check for one @ symbol.
3. Split into username and domain.
4. Validate username and domain format.
5. Output Valid or Invalid.
Real-World Application: Used in registration forms or email clients. Challenges:
Supporting complex formats, Unicode, and avoiding overly strict rules.
15
9 Encrypting Passwords with Hashing
9.1 Decomposition (Breaking down the problem)
We split the task of hashing passwords into smaller sub-tasks:
• Input a plain text password.
• Apply a hash function.
• Store the hashed password.
• Verify input during login.
9.2 Pattern Recognition (Finding similarities & differences)
• Hashing mirrors checksums or digital signatures.
• Common hashing patterns:
– Transform input to fixed-length hash.
– Compare hashes for verification.
• Passwords vary, but the hashing logic is similar to other security tasks.
9.3 Abstraction (Focusing on important details)
• Ignore hash function internals.
• Focus only on:
– Password → String to hash.
– Hash → Secure output.
• The hashing logic applies to any password.
9.4 Algorithm Design (Step-by-step solution)
Example: Hashing with bcrypt
1. Take the password.
2. Generate a hash using bcrypt.
3. Store the hash.
4. During login, hash the input and compare.
5. Output access result.
Real-World Application: Used in authentication systems (e.g., WordPress). Chal-
lenges: Choosing secure hash functions, managing salts, and handling legacy systems.
16
10 Handling File Uploads
10.1 Decomposition (Breaking down the problem)
We split the task of file uploads into smaller sub-tasks:
• Select a file from the users device.
• Validate file size and type.
• Upload the file to a server.
• Store the file with metadata.
• Confirm upload success.
10.2 Pattern Recognition (Finding similarities & differences)
• File uploads mirror cloud storage or email attachments.
• Common upload patterns:
– Validate file attributes.
– Transfer data over a network.
• File types vary, but the upload logic is similar to other data transfer tasks.
10.3 Abstraction (Focusing on important details)
• Ignore UI elements like progress bars.
• Focus only on:
– File → Data with size and type.
• The upload logic applies to any file.
10.4 Algorithm Design (Step-by-step solution)
Example: Uploading a PDF file
1. Take the selected file.
2. Check if size < 10MB and type is PDF.
3. Upload file to server.
4. Store with timestamp.
5. Output Upload successful or Failed.
Real-World Application: Used in cloud storage (e.g., Dropbox) or assignment portals.
Challenges: Handling large files, securing uploads, and managing storage.
17
11 Generating a Report of Student Grades
11.1 Decomposition (Breaking down the problem)
We split the task of generating a grade report into smaller sub-tasks:
• Input student scores.
• Calculate total and average scores.
• Assign grades based on thresholds.
• Format and display the report.
11.2 Pattern Recognition (Finding similarities & differences)
• Report generation mirrors financial or sports statistics.
• Common reporting patterns:
– Aggregate data (e.g., sum, average).
– Apply rules to categorize results.
• Scores vary, but the calculation logic is similar to other data aggregation tasks.
11.3 Abstraction (Focusing on important details)
• Ignore irrelevant details like student contact info.
• Focus only on:
– Scores → Numbers to process.
– Grades → Categories based on rules.
• The reporting logic applies to any score dataset.
11.4 Algorithm Design (Step-by-step solution)
Example: Generating a grade report
1. Take a list of scores.
2. Calculate total and average.
3. Assign grade (e.g., ≥90 → A).
4. Output report with scores and grade.
Real-World Application: Used in academic systems (e.g., Canvas). Challenges:
Handling missing scores, weighted grades, and clear formatting.
18
12 Implementing Two-Factor Authentication
12.1 Decomposition (Breaking down the problem)
We split the task of 2FA into smaller sub-tasks:
• Input username and password.
• Generate and send a verification code.
• Validate the input code.
• Grant or deny access.
12.2 Pattern Recognition (Finding similarities & differences)
• 2FA mirrors bank card PIN verification.
• Common 2FA patterns:
– Verify credentials.
– Send and check a temporary code.
• Delivery methods vary, but the verification logic is similar to other security tasks.
12.3 Abstraction (Focusing on important details)
• Ignore delivery method (e.g., SMS, email).
• Focus only on:
– Credentials → User verification.
– Code → Temporary token.
• The 2FA logic applies to any system.
12.4 Algorithm Design (Step-by-step solution)
Example: 2FA with SMS code
1. Take username and password.
2. Verify credentials.
3. Generate and send a code.
4. Compare input code with sent code.
5. Output access result.
Real-World Application: Used in banking or email services (e.g., Gmail). Chal-
lenges: Code delivery delays, lost devices, and securing transmission.
19
13 Checking if a Number is Prime
13.1 Decomposition (Breaking down the problem)
We split the task of checking primality into smaller sub-tasks:
• Input a number.
• Check divisibility from 2 to square root.
• Determine if the number is prime.
• Output the result.
13.2 Pattern Recognition (Finding similarities & differences)
• Prime checking mirrors factoring numbers.
• Common primality patterns:
– Test divisibility.
– Stop at square root for efficiency.
• Numbers vary, but the divisibility logic is similar to other math tasks.
13.3 Abstraction (Focusing on important details)
• Ignore unrelated properties (e.g., even/odd).
• Focus only on:
– Number → Integer to test.
• The primality logic applies to any positive integer.
13.4 Algorithm Design (Step-by-step solution)
Example: Checking if a number is prime
1. Take a number n.
2. If n < 2 → output Not prime.
√
3. Check divisibility from 2 to n.
4. If divisible → output Not prime.
5. Else → output Prime.
Real-World Application: Used in cryptography (e.g., RSA). Challenges: Optimizing
for large numbers, handling edge cases, and computational efficiency.
20
14 Implementing Auto-Save Feature in an Editor
14.1 Decomposition (Breaking down the problem)
We split the task of auto-saving into smaller sub-tasks:
• Monitor document changes.
• Schedule periodic saves.
• Save the document to storage.
• Handle save errors.
14.2 Pattern Recognition (Finding similarities & differences)
• Auto-save mirrors backup systems or cloud sync.
• Common auto-save patterns:
– Trigger on change or timer.
– Save data to storage.
• Document types vary, but the save logic is similar to other persistence tasks.
14.3 Abstraction (Focusing on important details)
• Ignore UI or formatting details.
• Focus only on:
– Document → Data to save.
• The auto-save logic applies to any editor.
14.4 Algorithm Design (Step-by-step solution)
Exampleurane Example: Auto-saving every 5 seconds
1. Monitor document changes.
2. If changed or 5 seconds elapsed → save document.
3. Check save status.
4. If failed → retry.
5. Continue monitoring.
Real-World Application: Used in Google Docs or IDEs. Challenges: Balancing save
frequency, handling network failures, and ensuring consistency.
21
15 Compressing Files to Reduce Size
15.1 Decomposition (Breaking down the problem)
We split the task of file compression into smaller sub-tasks:
• Select a file to compress.
• Apply a compression algorithm.
• Create a compressed archive.
• Save the compressed file.
15.2 Pattern Recognition (Finding similarities & differences)
• Compression mirrors encoding images or videos.
• Common compression patterns:
– Remove redundant data.
– Use encoding techniques (e.g., run-length).
• File types vary, but the compression logic is similar to other data reduction tasks.
15.3 Abstraction (Focusing on important details)
• Ignore algorithm specifics (e.g., Huffman coding).
• Focus only on:
– File → Data to compress.
• The compression logic applies to any file.
15.4 Algorithm Design (Step-by-step solution)
Example: Run-length encoding compression
1. Take the file data.
2. For each character → count consecutive repeats.
3. Encode as count + character.
4. Save the compressed data.
5. Ensure decompression restores the original.
Real-World Application: Used in ZIP files or image formats (e.g., PNG). Challenges:
Choosing the right algorithm, handling large files, and ensuring compatibility.
22
16 Tracking User Session
16.1 Decomposition (Breaking down the problem)
We split the task of session tracking into smaller sub-tasks:
• Generate a session ID.
• Store user actions.
• Monitor session expiration.
• Handle logout or timeout.
16.2 Pattern Recognition (Finding similarities & differences)
• Session tracking mirrors cookies or tokens in web apps.
• Common session patterns:
– Assign unique ID.
– Track actions and time.
• Actions vary, but the tracking logic is similar to other state management tasks.
16.3 Abstraction (Focusing on important details)
• Ignore UI or specific actions.
• Focus only on:
– Session → ID and user data.
• The tracking logic applies to any system.
16.4 Algorithm Design (Step-by-step solution)
Example: Tracking a web session
1. Generate a unique session ID on login.
2. Store ID and user data.
3. Update with actions.
4. Check if session timed out (e.g., 30 minutes).
5. Terminate on logout or expiration.
Real-World Application: Used in e-commerce or social media (e.g., X). Challenges:
Ensuring unique IDs, preventing hijacking, and managing storage.
23
17 Designing a Chat Application
17.1 Decomposition (Breaking down the problem)
We split the task of building a chat app into smaller sub-tasks:
• Capture users message.
• Send message over a network.
• Receive and display messages.
• Store conversation history.
17.2 Pattern Recognition (Finding similarities & differences)
• Chat apps mirror email or messaging systems.
• Common chat patterns:
– Send/receive data packets.
– Store messages with timestamps.
• Message types vary, but the communication logic is similar to other networked apps.
17.3 Abstraction (Focusing on important details)
• Ignore UI elements like emojis.
• Focus only on:
– Message → Text to send/receive.
• The chat logic applies to any messaging system.
17.4 Algorithm Design (Step-by-step solution)
Example: Sending a chat message
1. Take the users message.
2. Package with sender and timestamp.
3. Send to recipient via server.
4. Store in database.
5. Display incoming messages.
Real-World Application: Used in WhatsApp or Slack. Challenges: Real-time deliv-
ery, offline messages, and encryption.
24
18 Implementing Undo and Redo in Software
18.1 Decomposition (Breaking down the problem)
We split the task of undo/redo into smaller sub-tasks:
• Record user actions.
• Store actions in stacks.
• Retrieve states for undo/redo.
• Update the interface.
18.2 Pattern Recognition (Finding similarities & differences)
• Undo/redo mirrors browser history navigation.
• Common undo/redo patterns:
– Use stacks to store states.
– Pop states to revert or reapply.
• Action types vary, but the stack logic is similar to other history tracking tasks.
18.3 Abstraction (Focusing on important details)
• Ignore specific action types.
• Focus only on:
– State → Action to storeFig.
• The undo/redo logic applies to any software.
18.4 Algorithm Design (Step-by-step solution)
Example: Undo/redo in a text editor
1. On action → push state to undo stack.
2. For undo → pop undo stack, push to redo stack.
3. For redo → pop redo stack, push to undo stack.
4. Update the document to reflect the current state.
Real-World Application: Used in text editors (e.g., Microsoft Word) or design tools.
Challenges: Memory management, complex actions, and collaborative editing.
25
19 Validating a Password Strength
19.1 Decomposition (Breaking down the problem)
We split the task of password validation into smaller sub-tasks:
• Input a password string.
• Check length and character types.
• Assign a strength score.
• Output the strength level.
19.2 Pattern Recognition (Finding similarities & differences)
• Password validation mirrors form input checks.
• Common validation patterns:
– Check multiple criteria (e.g., length, symbols).
– Score based on rules.
• Passwords vary, but the validation logic is similar to other security checks.
19.3 Abstraction (Focusing on important details)
• Ignore UI feedback (e.g., progress bars).
• Focus only on:
– Password → String to validate.
• The validation logic applies to any password.
19.4 Algorithm Design (Step-by-step solution)
Example: Checking password strength
1. Take the password.
2. Check length (≥8) and types (uppercase, numbers).
3. Score 1 point per criterion met.
4. Output Strong if score ≥ 4, else Weak.
Real-World Application: Used in login systems or password managers. Challenges:
Balancing security and usability, Unicode support, and clear feedback.
26
20 Handling Date and Time Inputs
20.1 Decomposition (Breaking down the problem)
We split the task of handling dates into smaller sub-tasks:
• Input a date string.
• Validate format (e.g., DD/MM/YYYY).
• Check date validity (e.g., no 30th February).
• Output result or perform calculations.
20.2 Pattern Recognition (Finding similarities & differences)
• Date validation mirrors email or phone checks.
• Common date patterns:
– Parse format.
– Check ranges (e.g., 131 for days).
• Date formats vary, but the validation logic is similar to other format checks.
20.3 Abstraction (Focusing on important details)
• Ignore UI or time zones.
• Focus only on:
– Date → Structured string.
• The validation logic applies to any date input.
20.4 Algorithm Design (Step-by-step solution)
Example: Validating a date
1. Take the date string.
2. Check format (e.g., DD/MM/YYYY).
3. Validate day, month, and year ranges.
4. Output Valid or Invalid.
Real-World Application: Used in booking systems or calendars (e.g., Google Calen-
dar). Challenges: Different formats, leap years, and internationalization.
27
21 Implementing a Voting System
21.1 Decomposition (Breaking down the problem)
We split the task of a voting system into smaller sub-tasks:
• Input list of candidates.
• Accept user votes.
• Count votes for each candidate.
• Display the winner.
21.2 Pattern Recognition (Finding similarities & differences)
• Voting mirrors polls or elections.
• Common voting patterns:
– Collect and count votes.
– Find the highest count.
• Candidate types vary, but the counting logic is similar to other tallying tasks.
21.3 Abstraction (Focusing on important details)
• Ignore voter demographics.
• Focus only on:
– Votes → Candidate selections.
• The voting logic applies to any election.
21.4 Algorithm Design (Step-by-step solution)
Example: Counting votes
1. Display candidates.
2. Accept a vote.
3. Increment candidates vote count.
4. Find candidate with most votes.
5. Output winner.
Real-World Application: Used in online polls or classroom voting. Challenges:
Preventing multiple votes, handling ties, and securing the system.
28
22 Detecting Duplicate Entries in a Dataset
22.1 Decomposition (Breaking down the problem)
We split the task of detecting duplicates into smaller sub-tasks:
• Input a dataset.
• Compare entries for matches.
• Flag or list duplicates.
• Output or remove duplicates.
22.2 Pattern Recognition (Finding similarities & differences)
• Duplicate detection mirrors data cleaning or deduplication.
• Common detection patterns:
– Track seen items.
– Mark duplicates.
• Data types vary, but the comparison logic is similar to other matching tasks.
22.3 Abstraction (Focusing on important details)
• Ignore irrelevant fields (e.g., timestamps).
• Focus only on:
– Entries → Items to compare.
• The detection logic applies to any dataset.
22.4 Algorithm Design (Step-by-step solution)
Example: Finding duplicate names
1. Take the dataset.
2. Use a set to track seen items.
3. If an item is in the set → mark as duplicate.
4. Output duplicates.
Real-World Application: Used in database management or contact deduplication.
Challenges: Handling large datasets, partial duplicates, and case sensitivity.
29
23 Handling Pagination in Web Pages
23.1 Decomposition (Breaking down the problem)
We split the task of pagination into smaller sub-tasks:
• Input a dataset.
• Divide into pages (e.g., 10 items/page).
• Accept users page selection.
• Display the selected pages data.
23.2 Pattern Recognition (Finding similarities & differences)
• Pagination mirrors search engine or e-commerce listings.
• Common pagination patterns:
– Slice data into chunks.
– Navigate between pages.
• Data varies, but the slicing logic is similar to other navigation tasks.
23.3 Abstraction (Focusing on important details)
• Ignore UI elements like page buttons.
• Focus only on:
– Data → List to paginate.
• The pagination logic applies to any dataset.
23.4 Algorithm Design (Step-by-step solution)
Example: Paginating a product list
1. Calculate total pages (items ÷ items per page).
2. Take the selected page number.
3. Slice data for the page.
4. Display the pages items.
Real-World Application: Used in Google Search or X feeds. Challenges: Dynamic
data changes, optimizing large datasets, and smooth navigation.
30
24 Implementing Dark Mode Toggle
24.1 Decomposition (Breaking down the problem)
We split the task of dark mode toggle into smaller sub-tasks:
• Detect users theme choice.
• Apply theme styles (e.g., dark/light colors).
• Save the preference.
• Load preference on startup.
24.2 Pattern Recognition (Finding similarities & differences)
• Theme switching mirrors settings management.
• Common toggle patterns:
– Switch between states (e.g., on/off).
– Persist state across sessions.
• Themes vary, but the toggle logic is similar to other state changes.
24.3 Abstraction (Focusing on important details)
• Ignore specific styles (e.g., colors).
• Focus only on:
– Theme → Light or dark state.
• The toggle logic applies to any UI.
24.4 Algorithm Design (Step-by-step solution)
Example: Toggling dark mode
1. Take current theme (light/dark).
2. If light → apply dark styles, save dark.
3. If dark → apply light styles, save light.
4. Load saved theme on startup.
Real-World Application: Used in websites or apps (e.g., X, YouTube). Challenges:
Smooth transitions, accessibility, and system theme integration.
31
25 Designing a Calculator Application
25.1 Decomposition (Breaking down the problem)
We split the task of a calculator into smaller sub-tasks:
• Input numbers and operator.
• Parse the expression.
• Perform the calculation.
• Display the result.
25.2 Pattern Recognition (Finding similarities & differences)
• Calculators mirror spreadsheet functions.
• Common calculation patterns:
– Parse numbers and operators.
– Apply arithmetic rules.
• Expressions vary, but the calculation logic is similar to other math tasks.
25.3 Abstraction (Focusing on important details)
• Ignore UI elements like buttons.
• Focus only on:
– Expression → Numbers and operator.
• The calculation logic applies to any arithmetic operation.
25.4 Algorithm Design (Step-by-step solution)
Example: Basic arithmetic calculator
1. Take the expression (e.g., 2 + 3).
2. Parse into numbers and operator.
3. Perform the operation (e.g., add).
4. Output the result.
Real-World Application: Used in calculator apps or financial tools. Challenges:
Complex expressions, precision issues, and input validation.
32
26 Implementing Auto-Complete Feature
26.1 Decomposition (Breaking down the problem)
We split the task of auto-complete into smaller sub-tasks:
• Capture partial user input.
• Search for matching items.
• Display suggestions.
• Handle user selection.
26.2 Pattern Recognition (Finding similarities & differences)
• Auto-complete mirrors search engine suggestions.
• Common auto-complete patterns:
– Filter items by prefix.
– Sort and limit suggestions.
• Input varies, but the matching logic is similar to other search tasks.
26.3 Abstraction (Focusing on important details)
• Ignore UI elements like dropdowns.
• Focus only on:
– Input → Partial string.
– Database → List to search.
• The auto-complete logic applies to any search system.
26.4 Algorithm Design (Step-by-step solution)
Example: Auto-completing words
1. Take partial input (e.g., ap).
2. Find items starting with input.
3. Sort and limit to 5 suggestions.
4. Display suggestions.
Real-World Application: Used in Google Search or IDEs (e.g., VS Code). Chal-
lenges: Large datasets, fuzzy matching, and real-time performance.
33
27 Detecting Anomalies in Sensor Data
27.1 Decomposition (Breaking down the problem)
We split the task of anomaly detection into smaller sub-tasks:
• Input sensor data stream.
• Define normal range (e.g., mean ± 2σ).
• Flag outliers.
• Output anomalies.
27.2 Pattern Recognition (Finding similarities & differences)
• Anomaly detection mirrors fraud or quality control.
• Common anomaly patterns:
– Compare against statistical thresholds.
– Flag significant deviations.
• Data types vary, but the detection logic is similar to other analysis tasks.
27.3 Abstraction (Focusing on important details)
• Ignore sensor hardware.
• Focus only on:
– Data → Numerical values.
• The detection logic applies to any sensor data.
27.4 Algorithm Design (Step-by-step solution)
Example: Detecting temperature anomalies
1. Take sensor data.
2. Calculate mean and standard deviation.
3. Flag values > 2σ from mean.
4. Output anomalies.
Real-World Application: Used in IoT or healthcare (e.g., heart rate monitors). Chal-
lenges: Defining thresholds, noisy data, and real-time processing.
34
28 Implementing Auto-Backup Feature
28.1 Decomposition (Breaking down the problem)
We split the task of auto-backup into smaller sub-tasks:
• Monitor data changes.
• Schedule backups.
• Save data to backup location.
• Handle backup errors.
28.2 Pattern Recognition (Finding similarities & differences)
• Auto-backup mirrors cloud sync or auto-save.
• Common backup patterns:
– Trigger on change or timer.
– Save data securely.
• Data varies, but the backup logic is similar to other persistence tasks.
28.3 Abstraction (Focusing on important details)
• Ignore storage medium.
• Focus only on:
– Data → Content to save.
• The backup logic applies to any system.
28.4 Algorithm Design (Step-by-step solution)
Example: Auto-backup every hour
1. Monitor data changes.
2. If changed or hour elapsed → save data.
3. Verify backup success.
4. Retry on failure.
Real-World Application: Used in Google Drive or database systems. Challenges:
Storage management, network failures, and data consistency.
35
29 Building a Recommendation System
29.1 Decomposition (Breaking down the problem)
We split the task of recommendations into smaller sub-tasks:
• Input user preferences.
• Match preferences with dataset.
• Rank matching items.
• Display recommendations.
29.2 Pattern Recognition (Finding similarities & differences)
• Recommendations mirror product or video suggestions.
• Common recommendation patterns:
– Filter by similarity.
– Rank by relevance.
• Preferences vary, but the matching logic is similar to other filtering tasks.
29.3 Abstraction (Focusing on important details)
• Ignore UI elements like cards.
• Focus only on:
– Preferences → User data.
– Items → Dataset to match.
• The recommendation logic applies to any system.
29.4 Algorithm Design (Step-by-step solution)
Example: Recommending movies
1. Take users liked movies.
2. Find similar movies in dataset.
3. Rank by similarity score.
4. Display top 5 recommendations.
Real-World Application: Used in Netflix or X suggested posts. Challenges: Cold-
start problem, large datasets, and balancing relevance.
36
30 Implementing User Roles and Permissions
30.1 Decomposition (Breaking down the problem)
We split the task of role management into smaller sub-tasks:
• Define roles (e.g., admin, student).
• Assign permissions to roles.
• Validate user actions against permissions.
• Allow or deny actions.
30.2 Pattern Recognition (Finding similarities & differences)
• Role management mirrors access control in CMS or OS.
• Common permission patterns:
– Map roles to actions.
– Check permissions before execution.
• Roles vary, but the validation logic is similar to other security tasks.
30.3 Abstraction (Focusing on important details)
• Ignore UI or specific actions.
• Focus only on:
– Role → Set of permissions.
– Action → Task to validate.
• The permission logic applies to any system.
30.4 Algorithm Design (Step-by-step solution)
Example: Checking permissions
1. Assign a role to the user.
2. Map role to permissions.
3. Check if action is in permissions.
4. Allow if permitted, else deny.
Real-World Application: Used in school systems or WordPress. Challenges: Com-
plex hierarchies, dynamic role changes, and security.
37