Big O Notation in Data Structure

Patient Tools

Read, save, and share this guide

Use these quick tools to make this medical article easier to read, print, save, or share with a family member.

On this page20 sections

Article Summary

Big O Notation is one of the most necessary mathematical notations used in computer science to measure an algorithm's efficiency. We can analyze how efficient an algorithm is from the amount of time, storage, other resources it takes to run the algorithm, and a change in the input size. Big O Notation in Data Structure tells us how well an algorithm will perform in a particular situation. In other...

Key Takeaways

  • This article explains An Introduction to Asymptotic Notations in simple medical language.
  • This article explains What is Big O Notation in Data Structure? in simple medical language.
  • This article explains Properties of Big O Notation in simple medical language.
  • This article explains How Does Big O Notation Make a Runtime Analysis of an Algorithm? in simple medical language.
Before reading

RX Patient Tools

Use these quick guides before reading the article, or return to them when you need help preparing questions for a doctor.

Start here Choose the right pathway for symptoms, reports, medicines, or urgent warning signs. Disease article roadmap Read this topic step by step: meaning, symptoms, warning signs, diagnosis, treatment, prevention, and follow-up. Treatment planner Prepare questions about treatment choices, benefits, risks, side effects, and follow-up. Family & caregiver guide Organize symptoms, reports, medicines, questions, and follow-up safely. Nutrition & diet guide Prepare food, hydration, supplement, and medicine-timing questions safely. Prevention guide Organize risk factors, protective habits, screening, and warning signs. Recovery guide Prepare a safe plan for activity, rehabilitation, warning signs, and follow-up.
Educational health guideWritten for patient understanding and clinical awareness.
Reviewed content workflowUse writer and reviewer profiles for stronger trust.
Emergency safety firstUrgent warning signs are highlighted below.
Definition

Big O Notation is one of the most necessary mathematical notations used in computer science to measure an algorithm’s efficiency. We can analyze how efficient an algorithm is from the amount of time, storage, other resources it takes to run the algorithm, and a change in the input size. Big O Notation in Data Structure tells us how well an algorithm will perform in a particular situation. In other words, it gives an algorithm’s upper-bound runtime or worst-case complexity.

An Introduction to Asymptotic Notations

The performance of an algorithm can change with a change in the input size. That is where Asymptotic Notations like Big O Notation comes into play. Asymptotic Notations can describe an algorithm’s run time when the input tends toward a specific or limiting value. Asymptotic analysis helps to analyze the algorithm performance change in the order of input size.

What is Big O Notation in Data Structure?

Big O Notation in Data Structure is used to express algorithmic complexity using algebraic terms. It describes the upper bound of an algorithm’s runtime and calculates the time and amount of memory needed to execute the algorithm for an input value.

Mathematical Definition

Consider the functions f(n) and g(n), where functions f and g are defined on an unbounded set of positive real numbers. g(n) is strictly positive for every large value of n.

The function f is said to be O(g) (read as big- oh of g), if, for a constant c>0 and a natural number n0, f (n) ≤ CG(n) for all n >= n0

This can be written as:

f(n) = O(g(n)), where n tends to infinity (n → ∞)

We can simply write the above expression as:

f(n) = O(g(n))

Properties of Big O Notation

The most important properties of Big O Notation in Data Structure are:

  • Constant Multiplication:

If f(n) = CG(n), then O(f(n)) = O(g(n)) for a constant c > 0

  • Summation Function:

If f(n) = f1(n) + f2(n) + — + FM(n) and fi(n)≤ fi+1(n) ∀ i=1, 2, –, m,

then O(f(n)) = O(max(f1(n), f2(n), –, fm(n)))

  • Logarithmic Function:

If f(n) = log an and g(n)=log bn, then

O(f(n)) = O(g(n))

  • Polynomial Function:

If f(n) = a0 + a1.n + a2.n2 + — + am.nm, then

O(f(n)) = O(nm)

How Does Big O Notation Make a Runtime Analysis of an Algorithm?

In order to analyze and calculate an algorithm’s performance, we must calculate and compare the worst-case runtime complexities of the algorithm. The order of O(1) – known as the Constant Running Time – is the fastest running time for an algorithm, with the time taken by the algorithm being equal for different input sizes. Although the Constant Running Time is the ideal runtime for an algorithm, it can be rarely achieved because the runtime depends on the size of n inputted.

For example, runtime analysis of an algorithm for a size of n = 20:

n=20,

log (20) = 2.996

20 = 20

20 log (20) = 59.9

20^2 = 400

2^20 = 1084576

20! = 2.432902 + 1818

  • Runtime complexity of some common algorithmic examples:
  • Runtime Complexity for Linear Search – O(n)
  • Runtime Complexity for Binary Search – O(log n)
  • Runtime Complexity for Bubble Sort, Insertion Sort, Selection Sort, Bucket Sort – O(n^c).
  • Runtime Complexity for Exponential algorithms like Tower of Hanoi – O(c^n).
  • Runtime Complexity for Heap Sort, Merge Sort – O(n log n).

How Does Big O Notation Analyze Space Complexity?

It is also essential to determine the Space Complexity of an algorithm. This is because space complexity indicates how much memory space the algorithm occupies. We compare the worst-case space complexities of the algorithm.

Before the Big O notation analyzes the Space complexity, the following tasks need to be implemented:

  1. Implementation of the program for a particular algorithm.
  2. The size of input n needs to be known to calculate the memory each item will hold.

Space Complexities of some common algorithms:

Linear Search, Binary Search, Bubble sort, Selection sort, Heap sort, Insertion sort – Space Complexity is O(1).

  • Radix sort – Space complexity is O(n+k).
  • Quick Sort – Space complexity is O(n).
  • Merge sort – Space complexity is O(log n).

Example of Big O Notation in C

Implementation of Selection Sort algorithm in C to find worst-case complexity (Big O Notation) of the algorithm:

for(int i=0; i<n; i++)

{

int min = i;

for(int j=i; j<n; j++)

{

if(array[j]<array[min])

min=j;

}

int temp = array[i];

array[i] = array[min];

array[min] = temp;

}

Explanation:

The range of the first (outer) for loop is i<n, meaning the order of the loop is O(n).

The range for the second (inner) for loop is j<n; so, the order of the loop is again O(n).

Average efficiency is calculated as n/2 for a constant c, but we ignore the constant. Thus, the order comes to be O(n).

We get runtime complexity by multiplying the inner and outer loop order. It is O(n^2).

In this way, you can implement other algorithms in C, and analyze and determine the complexities.

Our Learners Also Asked

1. What is Big O notation? Give some examples.

In computer science, Big O Notation is a fundamental tool used to find out the time complexity of algorithms. Big O Notation allows programmers to classify algorithms depending on how their run time or space requirements vary as the input size varies.

Examples:

  • Runtime Complexity for Linear Search – O(n)
  • Runtime Complexity for Binary Search – O(log n)
  • Runtime Complexity for Bubble Sort, Selection Sort, Insertion Sort, Bucket Sort – O(n^c).
  • Runtime Complexity for Exponential algorithms like Tower of Hanoi – O(c^n).
  • Runtime Complexity for Heap Sort, Merge Sort – O(n log n).

2. Why is Big O notation used?

Big O Notation gives the upper-bound runtime or worst-case complexity of an algorithm. It analyzes and classifies algorithms depending on their run time or space requirements.

3. What are time complexity and Big O notation?

Time complexity refers to the amount of time an algorithm takes to run when the input tends towards a specific or limiting value. It calculates the time taken to execute each code statement in an algorithm.

Big O Notation is a tool used to describe the time complexity of algorithms. It calculates the time taken to run an algorithm as the input grows. In other words, it calculates the worst-case time complexity of an algorithm.

Big O Notation in Data Structure describes the upper bound of an algorithm’s runtime. It calculates the time and amount of memory needed to execute the algorithm for an input value.

4. What is the other name for Big O notation?

Big O Notation is a mathematical notation named after the term “order of the function”, meaning growth of functions. It is also called Landau’s Symbol and belongs to the Asymptotic Notations group.

5. What are the rules of using Big O notation?

The main rules of Big O Notation in Data Structure are:

  • Consider the functions f(n) and g(n), where both functions f and g are defined on an unbounded set of positive real numbers. g(n) is strictly positive for every large value of n.

The function f is said to be O(g) (read as big- oh of g), if, for a constant c>0 and a natural number n0, f (n) ≤ CG(n) for all n >= n0

This can be written as:

f(n) = O(g(n)), where n tends to infinity (n → ∞)

We can simply write the above expression as:

f(n) = O(g(n))

The algorithm’s total performance is f(n) = O(g(n) + f(n))

  • Constant Multiplication:

If f(n) = CG(n), then O(f(n)) = O(g(n)) for a constant c > 0

  • Summation Function:

If f(n) = f1(n) + f2(n) + — + FM(n) and fi(n)≤ fi+1(n) ∀ i=1, 2, –, m,

then O(f(n)) = O(max(f1(n), f2(n), –, fm(n)))

  • Logarithmic Function:

If f(n) = log an and g(n)=log bn, then

O(f(n)) = O(g(n))

  • Polynomial Function:

If f(n) = a0 + a1.n + a2.n2 + — + am.nm, then

O(f(n)) = O(nm)

Choose the Right Program

Supercharge your career in AI and ML with Simplilearn’s comprehensive courses. Gain the skills and knowledge to transform industries and unleash your true potential. Enroll now and unlock limitless possibilities!

Program Name AI Engineer Post Graduate Program In Artificial Intelligence Post Graduate Program In Artificial Intelligence
Geo All Geos All Geos IN/ROW
University Simplilearn Purdue Caltech
Course Duration 11 Months 11 Months 11 Months
Coding Experience Required Basic Basic No
Skills You Will Learn 10+ skills including data structure, data manipulation, NumPy, Scikit-Learn, Tableau and more. 16+ skills including
chatbots, NLP, Python, Keras and more.
8+ skills including
Supervised & Unsupervised Learning
Deep Learning
Data Visualization, and more.
Additional Benefits Get access to exclusive Hackathons, Masterclasses and Ask-Me-Anything sessions by IBM
Applied learning via 3 Capstone and 12 Industry-relevant Projects
Purdue Alumni Association Membership Free IIMJobs Pro-Membership of 6 months Resume Building Assistance Upto 14 CEU Credits Caltech CTME Circle Membership
Cost $$ $$$$ $$$$
Explore Program Explore Program Explore Program

Conclusion

If you work with big data, Big O Notation is especially useful in analyzing algorithms. The tool helps programmers calculate the scalability of an algorithm or count how many steps it must execute to give output based on data the program works on. If you’re looking to fine-tune your code to increase efficiency, the Big O Notation in Data Structure can be very effective. For more details on Big O Notation or coding, get started with our AI and ML certification course and be job-ready.

Doctor visit helper

Prepare before seeing a doctor

A simple rural-patient checklist to help you explain symptoms clearly, ask better questions, and avoid unsafe self-treatment.

Safety note: This is not a prescription or diagnosis. For severe symptoms, pregnancy danger signs, children with serious illness, chest pain, breathing difficulty, stroke-like weakness, or major injury, seek urgent care.

Which doctor may help?

Start with a registered doctor or the nearest qualified health center.

What to tell the doctor

  • Write when the problem started and how it changed.
  • Bring old prescriptions, investigation reports, and current medicines.
  • Write allergies, pregnancy status, diabetes, kidney/liver disease, and major past illnesses.
  • Bring one family member if the patient is weak, elderly, confused, or a child.

Questions to ask

  • What is the most likely cause of my symptoms?
  • Which danger signs mean I should go to hospital quickly?
  • Which tests are necessary now, and which can wait?
  • How should I take medicines safely and what side effects should I watch for?
  • When should I come for follow-up?

Tests to discuss

  • Vital signs: temperature, pulse, blood pressure, oxygen saturation
  • Basic physical examination by a clinician
  • CBC, urine test, blood sugar, or imaging only when clinically needed

Avoid these mistakes

  • Do not use antibiotics, steroid tablets/injections, or strong painkillers without proper medical advice.
  • Do not hide pregnancy, kidney disease, ulcer, allergy, or blood thinner use.
  • Do not delay emergency care when danger signs are present.

Medicine safety and first-aid guide

This section is for patient education only. It does not replace a doctor, pharmacist, or emergency care.

Safe first steps

  • Rest, drink safe water, and observe symptoms carefully.
  • Keep a written note of symptoms, duration, temperature, medicines already taken, and allergy history.
  • Seek medical care quickly if symptoms are severe, worsening, or unusual for the patient.

OTC medicine safety

  • For mild pain or fever, ask a registered pharmacist or doctor before using common over-the-counter pain/fever medicines.
  • Do not combine multiple pain medicines without advice, especially if you have kidney disease, liver disease, stomach ulcer, asthma, pregnancy, or take blood thinners.
  • Do not give adult medicines to children unless a qualified clinician advises it.

Avoid these mistakes

  • Do not start antibiotics without a proper medical decision.
  • Do not use steroid tablets or injections casually for quick relief.
  • Do not delay emergency care because of home remedies.

Get urgent help if

  • Severe symptoms, confusion, fainting, breathing difficulty, chest pain, severe dehydration, or sudden weakness need urgent medical care.
Medicine names, dose, and timing must be decided by a qualified clinician or pharmacist after checking age, pregnancy, allergy, other diseases, and current medicines.

For rural patients and family caregivers

Patient health record and symptom diary

Write your symptoms, medicines already taken, test results, and questions before visiting a doctor. This note stays on your device unless you print or copy it.

Doctor to discuss: Doctor / qualified healthcare provider
Tests to discuss with doctor
  • Basic vital signs: temperature, pulse, blood pressure, oxygen level if needed
  • Relevant blood, urine, imaging, or specialist tests only after clinical assessment
Questions to ask
  • What is the most likely cause of my symptoms?
  • Which warning signs mean I should go to emergency care?
  • Which tests are really needed now?
  • Which medicines are safe for my age, pregnancy status, allergy, kidney/liver/stomach condition, and current medicines?

Emergency warning signs such as chest pain, severe breathing difficulty, sudden weakness, confusion, severe dehydration, major injury, or loss of bladder/bowel control need urgent medical care. Do not wait for online information.

Safe pathway to proper treatment

Care roadmap for: Big O Notation in Data Structure

Use this simple roadmap to understand the next safe steps. It is educational and does not replace examination by a doctor.

Go to emergency care if you notice:
  • Severe or rapidly worsening symptoms
  • Breathing difficulty, chest pain, fainting, confusion, severe weakness, major injury, or severe dehydration
Doctor / service to discuss: Qualified healthcare provider; specialist depends on symptoms and examination.
  1. Step 1

    Check danger signs first

    If danger signs are present, seek emergency care and do not wait for online information.

  2. Step 2

    Record the symptom story

    Write when symptoms started, severity, medicines already taken, allergies, pregnancy status, and test results.

  3. Step 3

    Visit a qualified clinician

    A doctor, nurse, or qualified healthcare provider can examine you and decide which tests or treatment are needed.

  4. Step 4

    Do only useful tests

    Do tests after clinical assessment. Avoid unnecessary tests, random antibiotics, or repeated medicines without diagnosis.

  5. Step 5

    Follow up and return early if worse

    If symptoms worsen, new warning signs appear, or treatment is not helping, return for review quickly.

Rural patient practical tips
  • Take a written symptom diary and all previous prescriptions/test reports.
  • Do not hide medicines already taken, even herbal or over-the-counter medicines.
  • Ask which warning signs mean urgent referral to hospital.

This roadmap is for education. A real diagnosis and treatment plan requires history, examination, and clinical judgment.

Internal learning pathway

Explore related RX articles

Related guides from RX Harun are grouped to help readers move from overview to symptoms, tests, treatment, and safe next steps.

Rx Data Science and Artificial Intelligence
  1. Semantic Chunks for RAG DefinitionIn order to abide by the context window of the LLM , we usually break text…
  2. RAG Evaluation and Meta-Evaluation with GroUSE DefinitionThis tutorial introduces GroUSE, a framework for evaluating Retrieval-Augmented Generation (RAG) pipelines, focusing on the final…
  3. Deep Evaluation of RAG Systems using deepeval DefinitionThis code demonstrates the use of the deepeval library to perform comprehensive evaluations of Retrieval-Augmented Generation (RAG) systems.…
  4. Simple RAG with Llamaindex DefinitionThis code implements a basic Retrieval-Augmented Generation (RAG) system for processing and querying PDF document(s). The…
  5. Simple RAG (Retrieval-Augmented Generation) System DefinitionThis code implements a basic Retrieval-Augmented Generation (RAG) system for processing and querying PDF documents. The…
  6. Simple RAG (Retrieval-Augmented Generation) System for CSV Files DefinitionThis code implements a basic Retrieval-Augmented Generation (RAG) system for processing and querying CSV documents. The…