WGUl C949l Objectivel Assessmentl (Latestl
2026l Update)l Datal Structuresl andl
Algorithmsl Il Review|l 100%l Verifiedl
Questionsl &l Answersl |l Gradel A
Q:l Howl canl youl identifyl al Bubblel sortl froml code?
Answer:
Doublel nestedl loop.
Comparisonl andl swappingl ofl adjacentl elements.
Afterl eachl iterationl ofl thel outerl loop,l onel elementl isl guaranteedl tol bel inl itsl finall
position.
forl il inl range(n):
l forl jl inl range(0,l n-i-1):
l ifl arr[j]l >l arr[j+1]:
l arr[j],l arr[j+1]l =l arr[j+1],l arr[j]
Q:l Howl canl youl identifyl al Bucketl sortl froml code?
Answer:
Arrayl orl listl ofl buckets.
Distributionl ofl elementsl intol bucketsl basedl onl al hashingl orl rangel function.
Sortingl withinl bucketsl andl thenl concatenatingl them.
bucketl =l [[]l forl _l inl range(n)]
forl eleml inl arr:
l indexl =l int(eleml *l n)
l bucket[index].append(elem)
forl il inl range(n):
l bucket[i].sort()
sorted_arrl =l []
forl bl inl bucket:
,l sorted_arr.extend(b)
Q:l Howl canl youl identifyl al Mergel sortl froml code?
Answer:
Recursionl usedl tol splitl thel array.
Al mergel functionl thatl combinesl twol sortedl arrays.
Basel casel checksl forl subarrayl sizel (e.g.,l whenl thel lengthl isl 1).
defl merge_sort(arr):
l ifl len(arr)l >l 1:
l midl =l len(arr)l //l 2
l Ll =l arr[:mid]
l Rl =l arr[mid:]
l
l merge_sort(L)
l merge_sort(R)
l
l il =l jl =l kl =l 0
l whilel il <l len(L)l andl jl <l len(R):
l ifl L[i]l <l R[j]:
l arr[k]l =l L[i]
l il +=l 1
l else:
l arr[k]l =l R[j]
l jl +=l 1
l kl +=l 1
l whilel il <l len(L):
l arr[k]l =l L[i]
l il +=l 1
l kl +=l 1
l whilel jl <l len(R):
l arr[k]l =l R[j]
l jl +=l 1
l kl +=l 1
Q:l Howl canl youl identifyl al Quickl sortl froml code?
,Answer:
Partitioningl stepl tol placel thel pivotl inl itsl correctl position.
Recursionl onl leftl andl rightl subarrays.
Usel ofl al pivotl element.
defl quicksort(arr):
l ifl len(arr)l <=l 1:
l returnl arr
l pivotl =l arr[len(arr)l //l 2]
l leftl =l [xl forl xl inl arrl ifl xl <l pivot]
l middlel =l [xl forl xl inl arrl ifl xl ==l pivot]
l rightl =l [xl forl xl inl arrl ifl xl >l pivot]
l returnl quicksort(left)l +l middlel +l quicksort(right)
Q:l Bigl Ol notationl ofl Constant?
Answer:
O(1)l -l Whenl yourl calculationl isl notl dependentl onl thel inputl size,l itl isl al constantl timel
complexityl (Excellent/Best)l -l Nol incline
Q:l Bigl Ol notationl ofl Linearl Time?
Answer:
O(n)l -l Whenl youl havel al singlel loopl withinl yourl algorithm,l itl isl linearl timel
complexityl (Fair)l -l Straightl linearl line
Q:l Bigl Ol notationl ofl Logarithmicl Time?
Answer:
O(nl logl n)l -l Whenl thel inputl sizel isl reducedl byl half,l maybel whenl iterating,l handlingl
recursion,l orl whatsoever,l itl isl al logarithmicl timel complexity
Q:l Bigl Ol notationl ofl Quadraticl Time?
, Answer:
O(n^2)l -l Whenl youl havel nestedl loopsl withinl yourl algorithm,l meaningl al loopl inl al
loop,l itl isl quadraticl timel complexity
Q:l Bigl Ol notationl ofl Exponentiall Time?
Answer:
O(2^n)l -l Whenl thel growthl ratel doublesl withl eachl additionl tol thel input,l itl isl
exponentiall timel complexity
Q:l Bigl Ol notationl ofl Factoriall Time?
Answer:
O(n!)
Q:l Whatl isl thel keyl differencel betweenl dynamicl andl staticl variablel declaration?
Answer:
Dynamicl variablel declarationl allowsl thel typel ofl thel variablel tol bel determinedl atl
runtime,l whilel staticl variablel declarationl requiresl thel typel tol bel definedl atl compilel
time.
Q:l Howl isl thel assignmentl operatorl =l usedl inl programming?
Answer:
Thel assignmentl operatorl =l assignsl thel valuel onl thel right-handl sidel tol thel variablel onl
thel left-handl side.
Q:l Whatl doesl thel +=l assignmentl operatorl do?
Answer:
2026l Update)l Datal Structuresl andl
Algorithmsl Il Review|l 100%l Verifiedl
Questionsl &l Answersl |l Gradel A
Q:l Howl canl youl identifyl al Bubblel sortl froml code?
Answer:
Doublel nestedl loop.
Comparisonl andl swappingl ofl adjacentl elements.
Afterl eachl iterationl ofl thel outerl loop,l onel elementl isl guaranteedl tol bel inl itsl finall
position.
forl il inl range(n):
l forl jl inl range(0,l n-i-1):
l ifl arr[j]l >l arr[j+1]:
l arr[j],l arr[j+1]l =l arr[j+1],l arr[j]
Q:l Howl canl youl identifyl al Bucketl sortl froml code?
Answer:
Arrayl orl listl ofl buckets.
Distributionl ofl elementsl intol bucketsl basedl onl al hashingl orl rangel function.
Sortingl withinl bucketsl andl thenl concatenatingl them.
bucketl =l [[]l forl _l inl range(n)]
forl eleml inl arr:
l indexl =l int(eleml *l n)
l bucket[index].append(elem)
forl il inl range(n):
l bucket[i].sort()
sorted_arrl =l []
forl bl inl bucket:
,l sorted_arr.extend(b)
Q:l Howl canl youl identifyl al Mergel sortl froml code?
Answer:
Recursionl usedl tol splitl thel array.
Al mergel functionl thatl combinesl twol sortedl arrays.
Basel casel checksl forl subarrayl sizel (e.g.,l whenl thel lengthl isl 1).
defl merge_sort(arr):
l ifl len(arr)l >l 1:
l midl =l len(arr)l //l 2
l Ll =l arr[:mid]
l Rl =l arr[mid:]
l
l merge_sort(L)
l merge_sort(R)
l
l il =l jl =l kl =l 0
l whilel il <l len(L)l andl jl <l len(R):
l ifl L[i]l <l R[j]:
l arr[k]l =l L[i]
l il +=l 1
l else:
l arr[k]l =l R[j]
l jl +=l 1
l kl +=l 1
l whilel il <l len(L):
l arr[k]l =l L[i]
l il +=l 1
l kl +=l 1
l whilel jl <l len(R):
l arr[k]l =l R[j]
l jl +=l 1
l kl +=l 1
Q:l Howl canl youl identifyl al Quickl sortl froml code?
,Answer:
Partitioningl stepl tol placel thel pivotl inl itsl correctl position.
Recursionl onl leftl andl rightl subarrays.
Usel ofl al pivotl element.
defl quicksort(arr):
l ifl len(arr)l <=l 1:
l returnl arr
l pivotl =l arr[len(arr)l //l 2]
l leftl =l [xl forl xl inl arrl ifl xl <l pivot]
l middlel =l [xl forl xl inl arrl ifl xl ==l pivot]
l rightl =l [xl forl xl inl arrl ifl xl >l pivot]
l returnl quicksort(left)l +l middlel +l quicksort(right)
Q:l Bigl Ol notationl ofl Constant?
Answer:
O(1)l -l Whenl yourl calculationl isl notl dependentl onl thel inputl size,l itl isl al constantl timel
complexityl (Excellent/Best)l -l Nol incline
Q:l Bigl Ol notationl ofl Linearl Time?
Answer:
O(n)l -l Whenl youl havel al singlel loopl withinl yourl algorithm,l itl isl linearl timel
complexityl (Fair)l -l Straightl linearl line
Q:l Bigl Ol notationl ofl Logarithmicl Time?
Answer:
O(nl logl n)l -l Whenl thel inputl sizel isl reducedl byl half,l maybel whenl iterating,l handlingl
recursion,l orl whatsoever,l itl isl al logarithmicl timel complexity
Q:l Bigl Ol notationl ofl Quadraticl Time?
, Answer:
O(n^2)l -l Whenl youl havel nestedl loopsl withinl yourl algorithm,l meaningl al loopl inl al
loop,l itl isl quadraticl timel complexity
Q:l Bigl Ol notationl ofl Exponentiall Time?
Answer:
O(2^n)l -l Whenl thel growthl ratel doublesl withl eachl additionl tol thel input,l itl isl
exponentiall timel complexity
Q:l Bigl Ol notationl ofl Factoriall Time?
Answer:
O(n!)
Q:l Whatl isl thel keyl differencel betweenl dynamicl andl staticl variablel declaration?
Answer:
Dynamicl variablel declarationl allowsl thel typel ofl thel variablel tol bel determinedl atl
runtime,l whilel staticl variablel declarationl requiresl thel typel tol bel definedl atl compilel
time.
Q:l Howl isl thel assignmentl operatorl =l usedl inl programming?
Answer:
Thel assignmentl operatorl =l assignsl thel valuel onl thel right-handl sidel tol thel variablel onl
thel left-handl side.
Q:l Whatl doesl thel +=l assignmentl operatorl do?
Answer: