CS 159 Final Studying

5.0(1)
studied byStudied by 38 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/511

flashcard set

Earn XP

Description and Tags

Covers entire course content based on labs and lecture quizzes. Good luck

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

512 Terms

1
New cards

Arrays can be passed in two ways; by individual elements or the whole array

True

2
New cards

Elements of an array, themselves individual values of a given data type, are passed by value from calling to the called function

True

3
New cards

The called function cannot identify whether the value it receives comes from an array, an individual variable, or an expression that evaluates to the expected type

True

4
New cards

Individual elements of an array can be passed by address through the use of the address operator

True

5
New cards

The reason that the C language does not pass whole arrays by value is the extra stress it would put on the memory of the computer to make a copy of an array

True

6
New cards

The name of an array is a primary expression whose value is the address of the first element in the array

True

7
New cards

Indexed references to individual elements of an array are simply calculated addresses where the index value is added to the address represented by the name of the array

True

8
New cards

Passing the array name to a function allows changes in the called function to be available back in the calling function after it terminates

True

9
New cards

When passing a whole array to the function the total size of the array is necessary in the function call

False

10
New cards

When passing a whole array to the function the total size of the array is necessary in the definition of the called function

False

11
New cards

It is a course standard to make use of a symbolic/defined constant to represent the size of a statically declared array

True

12
New cards

The conversion code to use for input or output of an array element depends on the data type of the array

True

13
New cards

Variables and loops are commonly used together to generate index values to access the elements of an array

True

14
New cards

Arrays in the C programming language use a one-based index

False

15
New cards

To pass the whole array to a function you need to use the name of the array followed by empty square braces [] in the function call statement

False

16
New cards

All elements of one array can be assigned to another through the use of the assignment operator and the name of each array (example: x = y)

False

17
New cards

If more than one element of an array are passed to a function in a single function call then those elements are passed by address

False

18
New cards

Using the name of an array in the data list of a single printf function will result in the output of all elements of the array

False

19
New cards

All arrays sent to a given user-defined function must be of the same defined size

False

20
New cards

To conserve memory the sorting of data is completed within the array rather than creating a second array

True

21
New cards

Several sort passes will be necessary to sort most data sets

True

22
New cards

From an efficiency point of view, it makes no difference whether the data is ultimately sorted largest to smallest or smallest to largest in an array

True

23
New cards

The bubble sort operates faster when moving the larger values to the highest index than when moving the smaller values towards index zero

False

24
New cards

The number of exchanges that can potentially occur on a given pass of the bubble sort may be greater than 1

True

25
New cards

To sort an array of N elements a N - 1 sort passes are required to guarantee that data always ends in a sorted state

True

26
New cards

The outer loop in each of the bubble sorting algorithm is responsible for ensuring the number of passes required are completed

True

27
New cards
<p>Which is the largest value in the array after the loop?</p><p>A) 8</p><p>B) 11</p><p>C) 7</p><p>D) 12</p><p>E) None of the above</p>

Which is the largest value in the array after the loop?

A) 8

B) 11

C) 7

D) 12

E) None of the above

B

28
New cards
<p>What is the output?</p><p>A) x[3] = 2</p><p>B) x[3] = 1</p><p>C) x[3] = 0</p><p>D) x[3] = -1</p><p>E) None of the above</p>

What is the output?

A) x[3] = 2

B) x[3] = 1

C) x[3] = 0

D) x[3] = -1

E) None of the above

C

29
New cards
<p>What is the output?<br>A) x[6] = 6</p><p>B) x[6] = 8</p><p>C) x[6] = 4</p><p>D) x[6] = 7</p><p>E) None of the above</p>

What is the output?
A) x[6] = 6

B) x[6] = 8

C) x[6] = 4

D) x[6] = 7

E) None of the above

B

30
New cards

Using the name of an array in the data list of a single printf will result in the output of all elements of the array

False

31
New cards

It is a course standard to make use of a symbolic/defined constant to represent the size of a statically declared array

True

32
New cards
<p>What is the value found at index 4 in the array after the code segment has been executed?</p><p>A) 7</p><p>B) 0</p><p>C) 9</p><p>D) -1</p><p>E) None of the other values provided are correct</p>

What is the value found at index 4 in the array after the code segment has been executed?

A) 7

B) 0

C) 9

D) -1

E) None of the other values provided are correct

E

33
New cards
<p>What is the value found at index 4 in the array after the code segment below has been executed?<br>A) 11</p><p>B) 0</p><p>C) 22</p><p>D) 10</p><p>E) None of the other values provided are correct</p>

What is the value found at index 4 in the array after the code segment below has been executed?
A) 11

B) 0

C) 22

D) 10

E) None of the other values provided are correct

A

34
New cards

The name of an array is a primary expression whose value is the address that stores the size of the array

False

35
New cards

Passing the array name to a function allows changes in the called function to be available back in the calling function after it terminates

True

36
New cards

All elements of a given array will make use of the same conversion code for the purpose of input or output

True

37
New cards

Which of the following values has the longest “streak” as defined in the programming problems for both lab 10 and lab 11?

A) 19

B) 23

C) 25

D) 17

C

38
New cards

When passing a whole array to the function the total size of the array is not used in the function call

True

39
New cards

Elements of an array, themselves individual values of a given data type, are passed by value from calling to called function

True

40
New cards

The value of a pointer variable can change during the execution of a program

True

41
New cards

The proper initialization of a pointer variable will include an address on the right side of the assignment operator with the pointer variable on the left

True

42
New cards

Working with an uninitialized pointer variable is a logical error

True

43
New cards

When we need to send more than one value back from a function, we use pointers

True

44
New cards

A user-defined function may be declared to return a pointer value

True

45
New cards

The name of an array is a pointer constant to its first element

True

46
New cards

The name of an integer array can be assigned to an integer pointer variable

True

47
New cards

When a whole array is passed to a function the called function can declare the array using the traditional indexing notation {} or as a simple pointer variable

True

48
New cards

The C programming language provides two options for requesting memory, static allocation and dynamic allocation

True

49
New cards

Static memory allocation requires that the declaration and definition of the memory be fully specified in the source program

True

50
New cards

Dynamic memory allocation uses predefined functions to allocate memory for data while the program is running

True

51
New cards

All of the memory management functions are found in the standard library (stdlib.h)

True

52
New cards

The malloc function allocates a block of memory that contains the number of bytes specified in its parameter

True

53
New cards

The memory allocated as a result of the malloc function is not initialized and we should assume that it will contain unknown values

False

54
New cards

If we need to know the size of any data type the sizeof operator will give us the exact size in bytes

True

55
New cards

The malloc function returns the starting address of the memory allocated

True

56
New cards

The result of the malloc function is assigned to a pointer variable

True

57
New cards

A pointer is a variable that stores a memory address as its value

True

58
New cards

The value stored by a pointer variable may be the location of another variable in the program

True

59
New cards

The data stored in the location to which a pointer is referring can be accessed and manipulated by the pointer

True

60
New cards

An asterisk character (*) is used in the declaration of a pointer variable. This asterisk can be attached to either the data type or the name of the variable (int *x or int* x)

True

61
New cards

A pointer that has been declared on the first line of a function definition will receive its initial value from the calling function

True

62
New cards

Another use of the asterisk character (*) is as the indirection operator

True

63
New cards

The indirection operator will access the value stored at the location to which the pointer references

True

64
New cards
<p>What is the output?<br>A) a = 3</p><p>B) a = 5</p><p>C) a = 10</p><p>D) a = 11</p><p>E) None of the above</p>

What is the output?
A) a = 3

B) a = 5

C) a = 10

D) a = 11

E) None of the above

D

65
New cards

What is the output?
A) *y = 1

B) *y = 2

C) *y = 5

D) *y = 10

E) None of the above

B

66
New cards
<p>What is the output?<br>A) result = 6</p><p>B) result = 5</p><p>C) result = 4</p><p>D) result = 3</p><p>E) None of the above</p>

What is the output?
A) result = 6

B) result = 5

C) result = 4

D) result = 3

E) None of the above

C

67
New cards
<p>What is the output? (Assume successful malloc)<br>A) a[4] = 0.00</p><p>B) a[4] = 0.80</p><p>C) a[4] = 1.00</p><p>D) a[4] = 1.25</p><p>E) None of the above</p>

What is the output? (Assume successful malloc)
A) a[4] = 0.00

B) a[4] = 0.80

C) a[4] = 1.00

D) a[4] = 1.25

E) None of the above

B

68
New cards
<p>Which of the following is the output generated by the code segment above?<br>A) Value: 4</p><p>B) Value: 3</p><p>C) Value: 5</p><p>D) None of the above</p>

Which of the following is the output generated by the code segment above?
A) Value: 4

B) Value: 3

C) Value: 5

D) None of the above

C

69
New cards

The memory allocated as a result of the malloc function is not initialized and we should assume that it will contain unknown values

True

70
New cards

The result of the malloc function is assigned to an array variable

False

71
New cards

Static memory allocation uses predefined functions to allocate memory for data while the program is running

False

72
New cards

If we need to know the size of any data type the sizeof operator will give us the exact size in bytes

True

73
New cards

A pointer that has been declared on the first line of a function definition will receive its initial value from the calling function

True

74
New cards

The proper initialization of a pointer variable will include the pointer variable on the right side of the assignment operator with an address on the left

False

75
New cards

The following declaration of a user-defined function may receive a whole integer array as a parameter: void someFx(int *);

True

76
New cards

The malloc function allocates a block of memory that contains the number of bytes specified in its parameter

True

77
New cards

The indirection operator is used to alter the location to which a pointer refers

False

78
New cards

To conserve memory the sorting of data is completed within the array rather than creating a second array

True

79
New cards

Both the sorted and unsorted lists exist within the same array as the process of sorting data continues

True

80
New cards

The goal of each sorting algorithm is to move data from the unsorted list to the sorted list of an array

True

81
New cards

A sort pass is the process of moving an element from the unsorted list to the sorted list

True

82
New cards

Several sort passes will be necessary to sort most data sets

True

83
New cards

From an efficiency point of view, it makes no difference whether the data is ultimately sorted largest to smallest or smallest to largest in an array

True

84
New cards

The selection sort will identify one value in the unsorted sublist to move and become a part of the sorted sublist

True

85
New cards

The bubble sort operates faster when moving the larger values to the highest index than when moving the smaller values towards index zero

False

86
New cards

The number of exchanges that can potentially occur on a given pass of the bubble sort may be greater than 1

True

87
New cards

The insertion sort takes a value from the unsorted sublist and inserts it into the proper location of the sorted sublist based on the values currently present in the sorted sublist

True

88
New cards

To sort an array of N elements N -1 sort passes are required to guarantee that data always ends in a sorted state

True

89
New cards

The outer loop in each of the three sorting algorithms is responsible for ensuring the number of passes required are completed

True

90
New cards

The selection sorting algorithm will complete one exchange involving at most two elements per pass

True

91
New cards

The bubble sorting algorithm will complete one exchange involving at most two elements per pass

False

92
New cards

The insertion sorting algorithm will complete one exchange involving at most two elements per pass

False

93
New cards

The selection sorting algorithm can only be used to sort data in an ascending order (from smallest to largest)

False

94
New cards

On the final pass through the selection sorting algorithm TWO values are brought over from the unsorted list into the sorted list

True

95
New cards

It is possible that during a single pass of the selection sorting algorithm that the order of the data in the array will be the same as it was after the previous pass

True

96
New cards

The bubble sorting algorithm compares neighboring elements in the unsorted list of the array and swaps their positions when they are not in the desired order

True

97
New cards

The bubble sorting algorithm is optimized to stop the sorting process when the array is detected as being in a sorted state

False

98
New cards

Once the selection sort places a value in the sorted list that value will never move again in the remainder of the passes

True

99
New cards

The insertion sorting algorithm begins with one value in the sorted list before the first pass

True

100
New cards

Searching assumptions for each statement unless specified otherwise:

The data in the array is unique

The amount of data in the array is equal to its capacity

The use of the binary search is always applied to a sorted array

True