Wet NAT M3 My Comme le TO SITTEN Und Bann Aar I Pot mach In this problem, we want to sort an inpet array. Problem 24 (ea

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Wet NAT M3 My Comme le TO SITTEN Und Bann Aar I Pot mach In this problem, we want to sort an inpet array. Problem 24 (ea

Post by answerhappygod »

Wet Nat M3 My Comme Le To Sitten Und Bann Aar I Pot Mach In This Problem We Want To Sort An Inpet Array Problem 24 Ea 1
Wet Nat M3 My Comme Le To Sitten Und Bann Aar I Pot Mach In This Problem We Want To Sort An Inpet Array Problem 24 Ea 1 (33.53 KiB) Viewed 37 times
Wet Nat M3 My Comme Le To Sitten Und Bann Aar I Pot Mach In This Problem We Want To Sort An Inpet Array Problem 24 Ea 2
Wet Nat M3 My Comme Le To Sitten Und Bann Aar I Pot Mach In This Problem We Want To Sort An Inpet Array Problem 24 Ea 2 (47.9 KiB) Viewed 37 times
Wet Nat M3 My Comme Le To Sitten Und Bann Aar I Pot Mach In This Problem We Want To Sort An Inpet Array Problem 24 Ea 3
Wet Nat M3 My Comme Le To Sitten Und Bann Aar I Pot Mach In This Problem We Want To Sort An Inpet Array Problem 24 Ea 3 (47.9 KiB) Viewed 37 times
Wet Nat M3 My Comme Le To Sitten Und Bann Aar I Pot Mach In This Problem We Want To Sort An Inpet Array Problem 24 Ea 4
Wet Nat M3 My Comme Le To Sitten Und Bann Aar I Pot Mach In This Problem We Want To Sort An Inpet Array Problem 24 Ea 4 (25.12 KiB) Viewed 37 times
Wet NAT M3 My Comme le TO SITTEN Und Bann Aar I Pot mach In this problem, we want to sort an inpet array. Problem 24 (easier) In this problem, develop an algorithm that, given an unerted array of integers, creates a new array which is the sorted version of the gives ray Problem 2 Here is the main idea of the algorithm fint scan through the original input amay, finding the smallest element, and then insert this clement into the beginning (index 0) of the new array, and remove this smallest element from the impot amay Next, scan the (shortened) input amay again, finding the smallest element, and then insert it into the next available position of the new array and remove it from the isput amay. Repeat the process until the original array becomes size (this is aho the time when the new aray contains all the values in the original input arrays • Develop flowchart for this algorithm OVAL Cen Give pre-condition and pest-coadition for your algorithms at you will nood nested loops for doing the work in one mais algorithms. You can also write a sub program to do some work. Is this case the main algoritm has one loop His to find the liest element in an amay, define a variable, say, minder, which is initially then if an element at index of the array is smaller than the element at inden minder, update minder to b Ferming element at index/tvm array arr, you can just say "ove element at index j from aer, or "enerve aer from ar Stan your flowchart as shown in the fobowing picture, which lint get an input amayor, and then create new array nowder Save the flowchart inget p Cop T
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. o 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 j from array arr, you can just say "remove element at index j from arr", or "remove arr[j] from arr" Start your flowchart as shown in the following picture, which first get an input array arr, and then D create new array newArr. o Save the flowchart as img_sortA.jpg *DE start arri newArr 3
n thi WC -C u v to fin an e ex t nov "re our 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 function problem2A() { var p = document.getElementById("mydata"); var myArray = []; var arrayMax = 10; var limit= 100; for (var i = 0; i < arrayMax; i++) myArray.push(Math.floor(Math.random()*limit)); p.innerHTML = myArray; /* display input array */ var newArray=[]; /* you implementation here */
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply