Consider the following procedure, where L1 and L2 are two non-empty lists. Choose the correct option.
Procedure CompareLists(L1, L2)
if(length(L1) != length(L2)){
return(False)
}
while(length(L1) > 0){
if(last(L1) != last(L2)){
return(False)
}
L1 = init(L1)
L2 = init(L2)
}
return(True)
End CompareLists
Topic Mapping: chapter: Week 5 │ topic: Lists — Iteration and Processing │ subtopic: Comparing list elements and sizes using last and init operations in a loop
Q2
22 Dec 2024
Computational Thinking · Week 1
Q2.Consider the following procedure, where L1 and L2 are two non-empty lists. Choose the correct option.
Procedure CompareLists(L1, L2)
if(length(L1) != length(L2)){
return(False)
}
while(length(L1) > 0){
if(last(L1) != last(L2)){
return(False)
}
L1 = init(L1)
L2 = init(L2)
}
return(True)
End CompareLists
Topic Mapping: chapter: Week 5 │ topic: Lists — Iteration and Processing │ subtopic: Comparing list elements and sizes using last and init operations in a loop