Page 1 of 1

function SortSmallestToLargest (entries): sorted_entries = {} while entries is not empty: smallest_entry = entries[0] fo

Posted: Mon May 09, 2022 7:12 am
by answerhappygod
Function Sortsmallesttolargest Entries Sorted Entries While Entries Is Not Empty Smallest Entry Entries 0 Fo 1
Function Sortsmallesttolargest Entries Sorted Entries While Entries Is Not Empty Smallest Entry Entries 0 Fo 1 (24.21 KiB) Viewed 31 times
FIND
1) TIME COMPLEXITY,
2) SPACE COMPLEXITY
EXPLAIN THE LOGIC BEHIND IT PROPERLY. NOT JUST THE ANSWER OR
DOWNVOTE !!!!!!!!!!!!
function SortSmallestToLargest (entries): sorted_entries = {} while entries is not empty: smallest_entry = entries[0] foreach entry in entries: if (entry <smallest_entry): smallest_entry = entry sorted_entries.add(smallest_entry) // 0(1) entries.remove(smallest_entry) // 0(1) return sorted_entries