Pseudocode of an Array and List

Pseudocode is a way of writing our codes in plain English for ease of understanding. Pseudocode integrates and shows the step by step process of writing a program. An array is a data structure containing series of values or items. The items must be of the same data type. The data type may be strings, float, integers, Booleans etc.. A list is also a data structure containing series of elements, values, or items; However, a list may (not) be of the same data type. A list may contain strings, float, integers, and Booleans.

To perform operation on an array, you have to import the array depending on the language you are using. In this discussion, I am using python and the example is shown below:

Import array as arr

a = arr.array (‘str’, [“mango”, “orange”, ‘pineapple’, ‘apple’])

As you can see, the array is of the string (‘str’) data type and the index start from zero. The first element is of zero index and this is mango.

You don’t have to import while performing operation on a list since the operation may contain different data types. An example is shown below:

a = [‘mango’, 1, ‘orange, 2, ‘apple’, 100]

This example shows the string and integer data type and the index start from zero. Both array and list have two things in common: index starts from zero and they both use square [] brackets.

An example of a list in plain pseudocode is this:
Student inputs/lists numbers from 1 to 5
Set the index of the first number to zero #note that index in array (list) starts from zero (0)
While the total numbers of the indexes is equal to 4:
Print each number
End While

In python, this is the code:

numbers = int ( input (‘list number from 1 to 5’ ‘))

for numbers in [ _, _, _, _, _ ]: or
for numbers in range (5):

#the _ represents the inputted numbers.

print (numbers)

Next, I will provide an example of array in plain pseudocode

Student inputs the days in a week

Student declares and creates an int array with the days in a week

For each index in the array:          #note that index in array starts from zero (0)

 Student inputs the number of school hours each day of the week

Student reports the hours in each index of the array

Student initializes the sum of the hours to zero

For each index in the array:

            Add the value at that index to the previous day hours

Calculate and print the sum

End for

End Program

1 thought on “Pseudocode of an Array and List”

  1. I’m extremely impressed together with your writing abilities as neatly
    as with the structure for your weblog. Is that this a paid subject or did you
    customize it yourself? Anyway stay up the excellent quality writing, it’s rare to look a nice blog like this one nowadays..

Leave a Comment

Your email address will not be published. Required fields are marked *