๐Master Linear Search in Minutes (Simple DevOps Example + Time Complexity)
Raees Qazi | DevOps Engineer | Learner | Mentor | Creator | CEO-Briller Technologies
Today, I will explain algorithms in a very simple way, especially from a DevOps engineer’s point of view.
๐น Code vs Algorithm (Important Difference)
Before jumping into algorithms, let’s understand the difference:
Code:
A set of instructions written in a programming language that a computer can understand and execute.
Algorithm:
An algorithm is the idea or step-by-step logic to solve a problem.
It is not code — it’s the thinking behind the code.
๐ In simple words:
- Algorithm = Plan
- Code = Implementation of that plan

๐ Linear Search Algorithm (Real DevOps Example)
Let’s take a simple DevOps-related example.
We have environments like:
env = ["dev", "stg", "prd"]
key = "stg"Now, we want to find “stg” environment in the list.
๐ง Algorithm Steps (Thinking Process)
As a DevOps engineer, here’s how we think:
- Start
- Loop through all environments
- Compare each environment with the key
- If matched → Found
Else → Not Found - Stop
๐ This is called Linear Search because we check elements one by one.
๐ป Convert Algorithm into Code (Python Example)
Now let’s implement this in code:
list_of_envs = ["dev", "stg", "prd", "test", "qa"]
key = "test"for env in list_of_envs:
if env == key:
print("Found")
break
Explanation:
- We loop through each environment
- Compare it with the key
- If found, we print “Found” and stop the loop
๐ Alternative Approach (Better Practice)
list_of_envs = ["dev", "stg", "prd", "test", "qa"]
key = "test"is_found = False
for env in list_of_envs:
if env == key:
is_found = True
if is_found:
print("Found")
else:
print("Not Found")
Why this is better?
- Cleaner logic
- More control (useful in real DevOps scripts and automation)
⏱️ Time Complexity (Very Important Concept)
When writing algorithms, we must think about performance.
What is Time Complexity?
It tells us how much time an algorithm takes based on input size.
๐น Single Loop Example
If we have n elements, and loop runs through all:
Time Complexity = O(n)๐ Example: Linear Search
๐น Nested Loop Example
for i in range(n):
for j in range(n):
print(i, j)If n = 3, loop runs:
3 × 3 = 9 times๐ Time Complexity = O(n²)
⚠️ DevOps Insight
As a DevOps engineer:
- Always try to reduce loops
- Avoid unnecessary nested loops
- Optimize scripts for better performance (important in CI/CD pipelines)
✅ Final Thoughts
- Algorithm is your thinking process
- Code is your execution
- Always consider time complexity
- Write efficient and clean scripts
If you found this helpful, feel free to share it with others in your DevOps community ๐
๐ Online References
- LinkedIn: https://www.linkedin.com/in/raees-yaqoob-qazi-ryqs/
- Medium Blog: https://medium.com/@raeesyaqubqazi
- Blogspot: https://brillertechnologies.blogspot.com/
- Facebook Page: https://web.facebook.com/profile.php?id=61553548371216
- YouTube Channel: https://www.youtube.com/@RaeesQ.
- TikTok: https://www.tiktok.com/@mrryqs?_t=ZS-8y7t0fQfJKu&_r=1
Comments
Post a Comment