Connecting Tech Pros Worldwide Forums | Help | Site Map

Re: Solution needed..urgent!!

Juha Nieminen
Guest
 
Posts: n/a
#1: Oct 23 '08
Ankur Arora wrote:
Quote:
Do not use STL.
Any rational reason for this?

Richard Herring
Guest
 
Posts: n/a
#2: Oct 23 '08

re: Re: Solution needed..urgent!!


In message <CQZLk.87$yl1.45@read4.inet.fi>, Juha Nieminen
<nospam@thanks.invalidwrites
Quote:
>Ankur Arora wrote:
Quote:
>Do not use STL.
>
Any rational reason for this?
It motivates homework question 2:

"Why didn't your first design work?
(a) dangling pointers;
(b) uninitialised pointers;
(b) double deletion;
(c) incorrect container insertion/deletion algorithm;
(d) all of the above"

:-/
--
Richard Herring
Stuart Golodetz
Guest
 
Posts: n/a
#3: Oct 23 '08

re: Re: Solution needed..urgent!!


Juha Nieminen wrote:
Quote:
Ankur Arora wrote:
Quote:
>Do not use STL.
>
Any rational reason for this?
By not allowing you to use STL, they encourage you to write your own
classes to do the same thing - the process of reinventing the wheel will
convey to you (a) a fair amount about the STL, (b) an understanding of
why reinventing the wheel is generally to be avoided and (c) a healthy
appreciation of the hard work put in by the people who have worked on
the STL over the years. In other words, you'll learn a whole lot more by
working around the stupid wording of the question than you ever would
have done by merely solving the question itself...

Cheers,
Stu

P.S. It's also worth noting that the question said "STL" and not
"Standard Library". Should we take this to mean that any portions of the
Standard Library which were not inherited from the STL are usable...?
Hendrik Schober
Guest
 
Posts: n/a
#4: Oct 23 '08

re: Re: Solution needed..urgent!!


Stuart Golodetz wrote:
Quote:
[...]
P.S. It's also worth noting that the question said "STL" and not
"Standard Library". Should we take this to mean that any portions of the
Standard Library which were not inherited from the STL are usable...?
Well, yeah, it would be hard to be sure the task was done
without using 'std::cout' et.al., wouldn't it?

Schobi
James Kanze
Guest
 
Posts: n/a
#5: Oct 23 '08

re: Re: Solution needed..urgent!!


On Oct 23, 3:50*pm, Stuart Golodetz
<sgolod...@NdOiSaPlA.pMiPpLeExA.ScEomwrote:
Quote:
Juha Nieminen wrote:
Quote:
Ankur Arora wrote:
Quote:
Do not use STL.
Quote:
Quote:
* Any rational reason for this?
Quote:
By not allowing you to use STL, they encourage you to write
your own classes to do the same thing - the process of
reinventing the wheel will convey to you (a) a fair amount
about the STL, (b) an understanding of why reinventing the
wheel is generally to be avoided and (c) a healthy
appreciation of the hard work put in by the people who have
worked on the STL over the years.
I'm not so sure about that. Writing a simple array class which
is usable in one particular context is actually very simple.
Designing the interface so that it can be generally usable in
the widest number of different contexts is another matter, not
to mention implementing it in a manner so that it will have
adequate performance for all possible uses.

It's worth implementing some simple containers and algorithms
yourself, to understand the issues better, but doing so will not
help you better understand the STL.

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
gw7rib@aol.com
Guest
 
Posts: n/a
#6: Oct 23 '08

re: Re: Solution needed..urgent!!


On 23 Oct, 14:51, Ankur Arora <ankuraror...@gmail.comwrote:
Quote:
Here's what I have come up with so far (very basic, algorithmic
steps):-
- use of pointers to manipulate the deck since we will be doing a lot
of shuffling. A link list would be a good choice with each node
representing a card and the link list chain representing a particular
ordering.
This sounds good. I'd recommend the type of linked list where you keep
track of both the first and the last element in the list. This makes
adding to the end much quicker.

Hope that helps.
Paul.
Pete Becker
Guest
 
Posts: n/a
#7: Oct 23 '08

re: Re: Solution needed..urgent!!


On 2008-10-23 16:22:52 -0400, gw7rib@aol.com said:
Quote:
On 23 Oct, 14:51, Ankur Arora <ankuraror...@gmail.comwrote:
Quote:
>Here's what I have come up with so far (very basic, algorithmic
>steps):-
>- use of pointers to manipulate the deck since we will be doing a lot
>of shuffling. A link list would be a good choice with each node
>representing a card and the link list chain representing a particular
>ordering.
>
This sounds good. I'd recommend the type of linked list where you keep
track of both the first and the last element in the list. This makes
adding to the end much quicker.
>
When you're manipulating a deck of 52 cards, making append fast is not
important. An array is a much more natural data structure for this
purpose, and it's much easier to use.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

Ankur Arora
Guest
 
Posts: n/a
#8: Oct 24 '08

re: Re: Solution needed..urgent!!


On Oct 23, 11:04*pm, Pete Becker <p...@versatilecoding.comwrote:
Quote:
On 2008-10-23 16:22:52 -0400, gw7...@aol.com said:
>
Quote:
On 23 Oct, 14:51, Ankur Arora <ankuraror...@gmail.comwrote:
Quote:
Here's what I have come up with so far (very basic, algorithmic
steps):-
- use of pointers to manipulate the deck since we will be doing a lot
of shuffling. A link list would be a good choice with each node
representing a card and the link list chain representing a particular
ordering.
>
Quote:
This sounds good. I'd recommend the type of linked list where you keep
track of both the first and the last element in the list. This makes
adding to the end much quicker.
>
When you're manipulating a deck of 52 cards, making append fast is not
important. An array is a much more natural data structure for this
purpose, and it's much easier to use.
>
--
* Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)
Guys..Thanks for the tips!
A circular link list could also be considered..i think.
Stuart Golodetz
Guest
 
Posts: n/a
#9: Nov 1 '08

re: Re: Solution needed..urgent!!


Hendrik Schober wrote:
Quote:
Stuart Golodetz wrote:
Quote:
>[...]
>P.S. It's also worth noting that the question said "STL" and not
>"Standard Library". Should we take this to mean that any portions of
>the Standard Library which were not inherited from the STL are usable...?
>
Well, yeah, it would be hard to be sure the task was done
without using 'std::cout' et.al., wouldn't it?
>
Schobi
:-) I'm not sure it would be hard to be sure that you had or hadn't used
it (the find menu item works wonders here!), but it might be hard to do
the task itself without some sort of output method, yes.

Stu
Stuart Golodetz
Guest
 
Posts: n/a
#10: Nov 1 '08

re: Re: Solution needed..urgent!!


James Kanze wrote:
Quote:
On Oct 23, 3:50 pm, Stuart Golodetz
<sgolod...@NdOiSaPlA.pMiPpLeExA.ScEomwrote:
Quote:
>Juha Nieminen wrote:
Quote:
>>Ankur Arora wrote:
>>>Do not use STL.
>
Quote:
Quote:
>> Any rational reason for this?
>
Quote:
>By not allowing you to use STL, they encourage you to write
>your own classes to do the same thing - the process of
>reinventing the wheel will convey to you (a) a fair amount
>about the STL, (b) an understanding of why reinventing the
>wheel is generally to be avoided and (c) a healthy
>appreciation of the hard work put in by the people who have
>worked on the STL over the years.
>
I'm not so sure about that. Writing a simple array class which
is usable in one particular context is actually very simple.
Designing the interface so that it can be generally usable in
the widest number of different contexts is another matter, not
to mention implementing it in a manner so that it will have
adequate performance for all possible uses.
Sorry, I should have said "assuming you write containers with a similar
interface to the existing ones". I actually sat down and did it for
practice at one point (ignoring all the allocator-related stuff) and
found it quite useful.

Obviously the existing implementations have subtleties which I didn't
attempt to mimick, but I still think it's a worthwhile thing to do once
in your life (YMMV of course! :-)).

Regards,
Stu
Quote:
It's worth implementing some simple containers and algorithms
yourself, to understand the issues better, but doing so will not
help you better understand the STL.
yog.mittal@gmail.com
Guest
 
Posts: n/a
#11: Nov 7 '08

re: Re: Solution needed..urgent!!


I will really appreciate if anybody could please post the solution ?
Thanks
Closed Thread