Professional Documents
Culture Documents
PSUDOCODE
PSUDOCODE
PSUDOCODE
Is a search that go through all the arrays items (one by one), until it
reaches the required element.
1. Have your array.
2. Have your flag/found.
3. Make a loop.
4. Make if condition to search for the required element.
5. End your If condition and then your loop.
Y = {1 , 2 , 3 , 4 , 5} // this is the array
INPUT X
Found = false // this is the flag/found
i=0
LOOP I FROM 0 TO 4 // the loop
IF (Y[i] == X) // to check each item in the array.
THEN
Found = true // if the element is found
PRINT X, “Found at :”, I // the element will be printed and its
index/position
ENDIF
ENDLOOP
IF (Found ==false) // if the element is still not found
THEN
PRINT X, “Not Found” // it will print out that the element is Not
Found
OCCURRENCE:
NUMBERS = {76,89,22,42,13,100,99,14,30}
LOOP i from 0 to N-1
LOOP J FROM 0 to N-1
X=1
IF (NUMBERS[i] == NUMBERS[J+1]
X = X +1
Frequency[i] = X
ELSE
Frequency[i] = X
ENDIF
ENDLOOP
ENDLOOP
Collection:
.addItem( data ) = add data item to the collection
.resetNext() = start at the beginning
.hasNext() → tells whether there is another item in the list
.getNext() → retrieves a data item from the collection
.isEmpty() → check whether collection is empty
Given a collection of data, write a pseudo code to copy the positive elements of the collection to
an array. Data.resetNext()
Data.resetNext()
I=0
Loop while Data.hasNext() // to check if there are any more items
DataTemp = Data.getNext() // to get the next item
IF DataTemp > 0
THEN
ARRAY1[i] = DataTemp
ENDIF
ENDLOOP
Loop i form 1 to Array1.length() 1
PRINT Data[i]
ENDLOOP
- Sub procedure
o Advantages
o Disadvantages
o Use the worksheet from GCR
o GO TO COMPUTER HUB
- Sub program
o Same as sub procedure
o Use worksheet in GCR
- Given flow chart and determine the output
- Tracing table
- Drawing Gantt chart
o Drawing
o Use of Gantt chart
o You will write the scenario
o THINKIN AHEAD ON GCR
- Construct a pseudocode
o Loops
o Combinations
o Max and min and avg
o Occurrence