1/13
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
How do you find the maximum value in an array?
Max ← Array[1]
FOR i ← 2 TO LENGTH(Array)
IF Array[i] > Max THEN
Max ← Array[i]
ENDIF
NEXT i
What is a CASE structure used for?
CASE Grade OF
"A": OUTPUT "Excellent"
"B": OUTPUT "Good"
"C": OUTPUT "Average"
OTHERWISE: OUTPUT "Fail"
ENDCASE
What is a typical trace table used for?
To track variable values and outputs during each step or loop iteration of a program.
How do you push to a stack if there's space?
IF Top = MaxSize THEN
RETURN FALSE
ENDIF
Top ← Top + 1
Stack[Top] ← Value
RETURN TRUE
How do you loop through each element in a 2D array?
FOR i ← 1 TO Rows
FOR j ← 1 TO Columns
OUTPUT Array[i][j]
NEXT j
NEXT i
How do you return TRUE if a string starts with a specific letter?
IF SUBSTRING(Name, 1, 1) = "A" THEN
RETURN TRUE
ELSE
RETURN FALSE
ENDIF
How do you handle unexpected input in a function?
IF NOT IS_NUM(Input) THEN
RETURN -1
ELSE
RETURN STR_TO_NUM(Input)
ENDIF
How do you compare characters in the same positions of two strings?
MatchCount ← 0
FOR i ← 1 TO LENGTH(String1)
IF String1[i] = String2[i] THEN
MatchCount ← MatchCount + 1
ENDIF
NEXT i
How do you read data from a file into two parallel arrays?
Index ← 1
OPENFILE(FileIn, "data.txt", READ)
WHILE NOT EOF(FileIn)
READFILE(FileIn, Array1[Index])
READFILE(FileIn, Array2[Index])
Index ← Index + 1
ENDWHILE
CLOSEFILE(FileIn)
How do you search for a record with a matching ID in an array?
FOR i ← 1 TO LENGTH(Records)
IF Records[i].ID = SearchID THEN
RETURN Records[i]
ENDIF
NEXT i
RETURN NULL
What logic checks if all characters in a string are uppercase?
FOR i ← 1 TO LENGTH(Text)
IF TO_UPPER(Text[i]) ≠ Text[i] THEN
RETURN FALSE
ENDIF
NEXT i
RETURN TRUE
How do you initialise all elements in a 2D array to zero?
FOR i ← 1 TO Rows
FOR j ← 1 TO Columns
Matrix[i][j] ← 0
NEXT j
NEXT i
How do you reverse a string manually using a loop?
Reversed ← ""
FOR i ← LENGTH(Text) DOWNTO 1
Reversed ← Reversed & Text[i]
NEXT i
What is the difference between a procedure and a function in pseudocode
A FUNCTION returns a value to the calling program using RETURN.
- A PROCEDURE performs actions but does not return a value.