Programming techniques (excluding OOP)

0.0(0)
Studied by 4 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/21

flashcard set

Earn XP

Description and Tags

Made from P.M.T and Ada Comp. Sci. notes

Last updated 1:37 PM on 3/4/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

22 Terms

1
New cards

Are for loops in pseudo code inclusive (e.g. for val = 0 to 5… will the code within loop execute when val=5)?

Yes, for loops are inclusive

2
New cards

What columns would a trace table have tracing a recursive algorithm?

  • Function call

  • Any parameters the recursive function has

  • return

3
New cards

What is the DIV operation? Give an example

Integer division. For example 40 DIV 12 = 3 (26÷12= 3 remainder 4)

4
New cards

What is the MOD operation? Give an example

Modulo; the remainder of a division. For example, 40 MOD 12 = 4 (26÷12= 3 remainder 4)

5
New cards

What are the 3 programming constructs?

  • Sequence

  • Selection (aka branching)

  • Iteration

6
New cards

What is the sequence programming structure also known as?

Branching

7
New cards

What is the sequence programming construct?

When code is executed line-by-line, from top to bottom

8
New cards

What is the selection programming construct?

A certain block of code is only run if a specific condition is met

9
New cards

What is the iteration programming construct?

Repeatedly executing the same block of code a number of times or while a condition is met

10
New cards

What is the difference between branching and iteration?

  • Branching decides which code is run

  • Iteration repeatedly runs the same code in the same sequence

11
New cards

What are the two types of iteration?

  • Count controlled / definite iteration

  • Condition controlled / indefinite iteration

12
New cards

Describe count-controlled iteration

  • Code is repeated a specific number of times

  • It is definite iteration

13
New cards

What loops use count controlled iteration?

For loops

14
New cards

Describe condition-controlled iteration

  • The block of code is repeatedly run until a condition is met.

  • The number of repetitions is not fixed - it is indefinite iteration

15
New cards

What types of loops use condition controlled iteration?

While, do while & repeat until loops

16
New cards

Define recursion

A programming construct in which a subroutine calls itself during its execution

17
New cards

What are the key features of a recursive algorithm?

  • The function calls itself

  • There is a base case / condition that stops the recursive calls

  • Each recursive call will create a new copy of the values in the function and add all of the values of the copy the call is being made from to a stack 

  • There may be more than one base case

18
New cards

Advantages of recursion

  • Can represent certain problems with fewer lines of code, meaning that the function is:

    • Easier to read

    • Less prone to errors

  • Natural way to process certain data structures (such as trees) that are recursive by nature

19
New cards

Disadvantage of recursion

  • Harder to trace which makes debugging more difficult

  • Uses more memory because of the need to store multiple stack frames. If the call stack runs out of memory, there will be a stack overflow, and the program will crash.

  • Can be slower because of the need to manage stack operations.

20
New cards

What does passing a parameter by value mean?

  • The subroutine receives a copy of the variable

  • Changes are made to the copy

  • Changes don’t overwrite the original value

  • The copy is deleted/no longer available when the function ends

21
New cards

What does passing a parameter by reference mean?

The address of the parameter is given to the subroutine

Changes value of the parameter will be updated at the given address.

22
New cards

Are parameter(s) passed by value or by reference in recursive subroutines, and why?

  • If the parameter is sent by value, it will be a copy of the parameter that is used so the parameter wont be overridden. This will produce the correct output.

  • If the parameter is passed by reference it would not produce the correct result as it would be overridden / because it is a pointer to the address of the variable.

Explore top flashcards

flashcards
English 1111-Sadlier Unit IIII
20
Updated 1242d ago
0.0(0)
flashcards
APHUG Unit 6 & 7 Vocab
50
Updated 1066d ago
0.0(0)
flashcards
PSYC 14
64
Updated 188d ago
0.0(0)
flashcards
Kafli 9 - Choice and Preference
43
Updated 120d ago
0.0(0)
flashcards
Fifty common Russian verbs
51
Updated 435d ago
0.0(0)
flashcards
Unit 3 vocab
20
Updated 1206d ago
0.0(0)
flashcards
PA Drivers Permit Flashcards
166
Updated 1056d ago
0.0(0)
flashcards
Unit 1A
61
Updated 1160d ago
0.0(0)
flashcards
English 1111-Sadlier Unit IIII
20
Updated 1242d ago
0.0(0)
flashcards
APHUG Unit 6 & 7 Vocab
50
Updated 1066d ago
0.0(0)
flashcards
PSYC 14
64
Updated 188d ago
0.0(0)
flashcards
Kafli 9 - Choice and Preference
43
Updated 120d ago
0.0(0)
flashcards
Fifty common Russian verbs
51
Updated 435d ago
0.0(0)
flashcards
Unit 3 vocab
20
Updated 1206d ago
0.0(0)
flashcards
PA Drivers Permit Flashcards
166
Updated 1056d ago
0.0(0)
flashcards
Unit 1A
61
Updated 1160d ago
0.0(0)