Save
فريدة
برمجة
Save
Share
Learn
Content
Leaderboard
Learn
Created by
فريدة الكثيري
Visit profile
Cards (19)
Recursive
function
A
function
that calls
itself
Recursive
function
1. Determine the
size
factor
2. Determine the
base
case(s)
3. Determine the
general
case(s)
4.
Verify
the algorithm
Base case
The one for which you know the answer
General case
The one where the problem is expressed as a
smaller
version of itself
Three-Question Verification Method
1. The
Base-Case
Question
2. The
Smaller-Caller
Question
3. The
General-Case
Question
When
a function is called, an activation record is stored into a stack (
run-time stack
)
When
a recursive function is called, there is really
no difference
between recursive and nonrecursive calls
Structure
A data
structure
used to process data of
multiple
data types
Structure
example
Student
Record
Name
(a string)
HW Grades
(an array of 3 doubles)
Test Grades
(an array of 2 doubles)
Final Average
(a double)
Structure
member
Each thing in a
structure
Structure members have a name, a
type
and a
value
Names of
structure
members follow the rules for variable
names
Types
of
structure members
can be any defined type
Using
a struct
By defining a structure you create a
new data type
Accessing
members
You can treat the members of a struct just like
variables
, using the member
access
operator '.'
Structure assignment
You can use structures just like variables, copying the entire
structure
If a member is a pointer,
copying
means
copying
the pointer (not what is pointed to)
Pointers
to
structures
There is another member access operator used with pointers: '->'
Sample
Function
void update_average(StudentRecord *stu)
Calculate
total
of hw and test grades
Set the
average