start end 0·0 start the process end the process input data and store output data typically the stored data examples: 3 3
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
start end 0·0 start the process end the process input data and store output data typically the stored data examples: 3 3
required:
flowchart
javascript
start end 0·0 start the process end the process input data and store output data typically the stored data examples: 3 3 input data & store it as m output m memory value
In this problem, we want to sort an input array. Problem 2A (easier) In this problem, develop an algorithm that, given an unsorted array of integers, creates a new array which is the sorted version of the given array. Here is the main idea of the algorithm: first scan through the original input array, finding the smallest element, and then insert this element into the beginning (index 0) of the new array, and remove this smallest element from the input array. Next, scan the (shortened) input array again, finding the smallest element, and then insert it into the next available position of the new array and remove it from the input array. Repeat the process until the original array becomes size 0 (this is also the time when the new array contains all the values in the original input array). • Develop flowchart for this algorithm o Give pre-condition and post-condition for your algorithm. Hint: you will need nested loops for doing the work in one main algorithm. You can also write a sub- program to do some work. In this case the main algorithm has one loop. o Hint: to find the smallest element in an array, define a variable, say, minIndex, which is initially 0, then if an element at index k of the array is smaller than the element at index minIndex, update minindex to be k. o For removing an element at index / from array arr, you can just say "remove element at index j from arr", or "remove arr[j] from arr" o Start your flowchart as shown in the following picture, which first get an input array arr, and then create new array new Arr. o Save the flowchart as img_sortA.jpg start 000 arr newArr