Skip to main content

Posts

Showing posts from August 9, 2026

Linear Search problem practice In DSA

Linear Search — Practice Problems in Data structures & algorithms (DSA) Practice Sheet: Applying Linear Search to common array problems Goal: Learn how to scan an array from left to right and apply Linear Search to find a first index, check presence, count occurrences, find all indexes, and find a maximum value. Problem 1 — Find First Index Given the array [15, 8, 22, 10, 7, 22] and target 22 . •   Return the first index of 22. •   Expected answer: 2 Problem 2 — Check Presence Given the array [4, 9, 12, 6, 18, 3] and target 15 . •   Return True if 15 is present. •   Return False if 15 is not present. •   Expected answer: False Problem 3 — Count Occurrences Given the array [5, 2, 5, 8, 5, 9, 2] and target 5 . •   Return the number of occurrences of 5. •   Expected answer: 3 Problem 4 — Find All Indexes Given the array [3, 7, 3, 10, 3, 5, 3] and target 3 . •   Return all indexes where 3 occurs. •  ...