0
0
Digital Marketingknowledge~5 mins

Ad creative formats (image, video, carousel) in Digital Marketing - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Ad creative formats (image, video, carousel)
O(n)
Understanding Time Complexity

When using different ad creative formats like images, videos, or carousels, it's important to understand how the time to load and display these ads changes as the number of ads or elements grows.

We want to know how the work needed grows when we add more creative items.

Scenario Under Consideration

Analyze the time complexity of loading multiple ad creatives in a carousel format.


// Pseudocode for loading carousel ads
for each ad in carousel_ads:
    load_ad(ad)
    display_ad(ad)
    if ad.type == 'video':
        preload_video(ad)

This code loads and displays each ad in a carousel, preloading videos when needed.

Identify Repeating Operations

Look at what repeats as the number of ads increases.

  • Primary operation: Looping through each ad to load and display it.
  • How many times: Once for every ad in the carousel.
How Execution Grows With Input

As you add more ads, the total work grows directly with the number of ads.

Input Size (n)Approx. Operations
10About 10 loads and displays
100About 100 loads and displays
1000About 1000 loads and displays

Pattern observation: The work increases evenly as you add more ads.

Final Time Complexity

Time Complexity: O(n)

This means the time to load and display ads grows in a straight line with the number of ads.

Common Mistake

[X] Wrong: "Loading a video ad takes the same time as an image ad, so all ads cost the same time."

[OK] Correct: Video ads usually take longer to load and may require extra steps like preloading, so they add more time than simple images.

Interview Connect

Understanding how loading times grow with more ads helps you design better user experiences and shows you can think about performance in real projects.

Self-Check

"What if we added lazy loading so only visible ads load immediately? How would that change the time complexity?"