LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-17-2018, 03:27 AM   #1
jamesbon
Member
 
Registered: Jun 2010
Posts: 147

Rep: Reputation: 9
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
 
Old 08-17-2018, 03:39 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,799

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
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.
 
2 members found this post helpful.
Old 08-17-2018, 08:31 AM   #3
jamesbon
Member
 
Registered: Jun 2010
Posts: 147

Original Poster
Rep: Reputation: 9
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.
 
Old 08-17-2018, 10:59 AM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
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.

Last edited by astrogeek; 08-17-2018 at 11:19 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Script to solve second order (polynomial) interpolation eminempark Programming 6 01-22-2013 03:16 AM
Cricket broadband on Linux po1 LinuxQuestions.org Member Success Stories 0 06-11-2010 03:06 PM
cricket broadband oscarhaylock Linux - Newbie 2 09-11-2009 01:40 AM
cricket - uninitialized value in script imanassypov Linux - Networking 0 03-21-2006 09:19 AM
Cricket World Cup rch General 8 03-13-2003 03:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration