473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Explain this


This is an interview question asked in Robo.
How the memory address moves in Heap and stack?
That I knew it, Heap upper to lower and in stack lower to upper.

Then the next quotation was why?

(I need answer to this question)
I told them that, this is because sack keep on growing and the latest
record must be retrieved so it is like that. But I don't think it is
the right answer to that question. Can any one tell me the answer to
this question?
What is the diamond problem in C++?
Data structure used to implement snake and ladder game?


Aug 17 '05 #1
4 1776
> This is an interview question asked in Robo.
How the memory address moves in Heap and stack?
That I knew it, Heap upper to lower and in stack lower to upper.


This is not correct. It depends on the platform. For example, on a
HP-UX (PA-RISC architecture) stack grows lower address to higher
address while on Intel x86 platforms the stack grows from higher to
lower addresses.
Then the next quotation was why?

(I need answer to this question)
I told them that, this is because sack keep on growing and the latest
record must be retrieved so it is like that. But I don't think it is
the right answer to that question. Can any one tell me the answer to
this question?


This would be best answered in a newsgroup of the relavant platform.
What is the diamond problem in C++?


Diamond inheritance.

class Base_Class {
// ...
};

class Derived_L : public Base_Class {
// ...
};

class Derived_R : public Base_Class {
// ...
};

class Most_Derived : public Derived_L, public Derived_R {
// ...
};

In the inheritance heirarchy given above, the "Most_Derived" class
would have 2 copies of the "Base_Class". This is overcome by virtual
inheritance from Base_Class.

class Derived_L : virtual public Base_Class {
// ...
};

class Derived_R : virtual public Base_Class {
// ...
};

Srini

Aug 17 '05 #2
Thanks for your replay. Really it great to know some thing more about
my problems.

But I am still not clear why is so question . Can any one make it more
clear .

Aug 17 '05 #3
> Thanks for your replay. Really it great to know some thing more about
my problems.

But I am still not clear why is so question . Can any one make it more
clear .


It is probably caused by operating systems that do not have virtual memory
management.
You can have the heap start at the bottom of memory and the stack at the
top. When those two meet, then you are out of memory.
If they would grow in the same direction, you would have to preallocate an
amount of memory for each and one of them would run out of memory before all
memory had been used.

Niels Dybdahl
Aug 17 '05 #4

Srini wrote:
This is an interview question asked in Robo.
How the memory address moves in Heap and stack?


That I knew it, Heap upper to lower and in stack lower to upper.


This is not correct. It depends on the platform. For example, on a
HP-UX (PA-RISC architecture) stack grows lower address to higher
address while on Intel x86 platforms the stack grows from higher to
lower addresses.


I think a better, and more portable answer would have been "They
usually grow in opposite directions".
Then the next quotation was why?

(I need answer to this question)
I told them that, this is because sack keep on growing and the latest
record must be retrieved so it is like that. But I don't think it is
the right answer to that question. Can any one tell me the answer to
this question?


This would be best answered in a newsgroup of the relavant platform.


Since the stack is a contiguous, growable area of memory and the heap
uses non-contiguous allocation of memory in blocks, it is important to
keep the heap allocations as far away from the stack for as long as
possible, just to stay out of its way. Having its stack encroach upon
the memory of one of its allocated blocks, is a fatal error for an
executing program.

Greg

Aug 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bruce D | last post by:
I'm trying to understand MySQL better. I can't seem to figure out why the second query takes 2 minutes and the first query takes 12 seconds. It should be noted that the table, KBM, has 250...
14
by: Ina Schmitz | last post by:
Hello all, I don't succeed in displaying the explain plan. I use IBM DB2 Universal Database 8.2. I tried to do the example given in the online help for "Visual Explain". The tables...
10
by: Jeff Boes | last post by:
I'm hoping there's someone here with experience in building the Visual Explain tool from Red Hat. I downloaded it and the J2 SDK, but when I attempt to follow the build instructions, I get messages...
5
by: Jon Lapham | last post by:
I have been using the EXPLAIN ANALYZE command to debug some performance bottlenecks in my database. In doing so, I have found an oddity (to me anyway). The "19ms" total runtime reported below...
2
by: Dan Sugalski | last post by:
Is there any way to convince explain to go do its thing when given a query with placeholders in it? I'm trying to do some performance checking of some of the queries built into a system I'm...
4
by: marklawford | last post by:
Not having earned my DBA badge from the scouts just yet I'm a little lost with an error I'm getting. We've just upgraded our development database from 7.2 to 8.2 as the first step in upgrading...
2
by: heming_g | last post by:
two tables with the same table structure : tb_xxx and tb_xxx_tmp in table tb_xxx , column "listno" is the primary key of itself and foreign key of dozen of tables . here is my sql .. "...
0
by: dataguy | last post by:
I have my developers explaining the stored procedures that they write using visual studio. These stored procedures are for DB2 os390. In one case, one of the developers has defined a global...
5
by: kabotnet | last post by:
Hi, I'm new in db2, I'm trying to execute EXPLAIN command on some queries but i have error like: And message similar to: Token EXPLAIN is not valid, valid tokens ( END GET SET CALL DROP FREE...
1
by: w.l.fischer | last post by:
Hi, the following sequence: set current explain mode yes; set current explain snapshot yes; update ...; set current explain mode no;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.