CS代考 The exam is worth 60 points total, and you have a total of 60 minutes. Show

The exam is worth 60 points total, and you have a total of 60 minutes. Show your work for partial credit. We recommend looking through all the questions before beginning.
Note 1: Assume all necessary !”#$%&'( statements are present, even if not shown. Note 2: For all questions on this exam, you should assume the following:
)”*(+,-.+”‘/0 11 2
)”*(+,-$3450 11 6

Copyright By PowCoder代写 加微信 powcoder

)”*(+,-“#70 11 8
)”*(+,-,%+470 11 8
)”*(+,-‘+&9%(0 11 2
Q2 Multiple Choice 20 Points
Select exactly one option for each question.
Which of these expressions generates a random integer in the range from -50 to 50, inclusive?
! 54#’-6::0 ; <: ! 54#'-6:60 ; <: ! -54#'-0 = 6::0 ; <: ! -54#'-0 = 6:60 ; <: Assume that a program H. needs to work with a sequence of ,%+47 values, I. the number of data values in the sequence is stored in the "#7 variable )* , and !. the number of data values could be large (possibly millions of data values) Which is the best way to create an array in which to store the data values? ! !"#$% &$'' ( )$""#*+,- & ,.-/#!+!"#$%001 ! !"#$% $''2344444444451 ! !"#$% $''2,-51 ! ,%$%.* !"#$% $''2344444444451 Which command would produce an executable called !"#+,-( from source files ".!'*( and !"#$%&'()*( ? ! #(( ".!'*( !"#$%&'()*( ! #(( /- !"#+,-( ".!'*( !"#$%&'()*( ! #(( /- !"#+,-( ".!'*- !"#$%&'()*- ! #(( /( ".!'*( !"#$%&'()*( Which of the following function declarations would make the most sense for a function intended to read an unknown (possibly large) number of %0-.1 values from an input file, placing them in an array, and indicating the number of data values read? ! %0-.12 ,3.4$5.0&3)6789: 2!'; !'1 '&"$5.0&3)<= ! %0-.1>? ,3.4$5.0&3)6789: 2!’; !’1 22’&”$5.0&3)<= ! %0-.12 ,3.4$5.0&3)6789: 2!'; !'1 2'&"$5.0&3)<= ! 5-!4 ,3.4$5.0&3)6789: 2!'; %0-.1 5.0&3)>?<= Which of the following expressions evaluates to a true value if (and only if) the string . compares as not equal to the string @ ? ! A)1,("+6.; @< ! )1,("+6.; @< BC D ! )1,("+6.; @< ! )1,("+6.; @< E D Header guards protect against the contents of a header included using F!'(0&43 from being processed by the compiler more than once. Which of these is not a way in which the contents of a header could be processed more than once? A source file uses !"#$%&'( to include the same header more than once A header file uses !"#$%&'( to include the same header more than once Two headers !"#$%&'( the same header The )*+(,"%( mentions a -. file multiple times in a target's dependencies !"#$ "% &'$ ()"*$ ('')*+ &,-& ! -%. "#$ -/+ %!& 0-/$-12+'3 (2'# -'')*+ &,-& &,+ 0-2)+ #4 ! $' $% &,+ /-%5+ 6 &# 789 $%:2)'$0+3 ;,$:, #4 &,+ 4#22#<$%5 '&-&+*+%&' '+&' 1$& ! #4 "#$ &# 69 <,$2+ 2+-0$%5 &,+ #&,+/ 1$&' #4 "#$ )%:,-%5+.= "#$ ' ("#$ )) !* ++ !, "#$ ' "#$ - (. ++ !*, "#$ ' "#$ / (. ++ !*, "#$ ' "#$ 0 1(. ++ !*, !" !"#$% &'()*$ +, -#.'%( /01* 0#2$ 3'()*$ .' %"* 4#56 !"#$ $*72$(.#' 8 -#.'%( 9$.%* %"* :#72;*'%3%.#' 7#;;*'% <#$ %"* <#==#).'> <2'7%.#' 40 *51=3.'.'> 3% 3 “.>” =*?*= )”3% .% :#*(6 @’7=2:* )”3% %”* 13$3;*%*$( $*1$*(*’% .’ 7#’%*5%6 /”* *51=3’3%.#’ (“#2=: ‘#% 4* 3 :.$*7% %$3′(=3%.#’ #< %"* 7#:* (%3%*;*'%(A !"#$ %&'()*&+,-.* /'0 #1( 2)13 4 #5 +2)1 6 73 4 ,-.* (%; < '=>?9
‘=>? < '=2)1 @ 7?9 '=2)1 @ 7? < (%;9 %&'()*&+' A 70 2)1 @ B39 Q3.2 list 5 Points Given the following declaration: !"#$%$& '!()*! +,%$- . '!()*! +,%$- 2 +$3!1 4 5,%$1 Write the documentation comment for the following function by explaining at a high level what it does. Include what the parameter represents in context. The explanation should not be a direct translation of the code statements. Suggestion: give an example of a linked list, and explain how the 6/'!$(" function would modify the example list. 7,/% 6/'!$("85,%$ 2*)(9 . :;/6$ 8*)( <= 5>?? @@ *)(AB+$3! <= 5>??9 .
5,%$ 2+ = *)(AB+$3!AB+$3!1
*)(AB%0!0 C= *)(AB+$3!AB%0!01
&($$8*)(AB+$3!91
*)(AB+$3! = +1
*)( = +1 4

!” !”#$ %&'(‘)* +, -“‘)(.
/$0# (1$ ‘).(&23(‘”). 30&$42556 7&.( 0)# (1$) 8&'($ 0 9&”*&0: “& 9&”*&0: .(0($:$)(. 0. &$;2’&$#< !"#$ !"#$%&'($%( )* +",&-( ."%/#0-0 -10 !"#$%&'($%( 2$&!-,"&3 410 /565%0-06 %)* ,( 5 /",&-06 -" -10 $//067#02- 0#0%0&- "2 5 60!-5&8$#56 %5-6,9 "2 :"5- 0#0%0&-(3 410 /565%0-06( +",( 5!&";#( 60/60(0&- -10 %5-6,9<( &$%=06 "2 6">( 5&; !”#$%&(? 410 2$&!-,”& (1″$#; !”%/$-0 -10 ($% “2 -10 @5#$0( ,& 05!1 !”#$%& “2 -10 %5-6,9? 5&; /#5!0 -10 ($%( ,& -10 0#0%0&-( “2- 10 ($%( 5665A3 B”$ !5& 5(($%0 -15- -10 ($%( 5665A<( &$%=06 "2 0#0%0&-( ,( 0C$5# -"" 6 8605-06 -1 5& !"#( 3 !"#$% &'()*(+* , - - ./01 2/21 2/01 '/3 41 - ./.1 '/)1 '/+1 5/6 41 - ./.1 0/'1 6/51 +/+ 41 !"#$% &'89:&9(+*7 ;#":&<89:&9=>&'(.*(.*1 )1 +1 &’89:&9?7 ,, ./.! B ./.! B ./0!?7 ,, 2/2! B ‘/)! B 0/’!?7 ,, 2/0! B ‘/+! B 6/5!?7 ,, ‘/3! B 5/6! B +/+!?7

Q4.2 collect_less_than 5 Points
The !”##$!%&#$”&%()* function is intended to find all of the data values in an array of
+”,-#$ values which are less than a specified value, and add them to a dynamically-allocated result array. The function returns the number of values returned in the result array. The following
test code demonstrates the expected behavior:
+”,-#$ +)%)./ 0 1
2345 6375 4385 8385 9375 :385 2325
+”,-#$ >?$’,#%=
@*% !”,*% 0 !”##$!%&#$”&%()*A+)%)5 B5 C365 D?$’,#%E=
)”$?%A!”,*% 00 CE=
)”$?%A?$’,#%.6/ 00 234E=
)”$?%A?$’,#%.7/ 00 637E=
)”$?%A?$’,#%.8/ 00 838E=
)”$?%A?$’,#%.9/ 00 937E=
)”$?%A?$’,#%.2/ 00 232E=
Show how to complete the implementation of !”##$!%&#$”&%()* :
@*% !”##$!%&#$”&%()*A!”*’% +”,-#$ @*% *5 +”,-#$ G)#5
+”,-#$ >>?$’,#%E 1
@*% 0 75 !”##$!%$+ 0 6=
>?$’,#% 0 J> !”+$ 7 >J=
L”? @ 0 6= @ M *= @NNE 1
@L M G)#E 1
@L A!”##$!%$+ O0 1
+”,-#$ >%KH 0 ?$)##”!AJ> !”+$ 8 >JE=
>?$’,#% 0 %KH=
“# $%&&%'( )*+, – #” . */%(0%12
)*33,)4,+552
/,46/’ “# $%&&%'( )*+, 7 #”2
!”#$ %” &$'()*$ “# $%&&%'( )*+, 8 #” +
!”#$ %” &$'()*$ “# $%&&%'( )*+, 9 #” +
!”#$ %” &$'()*$ “# $%&&%'( )*+, – #” +
!”#$ %” &$'()*$ “# $%&&%'( )*+, 7 #” +

Q4.3 merge 5 Points
Consider the following linked list node data type:
!”#$%$& ‘!()*! +,%$-
&/,0! %0!01
‘!()*! +,%$- 23$4!1 5 +,%$1
Complete the implementation of the following function. It is given a pointer to a Node, and should “merge” the Node with the Node ahead of it, ¡°absorbing¡± its value. If there is no next Node, then the function has no effect. For example, if the original linked list configuration is like this:
!”””””# !”””””# !”””””# !”””””#
666 “”7$ 869 $””7$ 96: $””7$ ;6; $””7$ <69 $""7 666 %"""""& %"""""& %"""""& %"""""& $ 3,%$ """"& then after calling the >$(?$ function, the configuration will be like this:
!”””””# !”””””# !”””””#
666 “”7$ 869 $””7$ @6A $””7$ <69 $""7 666 %"""""& %"""""& %"""""& $ 3,%$ """"& !"#$ %&'(&)*"$& +,"$&- . #/ )0+ %#11#,( 2"$& 3 +0- . *"$& +4%5 6 0+ %#11#,( 2"$& 7 +08 0+ %#11#,( 2"$& 9 +0 :6 4%5;<$=4=8 0+ %#11#,( 2"$& > +0 6 4%5;<,&?48 0+ %#11#,( 2"$& @ +08 00 A#,4B =!"#$ %&%"'C !"#$ %" &$'()*$ 0+ %#11#,( 2"$& 3 +0 + !"#$ %" &$'()*$ 0+ %#11#,( 2"$& 7 +0 + !"#$ %" &$'()*$ 0+ %#11#,( 2"$& 9 +0 + !"#$ %" &$'()*$ 0+ %#11#,( 2"$& > +0 +
!”#$ %” &$'()*$ 0+ %#11#,( 2″$& @ +0 +

Q4.4 spaceout 5 Points
Complete the !”#$%&'( function. It takes a pointer to a character string and a non-negative integer ) , and returns a pointer to a dynamically-allocated string in which there are ) space characters after each character from the original string. The following test code shows the expected behavior:
$*#+ !,- . /0 1! 2′)/3
$*#+ 4+%!5 . !”#$%&'(6!7 893
$*#+ 4+%!: . !”#$%&'(6!7 :93
#!!%+(6!(+$;”6+%!57 /0 1! 2′)/9 .. 893
#!!%+(6!(+$;”6+%!:7 /0 1 ! 2 ‘ ) /9 .. 893
Show how to complete the implementation of !”#$%&'( . $*#+ 4!”#$%&'(6$&)!( $*#+ !(+,-7 1)( )9 < #!!%+(6) =. 893 1)( >%) . 61)(9 ?4 ;1!!1)@ $&A% 5 4?3
$*#+ 4+%!’>( . ;#>>&$6!1B%&26$*#+9 4 ?4 ;1!!1)@ $&A% : 4?93
2&+ 61 . 83 1 C ?4 ;1!!1)@ $&A% D 4?3 1EE9 < 12 61 F 6)E59 .. 89 < +%!'>(,1- . !(+,?4 ;1!!1)@ $&A% G 4?-3
+%!’>(,1- . I I3
“#$%&'()* + ,- .)$$)/0 123# 4 -,5
“#’%”/ “#$%&’5
!”#$ %” &$'()*$ ,- .)$$)/0 123# 6 -, +
!”#$ %” &$'()*$ ,- .)$$)/0 123# 7 -, +
!”#$ %” &$'()*$ ,- .)$$)/0 123# 8 -, +
!”#$ %” &$'()*$ ,- .)$$)/0 123# 9 -, +
!”#$ %” &$'()*$ ,- .)$$)/0 123# 4 -, +

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com