Computational Thinking, Problem-solving and Programming 2
Computational Thinking, Problem-solving and Programming 2
programming 2
Thinking abstractly
Abstraction:oop,collection
Each value in an array is called an element, and each element is accessed by its index - a
numeric value that represents its position in the array.
A = new Array()
loop i from 0 to 4
A[i] = i + 1
end loop
loop i from 0 to 4
print(A[i])
end loop
A = [1, 2, 3, 4, 5]
print(A[i])
end loop
size = 5
A = new Array(size)
A[i] = i + 1
end loop
print(A[i])
end loop
Collection
a collection is a data structure that groups multiple elements into a single unit. Collections are used to store,
retrieve, manipulate, and communicate aggregate data. They are fundamental to many programming tasks, as they
provide a way to manage and organize data efficiently.
A collection is a general term for a group of objects. It can be any type of data structure that holds multiple elements,
like a list, set, or queue.
Collection methods in Pseudocode are:
•addItem( new data item )
•resetNext( ) start at beginning of list
•hasNext( ) checks whether there are still more items in the list
•getNext( ) retrieve the next item in the list
•isEmpty( )check whether the list is empty