1.
Each assignment will be of 10 marks.
2.
One mark will be deducted if
assignment is submitted on last date.
3.
After last date, 2 marks per day will
be deducted.
4.
7 marks will be given for exactly
following general requirements and hints. Extra 3 marks will be for those who
implement all requirements and do more than required.
5.
Marks will not be deducted for small
logical errors.
6.
Please do not get assignment from
others or give to others. Also, do not get or give assignment help. Get help on
data structures and programming. If you want to help others, teach them
programming and algorithms. Assignment is for self preparation.
7.
5 Negative marks will be given for
copied assignment for the first time. F grade will be given for 2nd
time submission of copied assignment.
8.
Please email source code to saeedturk@yahoo.com, (before submitting) or bring in USB. Also
bring Printed Source Code at submission.
DSA Pre-Mid Assignment 2018
1. Predator-Prey Simulation on a 2D Array.
Predator is always attracted towards Prey while prey is always repelled away from
predator. If predator position is denoted by Pi,j, and prey position
is denoted by pij, attraction/repulsion is directly proportional to
distance between P and p. Distance between two elements of 2D array can be
calculated using Cartesian formula. Movements of predator and prey are always
in row or column wise. Movement of predator is always towards prey, while
movement of prey can be away from predator but with some random long /medium
jumps in any direction. Can predator ever catch the prey? Can you optimize your
algorithm to guarantee that predator will never be able to catch prey?
2. Stack based
Expression evaluator
As discussed in class, an expression evaluator consists of two
main components.
1.
Infix
to Postfix converter
2.
Postfix
expression evaluator.
Both parts use stacks(of different types, obviously).
Your expression evaluator should contain following core
functionality.
General
requirements
1.
Input
an infix expression.
2.
Operands
should be single digit.
3.
operators
+, -, * , /, ^,
4.
parenthesis
should also be supported. ( it is simple. Starting parenthesis: push in operand
stack. Ending parenthesis: pop all operators until a starting parenthesis is
found. Ending and starting parenthesis are not added to output postfix
expression. Also, if a low priority operator comes, it will pop all
higher/equal priority operators until a starting parenthesis)
5.
print
output postfix expression on screen.
6.
Use
same expression or a newly input expression from user.
7.
Calculate
solution of postfix expression.
8.
If
any error is found in calculation, indicate as syntax error.
Advanced: Above mentioned requirements will get you 7/10 marks.
For 3 more marks.
1.
Input
operands may be multidigit and decimal numbers.
2.
Input
operands may be variable.
3.
Operands
may be more complex. Like exp(x), sin(x), a+b(c+d), -a%b, etc.
Assignment 3: Pure dynamic array: Develop a
pure dynamic array class, as discussed in class.
Dynamic array has following features.
Dynamic array has following features.
1. Array size can be dynamically set. Array can
grow and shrink dynamically and automatically. Growth will double the array
size and should be when array is approximately 95% utilized. Shrinkage will
decrease the size to half and should be called when array is about 40%
utilized.
2. Implement instertAt, InsertinOrder,
insertlast, deleteAt, deleteLast, searchAndDelete etc methods.
3. Implement array traversal, i.e. just screen
output.
4. Array input, output, search, delete,
insertInOrder etc as a menu based program.
0 comments:
Post a Comment