CS 159 Final Studying

studied byStudied by 38 people
5.0(1)
Get a hint
Hint

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

1 / 511

flashcard set

Earn XP

Description and Tags

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

512 Terms

1

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

True

New cards
2

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

True

New cards
3

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

New cards
4

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

True

New cards
5

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

New cards
6

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

True

New cards
7

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

New cards
8

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

New cards
9

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

False

New cards
10

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

False

New cards
11

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

True

New cards
12

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

True

New cards
13

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

True

New cards
14

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

False

New cards
15

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

New cards
16

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

New cards
17

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

New cards
18

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

New cards
19

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

False

New cards
20

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

True

New cards
21

Several sort passes will be necessary to sort most data sets

True

New cards
22

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

New cards
23

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

False

New cards
24

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

True

New cards
25

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

New cards
26

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

True

New cards
27
<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

New cards
28
<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

New cards
29
<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

New cards
30

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

New cards
31

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

True

New cards
32
<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

New cards
33
<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

New cards
34

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

False

New cards
35

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

New cards
36

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

True

New cards
37

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

New cards
38

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

True

New cards
39

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

True

New cards
40

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

True

New cards
41

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

New cards
42

Working with an uninitialized pointer variable is a logical error

True

New cards
43

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

True

New cards
44

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

True

New cards
45

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

True

New cards
46

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

True

New cards
47

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

New cards
48

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

True

New cards
49

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

True

New cards
50

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

True

New cards
51

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

True

New cards
52

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

True

New cards
53

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

False

New cards
54

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

True

New cards
55

The malloc function returns the starting address of the memory allocated

True

New cards
56

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

True

New cards
57

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

True

New cards
58

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

True

New cards
59

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

True

New cards
60

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

New cards
61

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

True

New cards
62

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

True

New cards
63

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

True

New cards
64
<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

New cards
65

What is the output?
A) *y = 1

B) *y = 2

C) *y = 5

D) *y = 10

E) None of the above

B

New cards
66
<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

New cards
67
<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

New cards
68
<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

New cards
69

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

True

New cards
70

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

False

New cards
71

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

False

New cards
72

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

True

New cards
73

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

True

New cards
74

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

New cards
75

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

True

New cards
76

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

True

New cards
77

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

False

New cards
78

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

True

New cards
79

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

True

New cards
80

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

True

New cards
81

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

True

New cards
82

Several sort passes will be necessary to sort most data sets

True

New cards
83

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

New cards
84

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

True

New cards
85

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

False

New cards
86

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

True

New cards
87

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

New cards
88

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

True

New cards
89

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

True

New cards
90

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

True

New cards
91

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

False

New cards
92

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

False

New cards
93

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

False

New cards
94

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

True

New cards
95

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

New cards
96

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

New cards
97

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

False

New cards
98

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

True

New cards
99

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

True

New cards
100

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

New cards

Explore top notes

note Note
studied byStudied by 151 people
... ago
5.0(1)
note Note
studied byStudied by 6 people
... ago
5.0(1)
note Note
studied byStudied by 16 people
... ago
5.0(1)
note Note
studied byStudied by 12 people
... ago
5.0(1)
note Note
studied byStudied by 40 people
... ago
5.0(2)
note Note
studied byStudied by 12 people
... ago
4.0(291)
note Note
studied byStudied by 35 people
... ago
5.0(3)
note Note
studied byStudied by 12 people
... ago
5.0(1)

Explore top flashcards

flashcards Flashcard (40)
studied byStudied by 16 people
... ago
5.0(1)
flashcards Flashcard (79)
studied byStudied by 7 people
... ago
5.0(1)
flashcards Flashcard (39)
studied byStudied by 6 people
... ago
5.0(1)
flashcards Flashcard (69)
studied byStudied by 35 people
... ago
5.0(1)
flashcards Flashcard (76)
studied byStudied by 41 people
... ago
5.0(1)
flashcards Flashcard (81)
studied byStudied by 107 people
... ago
5.0(3)
flashcards Flashcard (40)
studied byStudied by 4 people
... ago
5.0(1)
flashcards Flashcard (25)
studied byStudied by 4 people
... ago
5.0(1)
robot