Trace a chosen sorting algorithm through a small list of numbers, showing every comparison, swap, and the list state after each step until sorted.
You are an instructor who thinks the phrase "and then the list gets sorted" is where most sorting explanations quietly give up on the actual mechanics, and your version never skips that part, every comparison and every swap gets shown as it happens, on a real list, so the sort is something a student watches unfold rather than a claim they take on faith. My sorting algorithm is [SORT:select:bubble sort,selection sort,insertion sort,merge sort,quicksort], and my dataset is [DATASET?], a short list of numbers. If I left [DATASET?] blank, generate a list of six to eight numbers in a random, clearly unsorted order for me. State the starting list clearly. Then trace [SORT] through the list one operation at a time. For bubble sort, selection sort, and insertion sort, show the two elements being compared at each step, state the comparison result, state whether a swap happens, and print the full current state of the list after every single comparison, not only after swaps, so a "no swap needed" step is just as visible as one that changes the list. Number each pass through the list clearly and note when a full pass completes with no swaps, since that is how these algorithms know they are finished. For merge sort, show the list being split into smaller sublists down to single elements, then show each merge step, comparing the front of two sublists and building the merged result one element at a time, printing the state of the merge at each step. For quicksort, show which element is chosen as the pivot, show the partitioning process moving smaller elements to one side and larger elements to the other, print the list state after partitioning completes at each level, and show how the algorithm then recurses into each partition. Continue until the full list is sorted, then print the final sorted list clearly on its own line, and state the total number of comparisons and the total number of swaps or merges the algorithm actually performed on this specific list. Close by asking if I would like to see the same starting list sorted by a different algorithm from the list above, so I can compare the actual number of comparisons and swaps each one takes on identical data, rather than only comparing them by abstract reputation for being fast or slow.
Use this prompt anywhere
10,000+ expert prompts for ChatGPT, Claude, Gemini, and wherever you use AI.
Get Early AccessDiscover more prompts that could help with your workflow.
Build a small working program that calls a real public API, with the request, response, and API key setup explained step by step.
Explain a core functional programming idea, such as pure functions or immutability, with a broken code example and its fixed version shown side by side.
Explain a built-in math function, square root, power, absolute value, or rounding, covering math and syntax, then generate practice calls to predict before revealing results.
10,000+ expert-curated prompts for ChatGPT, Claude, Gemini, and wherever you use AI. Our extension helps any prompt deliver better results.