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

Tags & Description

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

Studying Progress

0%
New cards
512
Still learning
0
Almost done
0
Mastered
0
512 Terms
1
New cards

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

True

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

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

New cards
4
New cards

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

True

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

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

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

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

New cards
9
New cards

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

False

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

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

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

New cards
13
New cards

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

True

New cards
14
New cards

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

False

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

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

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

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

New cards
19
New cards

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

False

New cards
20
New cards

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

True

New cards
21
New cards

Several sort passes will be necessary to sort most data sets

True

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

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

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

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

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

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>
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

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>
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

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>
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

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

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

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>
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

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>
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

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

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

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

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

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

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

New cards
40
New cards

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

True

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

New cards
42
New cards

Working with an uninitialized pointer variable is a logical error

True

New cards
43
New cards

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

True

New cards
44
New cards

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

True

New cards
45
New cards

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

True

New cards
46
New cards

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

True

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

New cards
48
New cards

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

True

New cards
49
New cards

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

True

New cards
50
New cards

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

True

New cards
51
New cards

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

True

New cards
52
New cards

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

True

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

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

New cards
55
New cards

The malloc function returns the starting address of the memory allocated

True

New cards
56
New cards

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

True

New cards
57
New cards

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

True

New cards
58
New cards

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

True

New cards
59
New cards

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

True

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

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

New cards
62
New cards

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

True

New cards
63
New cards

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>
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

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

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>
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

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>
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

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>
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

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

New cards
70
New cards

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

False

New cards
71
New cards

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

False

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

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

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

New cards
75
New cards

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

True

New cards
76
New cards

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

True

New cards
77
New cards

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

False

New cards
78
New cards

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

True

New cards
79
New cards

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

True

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

New cards
81
New cards

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

True

New cards
82
New cards

Several sort passes will be necessary to sort most data sets

True

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

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

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

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

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

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

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

New cards
90
New cards

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

True

New cards
91
New cards

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

False

New cards
92
New cards

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

False

New cards
93
New cards

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

False

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

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

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

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

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

New cards
99
New cards

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

True

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

New cards

Explore top notes

note Note
studied byStudied by 3 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 12 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 22 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 28 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 6 people
Updated ... ago
5.0 Stars(2)
note Note
studied byStudied by 2008 people
Updated ... ago
5.0 Stars(2)
note Note
studied byStudied by 10 people
Updated ... ago
4.0 Stars(1)
note Note
studied byStudied by 3 people
Updated ... ago
5.0 Stars(1)

Explore top flashcards

flashcards Flashcard39 terms
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard308 terms
studied byStudied by 16 people
Updated ... ago
4.0 Stars(1)
flashcards Flashcard42 terms
studied byStudied by 21 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard74 terms
studied byStudied by 8 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard64 terms
studied byStudied by 36 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard71 terms
studied byStudied by 3 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard60 terms
studied byStudied by 3 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard342 terms
studied byStudied by 70 people
Updated ... ago
5.0 Stars(1)