Похожие чаты

Please can anyone help me with this: so i was trying

to learn data structures and i was at this stack implementation
class Stack {
int top;

public:
int a[MAX]; // Maximum size of Stack

Stack() { top = -1; }
bool push(int x);
int pop();
int peek();
bool isEmpty();
};

and it says top=-1 , so does it mean Base Address of your Array a + (-1 * size of(data type for array a))

but what if that address has a char and not an integer?

3 ответов

21 просмотр

Nah, the -1 signifies your stack is empty and that's just a convention everyone follows

you have just implemened stack of integers. implement stack of bytes then all types are equal.

Похожие вопросы

Обсуждают сегодня

лучше скажите, причём тут паскаль?
Alexey Kulakov
36
@marycamacho @NATHANLENAE @popachubby It was said that HOT will be used for hosting payments. But HOT is ERC20 based. So slow and high paying. The ERC network does not seem ve...
Aragorn
14
Добрый вечер. Хочу чтобы у меня в классе поле было функцией, которая возвращает строку. Делаю так: interface ... TGetOutPath = function : String of object; ... protec...
Kirill Filippenok
12
Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
Bitcoin will probably halt around here somewhere to let alts push a bit?
Neo Smitty
16
Another way to think about it is like this: let's say we sell $100m of FXB2029 and another $100m of FXB2055 and we buy $200m of ETH with it. Do you think that ETH price will b...
Sam Kazemian ¤⛓️¤
20
Это может быть все-таки не флудвейт? у меня ботфазер принимает изменения и отображает даже что они изменились, на видео видно что он прислал якобы уже измененное описание, н...
OVERLINK
13
Say them all. Bitcoin > $91000 means there is no more altcoin. Institutions will buy only Bitcoin. But for a regular human, Bitcoin is a risky asset since it can be easily b...
Rr3ttt5
5
Hello guys! With whom i can talk about nodes?
Moon
17
I just don't understand why they're not responding again... this is a page that shouldn't be publicly available right now and did devops make a mistake by not protecting it wi...
CryptoBoy1007
11
Карта сайта