LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   fantacy cricket and polynomial representation problem (https://www.linuxquestions.org/questions/programming-9/fantacy-cricket-and-polynomial-representation-problem-4175636542/)

jamesbon 08-17-2018 03:27 AM

fantacy cricket and polynomial representation problem
 
Hi I need some algorithm to solve following problems, I code in C,
any help is appreciated.

Problems
(1) Let A and B be the pointers to two polynomial represented using linked list. Write a function to compute the product polynomial D = A * B. The function should leave A and B unaltered and create D as a new polynomial.
(2) Let A be a pointer to a polynomial. Write a function to evaluate the polynomial A at a point x where x is a floating point number.
(3) Write a program which accepts a valid infix expression and provide its corresponding postfix expression. Consider following assumptions:
• There are 5 operators (+,-,*,/ and ^).
• + and – follow right to left associativity
• * and / also follow right to left associativity
• ^ follow left to right associativity
(4) Fantasy cricket league is a type of game where we can earn points by selecting best 11 players from two playing cricket team. Let us assume that we need to develop an application which can select best 11 players to score maximum points. The application will select the best players after completion of a match. The rules are mentioned below.
a. Each cricket team will have 5 players (2 batsmen, 2 bowlers and 1 wicket keeper) only. (For two teams total 10 players)
b. 1 Run means 1 point. 1 wicket means 50 points. Wicketkeepers points will be depend on bowlers. If two bowlers score 100 total points then the points of wicketkeeper will be 50. (50%).
c. One batsman can score in between 0 to 100 and one bowler can take maximum 3 wickets.
d. All out is not necessary. Bowlers cannot score runs.
e. Points of captain of the fantasy team will be double. That means 1 run = 2 points and 1 wicket = 100 points. The application will automatically select the captain.
f. One fantasy cricket team can have only one captain.
g. One can select maximum three players from a team.
h. Fantasy team can score maximum 200 runs and can take maximum 4 wickets.

1. First create two link lists of two cricket teams (Say team A and team B). Total 5 nodes. The structure of the list is as mentioned below. Put the runs scored by the batsman and wicket taken by the bowler in data field. The points of wicket keepers will be counted automatically as mentioned earlier.

Batsman(1) Batsman(2) Wicketkeeper Bowler(1) Bowler(2)

2. Create a new linklist from above two lists. The data field will represent the team name from where the player belongs. This list will select the best possible 5 players to get the maximum points.
3. Display the fantasy points earn by your selected team.
4. Select the highest run scoring batsman (Select the team) and maximum wicket taking player (Select the team). Select the best valuable wicketkeeper (Select the team). These players may not be present in the selected fantasy cricket team.
-----------------------------------------------------------------------------------------------------------------------
Test Cases:
Input:
Enter runs score by team ‘A’ batsmen followed by team ‘B’:
29, 81, 79, 35
Enter wicket taken by team ‘A’ bowlers followed by team ‘B’:
1, 3, 2, 2
Output:
Question 1: Display the two link lists.
Question 2: A->B->B->A->A (Result: 81+79+100+150+50) (Captain is a bowler from team A)
Question 3: Points: 81+79+100+300+50=610
Question 4: Highest run scoring batsman is from team A. Highest wicket taking bowler is from team A. Valuable wicketkeeper is from team B.

(5) In a mathematics examination you are asking to find out the LCM and HCF of two numbers. You have ‘n’ questions to solve. You need to solve the entire question by using array and store the result in two separate arrays (For HCF and LCM). Let us assume that for some reason you can solve only ‘n-1’ question in first attempt. You missed the middle question to solve. If ‘n’ is an even number then the middle element = (n/2)th position question and if ‘n’ is an odd number then the middle element = ((n+1)/2)th position question.
Questions:
1. You have total ‘2n’ numbers (2 numbers for each question). Create an array and store the numbers in that array. Avoid the numbers of middle question.
2. Save the LCM result in a Queue.
3. Save the HCF result in a Stack.
4. Now you need to solve the middle question. So first store the two numbers in the middle position of the array and find out the LCM and HCF. Also store the result in LCM and HCF array.
5. Now you need to delete the first and middle question. Hence the LCM and HCF of the first and middle question will be deleted.
---------------------------------------------------------------------------------------------------------------------
Test Case
How many question you want to solve?
3
Enter the two numbers of 1st question followed by 2nd and question.
2,4,3,9, 20, 7
Question 1: Array is: 2, 4,20,7
Question 2: Queue is: 4,140
Question 3: Stack is (First element is the top of the stack): 1, 2
Question 4: New Array: 2,4,3,9,20,7
New Queue: 4, 140, 9
New Stack: 3, 1, 2
Question 5: After deleting first and middle question
New array: 20, 7
New Queue: 140
New Stack: 1

pan64 08-17-2018 03:39 AM

https://www.linuxquestions.org/linux/rules.html
Quote:

Do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and searches) and we'll do our best to help. Keep in mind that your instructor might also be an LQ member.

jamesbon 08-17-2018 08:31 AM

I don't have any idea as how to proceed in the problems given above any hint or algorithm I am not asking for exact code.

astrogeek 08-17-2018 10:59 AM

As pan64 has already pointed out, we are happy to help with specific programming questions, but posting homework questions verbatim is not respectful of the time of others, not helpful to yourself and against LQ rules.

If you are not sure how to proceed then you should discuss it with your instructor or teacher. LQ members know nothing about how the course is structured and what is expected of the student.

Start with the first question which tells you how to represent the problem using linked lists. If you do not understand linked lists then review your course material which should have covered this subject before asking you to use it. Also use your favorite search engine to find a wealth of relevant information.

As you learn, and encounter real programming issues, please post your specific questions here and others will be happy to help.

You may want to review the Site FAQ as an excellent generic guide to formulating questions and forum participation, not applicable to LQ alone.


All times are GMT -5. The time now is 07:20 PM.