progweek3 Flashcards
looping
the repetition of the same procees multiple
times until a specific condition is satisfied, then it will stop.
Actually, looping can simplify complex problems into simple ones.
while loops, does or does not depend upon the number of iterations?
does not
Recursion is
a programming technique in which a function calls itself.
In recursion, there is a _ that is (are) tested for
_.
base case (or cases)
upon entry to the function
In recursion, there is a _ step (or steps) in which one of the variables is
_ in a way that will lead to the base case.
recursive
passed as an argument
The structure type allows us to :
aggregate variables of different types.
A header file is
a file with extension .h which contains C function
declarations and macro definitions to be shared between several source
files.
here are two types of header files:
files that the programmer writes, and
files that comes with your compiler.
In the C language, structures can be _ to functions
and can be _.
You can pass to a self-defined function:
passed as arguments
returned from them
individual members,
an entire structure,
or a pointer to the structure.
Abstraction is
a key mechanism that helps to solve problems in general
and to write cleaner, safer, and simpler programs.
Computer systems are essentially :
stratifications of layers of abstraction
The logic gates in our physical machine take _.
continuous signals and
produce a system which works in binary.
The operating systems creates _.
an abstraction of the physical
machine (e.g., providing an abstract version of the memory of the
system, of each device, etc.).
Modularization:
When we have a medium/big problem we want to decompose it in
subproblems and use di↵erent modules to solve each subproblem.
These modules then cooperate to solve the original problem.
There are essentially two ways to abstract in our programs (independently
on the language we use):
parametrization
specification(API)
Parametrisation:
We abstract from some of the data using parameters. E.g., we can define a function bigger(int x, int y) which
works with any integers instead of rewriting the code for each single
pair. This is usually supported by programming languages.
Specification (API):
We abstract from the implementation. We
separate declaration and implementation. E.g., when we plan our project we only think about the external behavior of each data type
and function. This is usually not supported by the language itself and
is dealt with informally (essentially done via comments).
procedural abstraction:
We split the problem into subproblems that are solved in separate functions.
We use parameters to make functions solve many problems at the same time (make functions less specific).
We use specification to separate implementation and declaration. When we use a function we do not have access to the implementation but just to its specification (what it does but not how it does it).
If we apply abstraction via API to data types we obtain the notion of
_.
Abstract Data Type (ADT).
A data type is:
A collection of objects, e.g.,{. . . , 1, 0, 1, 2, . . .} for int.
A collection of operations, e.g.,+, *,- , / etc. for int.
We abstract from the implementation of the data type. So, an abstractdata type consists of:
the specification of the abstract values in the type and some of
their properties.
the specification of the operations that allow to create, modify and
use these values.
A dynamic length stack (dls) of integers is :
a stack whose size can
change dynamically during the execution of the program. The size
changes automatically when elements are added or removed from the stack.
dlsInit:
Initializes a new empty dls.
push:
Inserts an element into a given dls.
pop:
remove the last element that was added to the dls and returns
its value.
freeDLS:
Frees all the space used by the given dls.
specification of the operations:
dlsInit
push
pop
freeDLS
self-referential structure is
a structure that contains a pointer member to a variable of the same type.
linked list:
It is a set of dynamically allocated nodes. Each node contains one value
and one pointer. The pointer always points to the next member of the list.
A local pointer variable is
used to held the list. It points to the first
element of the the list. If that pointer is NULL, then the list is considered
to be empty.
Array / Linked list
stored in a contiguous location/ not stored in a contiguous location
fixed in size/ dynamic in size
memory allocated at compile time / memory allocated at run time
elements may be accessed easily / element accessing may require traversal of the whole list