Com2 (till test 2)(Ignore for final)) Flashcards

1
Q

What is a self-referential struct?

A

Contains a pointer member that points to a structure of the same structure type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Syntax for assigning array/pointer with malloc.

A

newPtr = malloc(sizeof(what it is pointing to))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Library for exit function.

A

include <stdlib.h></stdlib.h>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the two symbolic constants for the exit function?

A

EXIT_SUCCESS
EXIT_FAILURE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the library for signals?

A

<signal.h>
</signal.h>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What two arguments does the signal function receive? How are singals raised?

A

A function, and a symbolic constant that will call the function when triggered.

Using the raise function with a symbolic constant as parameter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Labels and goto syntax?

A

labelname:

goto labelname;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How can CTRL Z be simulated with raise function?

A

raise(SIGINT);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What do labels do when the compiler reads them?

A

Nothing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Bubble sort syntax. (Lecturer’s way)

A

for(unsigned int pass = 1; pass < SIZE; ++pass){

for(size_t i = 0; i < SIZE - 1; ++i){

if (a[i] > a[i + 1]){
int hold = a[i];
a[i] = a[i + 1];
a[i + 1] = hold;
}

}

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Binary search syntax.

A

while (low <= high) {
size_t middle = (low + high) \ 2;

if (target == b[middle]){
return middle;
}

else if (target < b[middle]){
high = middle - 1;
}

else {
low = middle + 1;
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Library for malloc, realloc and calloc?

A

include <stdlib.h></stdlib.h>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly