Having trouble reading this simple pseudo code to insert into a function. The topic of this code is inserting into an array based list.
Insertion
Given-the element to insert and the index to insert at
Returns- boolean to indicate success/failure
(Validate the index number. Validate between 0 and count)
If index < 0 or index > count
Print/raise "invalid index" error
Return false
End if
(Check if list has space)
If count is equal to max size/capacity
Print/raise "list full" error
Return false
End if
(Shift the elements up by one to make room for inserted element)
For i = count to i > index, i--
array[i] = array[i-1]
End for
(Set the element and update count)
array[index] = element
increment count
Return true
What specifically is confusing you?
Pseudo code in general, I have never been good at reading it into code.
You've never followed cookbook instructions before? You've never even seen step-by-step instructions before? I find that a bit hard to believe.
Start with the first thing you are unable to accomplish. Say what it is. I'll explain it. "pseudo code" is not the first thing, it's all the things.