Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assemble Conga Line Have you ever heard the term conga line? Basically, it s a carnival dance where the dancers form a long line. Everyone
Assemble Conga Line
Have you ever heard the term conga line? Basically, its a carnival dance where the dancers form a long line. Everyone holds the waist of the person in front of them and their waists are held in turn by the person to their rear, excepting only those in the front and the back. It kind of looks like this
By now, you can quite understand the suitable data structure to represent a conga line. Now you are the choreographer of the Conga Dance in a Summer Festival. You wish to arrange the conga line ascending age wise and tell the participants to stand in a line likewise. Now as technical you are, can you write a method that will take the conga line and return True if everyone stands according to your instruction. Otherwise returns False.
Sample Input
Sample Input
Sample Output
True
Sample Output
False
You must Run this cell for your driver code to execute successfully
#Run this cell
class Node:
def initselfelem,next None:
self.elem,self.next elem,next
def createListarr:
head Nodearr
tail head
for i in rangelenarr:
newNode Nodearri
tail.next newNode
tail newNode
return head
def printLinkedListhead:
temp head
while temp None:
if temp.next None:
printtempelem, end
else:
printtempelem
temp temp.next
print
Driver code:
def assemblecongalinecongaline:
#TO DO
printTest Case
congaline createListnparray
printOriginal Conga Line: end
printLinkedListcongaline
returnedvalue assemblecongalinecongaline
printreturnedvalue #This should print True
unittest.outputtestreturnedvalue, True
print
printTest Case
congaline createListnparray
printOriginal Conga Line: end
printLinkedListcongaline
returnedvalue assemblecongalinecongaline
printreturnedvalue #This should print False
unittest.outputtestreturnedvalue, False
print
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started