Sorting arrays: Swap with a temporary array address? › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 3: [Algorithms] – Linear Search, Binary Search, Bubble Sort, Selection Sort, Recursion, Merge Sort › Sorting arrays: Swap with a temporary array address? Tagged: arrays, sorting arrays This topic has 0 replies, 1 voice, and was last updated 3 years, 10 months ago by admin. Viewing 1 post (of 1 total) Author Posts April 2, 2022 at 6:45 am #317 adminKeymaster This is the array that needs to be sorted in ascending order: Address Value a0 8 a1 7 a2 6 a3 2 a4 9 There will be three scenarios: Either a0 = a1 or a0 > a1 or a0 < a1 It appears there will be a swap from a0 to a1 as a0 > a1. One way to do swap I have earlier came across is: a0 = at at = a1 a1 = at Will the above process be applicable also here. Also, how to have at? Can a new address at be created initially holding say 0? Reply Yes it’s applicable. tmp = A[0]; A[0] = A[1]; A[1] = tmp; [learn_press_profile] Author Posts Viewing 1 post (of 1 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In