$25
Q1. Students of a school are standing in a row for drill practice.
a. Find if the student ‘P’ is present at the position ‘U’ in the row
b. Find the length of the row
Write a prolog program to solve the question.
Assume row consists of names of students denoted by unique value.
Q2. Assume the same situation as previous question where students are standing in a queue with each one holding basket of candies which contain some number of candies each (assume this to be the previous state), now distributor thought to reassign candies to students hence here distributor followed an algorithm where he gave xi number of candies to the ith student such that xi is summation of all candies given to the students before ith student in previous state. Write a prolog program to get updated values of candies with each student after distribution.
Assume first student standing in that queue gets same number of candies as he/she got in previous state.