1/2 - Programming Fundamentals

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

1/10

flashcard set

Earn XP

11 Terms

1
New cards

What is exception handling?

Writing code to anticipate possible errors and deal with them gracefully.

2
New cards

What is a subroutine?

A block of code with an identifiable, unique name within a program which breaks down a large problem.

3
New cards

Difference between procedure and a function.

Functions return a value.

4
New cards

What are advantages of suborutines?

  • Easier to debug

  • Creates reusable methods

  • Can be grouped in libraries for easy reuse across programs


5
New cards

What is a stack frame?

A frame containing information about a subroutine.

6
New cards

What is included within a stack frame?

Return address, local variables, subroutine parameters

7
New cards

What is stack overflow/underflow?

Overflow: Trying to push a stack onto a frame with no space nor memory left.

Underflow: Trying to pop off a stack from an empty frame.

8
New cards

Why do local variables in functions lose their values?

They are destroyed with the stack.

9
New cards

What is recursion?

When a subroutine calls itself from within its own subroutine.

10
New cards

Characteristics of recursion (3)

  • Contains a stopping condition (base case)

  • For other inputs, the program should call itself

  • Base case must be reachable within a finite number of loops


11
New cards

Why is recursion rarely used?

Consumes more memory in comparison to iterative approaches.

  • The processor has to recall all the return addresses.