Wednesday, April 30, 2008

The Data structures exam

hey all,

as always after an enthu start, i stopped blogging. so here i am, back again tryin to keep it going. :-)
got a bit busy in my exams n stuff. nways, so tday was the Data structures practical exam..
We had 3 options and had to choose one of them and write the code for it accordingly. the 3 options were:
1.Binary Search tree: inorder traversal(non recursive), display, node delete, search and height of node.
2.djikstra's thm: find shortest path in given network.
3.store a polynomial using linked list and do: add, multiply, evaluation

the 3rd was obviously the easiest. and so i started off with it.. 1.5 hrs into the pracs(I had 3hrs in all, to complete the program), everything except for evaluation was done and working(including the menus in main() ).. absolutely well, i may add. so a happy nikhil started off with the last part. a simple 4-5 line evaluation code.

having done that, i just touched up a few lil things here and there and ran the program. and viola!! 9 errors show up on screen. and stupid ones. like '(' expected. 'poly' cannot start a parameter declaration. functions like multiply and add which were working till then suddenly started acting up. nothing would work.

Having had lotsa such experiences, i started off stripping the code down to its bones. put the node class as global instead of nested. deleted a few functions. etc.
NOTHING!! nothing would work

Finally, i put a character string as the only data in the poly class and tried printing it to screen. NOTHING!! it just would not work. finally a brainwave.

i changed the name of the poly class to 'ply' and VIOLA!! the program works!! just simply too good..
then started the task of putting all the code back into the class and undoing the changes i had in stripping it down..

finally with about 3 minutes to end of time(no jokes here!!) my code started working. but still i kept getting garbage data in between. then the 2nd brainwave. i had forgotten to rename the constructor.. did that. and with 1 min to end o time. the program worked..

HUSH!! such a relief it was.. it was like.. wow.. it worked finally.. i did it..

after thoughts: Later i came to know the fact that 'poly' is already defined in the math.h header file that i included for evaluating the polynomial. so a VERY IMPORTANT lesson learnt..

thats all for tday. after that, had a good time n chilled out at CCD discussing some techie n non-techie stuff.. so that was good.. :-)

adios..