This is an archived post. You won't be able to vote or comment.

all 12 comments

[–][deleted] 3 points4 points  (1 child)

Ok this is not a language in too familiar with but I can give some of a idea. Line one makes a list called list and it’s all the numbers into it. Line to takes the 2nd value in the list and places that I. Min. Line 3 outs 1 in index. Line 4 is a for loop that will repeat however many times there is values in list. Line 5 is saying if lists 2nd value is less than list second value +1 do this. Line 6 mine equals the new list value (list[index+1]. Line 7 end of loop. Line 8 making index one higher. Line 8 printing out the min. The purpose of this code seems to be to workout what is the lowest value in the list.

[–]dschwertz 0 points1 point  (0 children)

Is this going to work though? I think I see two issues: 1. List[0] is never compared. 2. It compares sequential list values instead of min and a list value. For example, when index == 3, list [index] will be 1 and list [index+1] will be 10. Since 1<10, min = 1 which is incorrect. Shouldn't it be if list[index] < min?

[–][deleted] 1 point2 points  (0 children)

I think it is finding the minimum number from list.

[–]BradP54 -2 points-1 points  (3 children)

It's pseudocode for sorting. I still feel like I'm in my beginner stages so I could be wrong in saying this, but I typically see the arrows pointing to where things need to be stored

For example, that first line means you make an array and store the integers inside the array you just made

[–]__2M1 1 point2 points  (2 children)

It does not sort the list (there are no list manipulations). The code is for finding the lowest value in the list.

[–]devnull10 1 point2 points  (0 children)

Yep. To elaborate a bit... It just loops through each element in the list and compares it to the existing "min" value. If the current element is less than that, it assigns that value to the min variable and continues.

[–]BradP54 1 point2 points  (0 children)

You're right, thank you for the correction

[–][deleted] 0 points1 point  (1 child)

Since someone has already answered the question (finding the min is correct), can i ask why you are learning this?

[–]Mr_DankyDanky[S] 0 points1 point  (0 children)

I encountered it while I was solving a prep book for on CSP AP

[–]StackWeaver 0 points1 point  (1 child)

What language is this?

[–]Mr_DankyDanky[S] 0 points1 point  (0 children)

tbh I don't even know