In the bustling metropolis, Feluda, renowned for his keen intellect as a detective, found himself in possession of enigmatic strings of text – intriguing phrases like "YOJUS DELLIK HTANJAR NI HCRAM 3202." Alongside his faithful companion, Topshe, Feluda embarked on deciphering this cryptic riddle. He scrutinized each word with meticulous care, delving into the intricate connections woven within. Guided by subtle hints concealed within the list, Feluda adeptly assembled the pieces, akin to solving a complex jigsaw puzzle. Solve this problem with Single and double linked list.
Shrikant Tiwari was finally enjoying a weekend with his family after locating the positions of landmines in two separate parks - he as well as TASC had thought that the imminent danger of the Ninja Warrior group was over. However an urgent phone call proved him wrong - the intelligence cell of TASC has intercepted a message: the largest park in the city has been filled with landmines, and the park would open in 30 minutes! There were few cryptic messages as well: "Sparse matrix.. past two minefields.. multiply..linked list". Shrikant very well understood what to do. Play the role of Shrikant and input two multipliable sparse matrices, where the positions of the landmines are depicted as 1 and empty spaces as 0. Then using that, find the landmines planted in the new park. Remember the cryptic message you intercepted!
Indiana Jones is in the search of the Golden Goose! He had found two stones which had inscriptions like this:
(a) 7x^2+x^3+9x^5
(b) 8x+12x^6+3x^5
On his journey, he came across a cave which had a door. That door contained some dials - which had to be spinned to show a certain number. Indiana figured out that the number of dials equaled to the largest of exponents of the polynomials engraved in the stones. Indiana Jones understood what to do and took out his laptop. He wrote a code which would take the largest number of exponents and some other necessary values from the stones, as user input. He then returned the code which was to be input into the cave door. Can you help Indiana Jones write this code, so that he can open the door and find the Golden Goose?
Hint: Should Indiana add or multiply? Justify.
Famous superhero Ben Tennyson, aka Ben 10, has been given a task by the alien scientist Azmuth, completing which he would give him the master control of the Omnitrix watch, making him even more powerful - the most powerful superhero in the galaxy. The challenge is that Azmuth has a lab full of many aliens, and he has to arrange them according to height. Ben must arrange these aliens according to height, and not only that he must show the worst case, best case and average case time complexity of this sort in a graph. Ben transformed into the most intelligent alien he knew of: Brainstorm, and started thinking about the problem. Can you play the role of Brainstorm/Ben and solve his dilemma to make him the most powerful superhero in the galaxy? Use all the sorting algorithms you have been taught, and discuss which algorithm is the fastest.
Celebrity sports car racer Dominic Toretto is in a dilemma. His family has been kidnapped by the new and emerging local thug Stephano, just to prove that he is the best racer around town! In order to free his family Dominic must race Stephano. Dominic was confident he would win, but the night before the race some anonymous thugs damaged the engine of his car. Dominic figured out that his car is now half as fast as Stephano's. The next day Dominic and Stephano had a heated argument: Stephano should not have sent thugs to his place - it was foul play from his side. Stephano replied, "Okay. Let's change the rules of the game. We will go around this race track with a loop, and I will give you a paintball. We will start at the same time, but since your car's speed is half of mine, you can choose the number of laps I will make in the race, after which I win. If you can come beside me and throw a paintball at my car before that, your family is free."
Part A: Take the road structure as a linked list of road segments, as input. Also take a number k as input, if Dominic and Stephano are in the same road segment within k rounds, Dominic wins, and his family is freed. Else Stephano wins.
Print whether Dominic will win or Stephano will win.
Sample output:
Stephano will win
Sample input 2:
For the same racetrack if the value of k = 3.
Sample output:
Dominic will win
Part B:
Take the road structure as a linked list of road segments, as input. Find the minimum number of rounds
which will Stephano has to take for Dominic to win.
Sample input:
The same racetrack as in part A.
Sample output:
Dominic will win before Stephano completes 2 laps.
HINT: You can consider a lap has been completed by a person if ID of next road segment visited
by a person < ID of current road segment of the person.