Results 1 to 12 of 12

Thread: Stack questions

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    27

    Stack questions

    hi, i was going throught java exercise i did not get this exercise? if you know anything please post your comments here.


    Which of the following applications may use a stack?
    A. A parentheses balancing program.
    B. Keeping track of local variables at run time.
    C. Syntax analyzer for a compiler.
    D. All of the above.

  2. #2
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Stack questions

    I'd say D.

  3. #3
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Stack questions

    I agree
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  4. #4
    New Member Santa Clause's Avatar
    Join Date
    Dec 2003
    Location
    North Pole. Lapland when I visit my Wife.
    Posts
    10

    Re: Stack questions

    Quote Originally Posted by indianj
    hi, i was going throught java exercise i did not get this exercise? if you know anything please post your comments here.


    Which of the following applications may use a stack?
    A. A parentheses balancing program.
    B. Keeping track of local variables at run time.
    C. Syntax analyzer for a compiler.
    D. All of the above.
    The question is, do you know what a stck is? If not, then we can explain - then you will be able to answer the question all by yourself
    I am the real Santa Clause

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    27

    Re: Stack questions

    thanks for your answer. yes i do not stack now.

  6. #6
    New Member Santa Clause's Avatar
    Join Date
    Dec 2003
    Location
    North Pole. Lapland when I visit my Wife.
    Posts
    10

    Re: Stack questions

    You have a large number of presents and you put them together, you put one present on top of the other. This is a stack. If you try to take one of the presents form the middle of the stack, all the others will fall. So you can only take something off the top of the stack.

    A stack is referred to as a LIFO (Last in First Out) - and they are used often in programming. For example, in a program you have a calling stack, each time you call a function, a pointer is pushed (placed) on the calling stack, once the current function has finished executing, the last item on the called stack is popped (taken off) and execution resumes form the next statement in the calling function. Once the stack is empty and the current execution has finished the program ends.

    Another implementation of stacks is Reverse Polish notation, whereby a mathematical expression is represented by string. All numbers are pushed on to the stack and operators cause two numbers to be popped from the stack and a portion of the expression to be solved. Calculators and computers use these.

    So, to work out where a stack might be used think of situation where you need to store a set of data but only ever require/want the last item you put inside the store. If we use Java as an example and apply it to this statement:
    B. Keeping track of local variables at run time.
    In Java locals variables mask variables of the same name which are member of the current class. Each block in which a variable is declared masks the higher scope. So it would be sensible to assume that like the calling stack, a variable stack exists too.
    I am the real Santa Clause

  7. #7
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Stack questions

    just say B for god's sake
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  8. #8
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Stack questions

    I would use stacks in C too. especially when you are analyzing syntax which is likely to be nested. I.e: nested loops and if statements.
    Last edited by visualAd; Nov 13th, 2005 at 04:28 PM.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  9. #9
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Stack questions

    I still keep with D since I have tried all the first 3 choices and implemented them all using a stack. heck its even in the compiler book to use a stack. :s

  10. #10
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Stack questions

    I still agree with you ocean
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  11. #11
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Stack questions

    A. was in the Data structure book.
    B. was an example in system architecture book.
    C. was in the compiler book.
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  12. #12
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Stack questions

    Quote Originally Posted by ComputerJy
    I still agree with you ocean
    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width