2.2 Problem Solving and Programming

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall with Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/13

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No study sessions yet.

14 Terms

1
New cards

Sequence

Code is executed line by line from top to bottom

2
New cards

Branching (selection)

A block of code is run if a condition is met (IF statements)

3
New cards

Iteration

A block of code is repeatedly ran for a certain number of times or until a condition is met (FOR/WHILE loops)

4
New cards

Recursion

When a function calls itself during its execution until a stopping condition is met

5
New cards

Advantages of recursion

  • Less lines of code = less likely to have errors

  • Good for divide and conquer problems

6
New cards

Disadvantages of recursion

  • Uses more memory than iteration

  • If not a stopping condition stack overflows may occur

  • Harder to understand for developers

7
New cards

Advantages of iteration

  • More efficient in time and memory than recursion

  • No risk of stack overflows

  • Easier to understand for developers

8
New cards

Disadvantages of iteration

  • Some algorithms are harder to write iteratively (divide and conquer and tree traversal)

  • Code can come overly complex for longer algorithms

9
New cards

Local variable

Variable that is declared in a function/procedure and can only be accessed in that function

10
New cards

Global variable

Variable that is declared outside any function and can be accessed anywhere in the program

11
New cards

Benefits of using procedures and functions

  • Less memory used

  • Can be reused multiple times

  • Makes programming more manageable splitting it into sections

12
New cards

Difference between function and procedure

A function returns a value whereas a procedure doesn’t

13
New cards

How are parameters used into a subroutine

  1. Passed by value - treated like a local variable and discarded at the end

  2. Passed by reference - address of the parameter is given, the value can be updated

14
New cards

IDE

Integrated development environment - software that allows programmers to write, test and debug code