0% found this document useful (0 votes)
0 views

Computational Thinking, Problem-solving and Programming 2

The document discusses computational thinking, problem-solving, and programming concepts, focusing on abstraction and object-oriented programming. It explains arrays as a data structure for storing multiple values of the same type, detailing their creation and manipulation through loops. Additionally, it introduces collections as a way to group multiple elements for efficient data management, along with common methods used in pseudocode.

Uploaded by

biji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Computational Thinking, Problem-solving and Programming 2

The document discusses computational thinking, problem-solving, and programming concepts, focusing on abstraction and object-oriented programming. It explains arrays as a data structure for storing multiple values of the same type, detailing their creation and manipulation through loops. Additionally, it introduces collections as a way to group multiple elements for efficient data management, along with common methods used in pseudocode.

Uploaded by

biji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 46

Computational thinking, problem-solving and

programming 2
Thinking abstractly
Abstraction:oop,collection

Object oriented programming


Object manipulation:set and getmethods
Code example for selection statements
Code examples for repetition statements
Arrays
An array is a data structure that allows you to store multiple values of the same data type in a
single variable.

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.

An array is an ordered, static set of elements

Can only store 1 data type

A 1D array is a linear array


● An array is an ordered, static set of elements
● Can only store 1 data type
● A 1D array is a linear array
Arrays
Creation

arrayname=new Array() //empty array

A = new Array(size)//array with size

A = [value1, value2, value3, ..., valueN]//with values

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]

loop i from 0 to length(A) - 1

print(A[i])

end loop

size = 5

A = new Array(size)

loop i from 0 to size-1

A[i] = i + 1

end loop

loop i from 0 to size-1

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

You might also like