top of page
HD-wallpaper-python-amoled-coding-coding-dark-dark-programming-python-sky-universe_edited.

Real-Life Situation/Scenerio: VIDEO EDITOR OPTIMIZING WORKFLOW

You are a video editor managing a collection of edited video files for different categories of content, including wedding events, vlogs, and infomercials. Each category contains 10 video files, and you need to organize and name them for easy access and retrieval. To efficiently sort and name the video files, you decide to implement the Insertion Sort algorithm, applying the Decrease and Conquer approach.

maxresdefault.jpg
photo-1515879218367-8466d910aaa4-scaled_edited.jpg
Functionality Dscription
desktop-wallpaper-python-programming-python-coding.jpg

SOURCE CODE AVAILABLE

INSERTION SORTING USAGE

Insertion Sort is a straightforward sorting algorithm that builds the final sorted array one item at a time by repeatedly taking the next element and inserting it into the sorted portion of the array. It is suitable for small datasets and is easy to implement, making it ideal for situations where efficiency is less of a concern compared to simplicity.

Why Insertion Sort

Insertion Sort is chosen for sorting the video files into categories because of its simplicity and effectiveness for small datasets.

  1. Small Dataset: With only 10 videos in each category, the dataset is relatively small. Insertion Sort's time complexity of O(n^2) is less of a concern for smaller datasets compared to larger ones.

  2. Stability: Insertion Sort is a stable sorting algorithm, meaning it preserves the relative order of equal elements. In the context of sorting video files for categories, stability ensures that videos with the same name or similar attributes remain in the same order after sorting.

  3. Ease of Implementation: Insertion Sort is straightforward to implement, making it a suitable choice for this scenario where simplicity is prioritized over performance optimization. The code is easy to understand and maintain, which is beneficial for managing video files in a video editing workflow.

  4. Efficiency for Almost Sorted Data: Since the video files may already be partially sorted by their names or other attributes, Insertion Sort's efficiency increases when dealing with nearly sorted data. This property makes it particularly suitable for situations where the input data is already partially ordered.

desktop-wallpaper-python-programming-python-coding.jpg

SOURCE CODE AVAILABLE

PSEUDOCODE

function insertionSort(video_files):

for i from 1 to length(video_files) - 1:

key = video_files[i]

j = i - 1

while j >= 0 and video_files[j] > key:

video_files[j + 1] = video_files[j]

j = j - 1

video_files[j + 1] = key

desktop-wallpaper-python-programming-python-coding.jpg

SOURCE CODE AVAILABLE

MAIN CODE

423455003_366596512853734_8867781615253194212_n.png
desktop-wallpaper-python-programming-python-coding.jpg

SOURCE CODE AVAILABLE

MAIN CODE OUTPUT

423454390_7272242582863420_7278657308088653412_n.png
desktop-wallpaper-python-programming-python-coding.jpg

SOURCE CODE AVAILABLE

CODE BREAKDOWN

  • def insertion_sort(video_files): Defines a function insertion_sort that takes a list of video files as input.

  • The algorithm iterates through each element of the list starting from index 1.

  • For each element, it compares it with the elements to its left in the sorted portion of the list.

  • If the current element is less than the element to its left, it shifts the elements to the right to make space for insertion.

  • Finally, it inserts the current element into its correct position in the sorted portion of the list.

CSAL REFLECTION

REFLECTION

GAINED KNOWLEDGE

Implementing the Insertion Sort algorithm in this project provided valuable insights into sorting techniques and their application in real-world scenarios. I gained a deeper understanding of how Insertion Sort works, particularly its approach of building the final sorted array one element at a time by comparing and inserting elements into their correct positions. Additionally, I learned about the stability of sorting algorithms and its significance in maintaining the order of equal elements.

© 2022 by Lawrence Acodili
Powered and secured by Wix

Call

+639615667908

Write

acodililawrence200.wixsite.com/lawrenceaco

Follow

  • Facebook
  • Twitter
  • LinkedIn
  • Instagram
bottom of page