Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > can a file be deleted from a stack without decrementing the TOP variable

Reply
Thread Tools

can a file be deleted from a stack without decrementing the TOP variable

 
 
srikanth
Guest
Posts: n/a
 
      03-08-2006
is it possible not to decrement the top variable after we remove(or
retreive) a file from a stack
>MY IDEA is:> if top is not decremented the stack is like it has some files existing in it with the top most file empty
>i.e, something like hiding the files by one step (or one position of stack)
>i.e,if someone tries to extract the top most file he see's that it is empty thus assumes the stack to be empty.
>can this view be applied effectively

NOTE :HERE file can be regarded as an entity (a NO. or a character or
an operator)stored in the stack.
>top is inbuilt var. used in stacks



 
Reply With Quote
 
 
 
 
Chris Dollin
Guest
Posts: n/a
 
      03-08-2006
srikanth wrote:

> is it possible not to decrement the top variable after we remove(or
> retreive) a file from a stack
>>MY IDEA is:> if top is not decremented the stack is like it has some
>>files existing in it with the top most file empty i.e, something like
>>hiding the files by one step (or one position of stack) i.e,if someone
>>tries to extract the top most file he see's that it is empty thus assumes
>>the stack to be empty.
>>can this view be applied effectively

> NOTE :HERE file can be regarded as an entity (a NO. or a character or
> an operator)stored in the stack.
>>top is inbuilt var. used in stacks


This is not an (ISO/ANSI) C question. Try comp.programming (and give
concrete examples for what you're asking).

--
Chris "sparqling" Dollin
"Who do you serve, and who do you trust?"
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      03-08-2006
"srikanth" <> writes:
> is it possible not to decrement the top variable after we remove(or
> retreive) a file from a stack
>>MY IDEA is:> if top is not decremented the stack is like it has some files existing in it with the top most file empty
>>i.e, something like hiding the files by one step (or one position of stack)
>>i.e,if someone tries to extract the top most file he see's that it is empty thus assumes the stack to be empty.
>>can this view be applied effectively

> NOTE :HERE file can be regarded as an entity (a NO. or a character or
> an operator)stored in the stack.
>>top is inbuilt var. used in stacks


This doesn't seem to be a C question.

You seem to be misusing the term "file".

">" characters at the beginning of a line are used to quote material
from previous articles.

Please read <http://cfaj.freeshell.org/google/>.

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
srikanth
Guest
Posts: n/a
 
      03-09-2006
sir i will make it simpler
>eg: let the stack be made of blocks i each block say i store one number
>eg: a stack containing

6
5
1
>now i retrieve 6 from the stack (so i have to DEC the top variable) to point to block containing 5
>****now,if i dont decrement the top the stack is like

/*empty*/
5
1
>i.e, it is like hiding 5 and 1 by one block in the stack
>my Q was can this be applied effectively


 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      03-09-2006
please leave some conext in your posts. Learn to quote properly. Listen
to what
people tell you. You have already been told '>' characters mark
previous posts.

Your post should have looked something like this
***


srikanth wrote:
> someone replied to srikanth
> > srikanth wrote:


> > > is it possible not to decrement the top variable after we remove(or
> > > retreive) a file from a stack
> > > MY IDEA is: if top is not decremented the stack is like it has some
> > > files existing in it with the top most file empty i.e, something like
> > > hiding the files by one step (or one position of stack) i.e,if someone
> > > tries to extract the top most file he see's that it is empty thus assumes
> > > the stack to be empty.
> > > can this view be applied effectively
> > > NOTE :HERE file can be regarded as an entity (a NO. or a character or
> > > an operator)stored in the stack.
> > > top is inbuilt var. used in stacks


you need to explain why you are trying to do this. You seem to want (?)
a
stack from which you can remove items and leave an empty item at the
top.
Why?

Are you describing a bug in a stack implementation or do you really
want to
do this?

Stacks normally remove the "slot" from the stack when the item is
removed.
So if you don't want empty "slots" then don't leave them on the stack.
And
if you do want them you'll need some way to indicate the slot is empty
(special value or flag).


> > This is not an (ISO/ANSI) C question. Try comp.programming (and give
> > concrete examples for what you're asking).


he's indicating this isn't a C language problem but a problem in
program design.
You can't think about writing code until you have a clear idea of what
is required
from this data structure.

> sir i will make it simpler
> eg: let the stack be made of blocks i each block say i store one number
> eg: a stack containing
>
> 6
> 5
> 1
>
> now i retrieve 6 from the stack (so i have to DEC the top variable) to point to
> block containing 5 ****now,if i dont decrement the top...


WHY would you do that?

> ...the stack is like
>
> /*empty*/
> 5
> 1
>
> i.e, it is like hiding 5 and 1 by one block in the stack
> my [question] was[,] can this be applied effectively[?]


that's your choice. If I had a good reason for hiding things from users
of the
data structure I might provide special is_empty() predicates. *You*
have to
decide what semantics your DS must have. Is a stack empty when its
top slot is empty? Can you remove from a pseudo-empty stack?
Can you add? How do you restore the stack to its usual semantics?

By all means play around with these things but if you provide DSs with
poorly defined semantics your program will behave badly. ie. crash,
destroy data, detonate the cruise missile etc.


--
Nick Keighley

 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      03-09-2006
Nick Keighley wrote:

(in replying to srikanth)
>
> please leave some conext in your posts. Learn to quote properly.
> Listen to what people tell you. You have already been told '>'
> characters mark previous posts.


He has been told this many times, and just ignores it. The only
thing left is to plonk and ignore him.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C/C++ compilers have one stack for local variables and return addresses and then another stack for array allocations on the stack. Casey Hawthorne C Programming 3 11-01-2009 08:23 PM
decrementing arrays Bill Cunningham C Programming 77 06-25-2008 05:52 PM
Decrementing of reference count of new objects? Mitko Haralanov Python 0 04-01-2008 09:49 PM
Writing a incrementing/decrementing function with roll-over pozz C Programming 10 07-14-2006 12:49 PM
Incrementing/decrementing for speed J. Campbell C++ 6 08-19-2003 02:48 PM



Advertisments