Hi Friends, Recently I've experienced an issue in my (following) code. I've designed an array-stack and checked the values pushed in to it. It works well when pushing but when popping it doesn't display the whole popped values. E.g: If I pushed the values "zero to nine" in to the stack, even though they are pushed successfully, their popping displays only "nine to five". Why it behaves like this? Could anyone suggest a solution for this? #define MAX 10 #include <stdio.h> #include <stdlib.h> struct stack{ int stackSize; int items[MAX];}; void push(struct stack *sp, int newItem){ if((sp->stackSize)<MAX){ sp->items[sp->stackSize++]=newItem; printf("Pushed %d\n",newItem); } …

Member Avatar
Member Avatar
+0 forum 3

Hi guys, Here is the question: I have Activity A, Activity B. Now, A --> B . Now, pressed the home button. Now, go to any image & "open with" will show my app. when pressing my app as the option, it will hit Activity A. When it will hit A, intent is handled in this activity. At this stage, A & B are already in the stack. I want to discard all the activities except A. I have done it by restarting the activity using CLEAR_TASK intent (basically a restarter). But problem comes when my app was not opened …

Member Avatar
+0 forum 0

I'm referring to my snippet [Inheriting the stack class](https://www.daniweb.com/software-development/csharp/code/498828/inheriting-the-stack-class) After looong loong searches and many tries and tests, I finally came up with a version that works as I wanted to. Stacker can now handle any type of object, even with arethmetic methods in place. The virtual way as proposed by JOShealV would work as well, but then you had to derive from Stacker and do some overriding. Still two questions though: 1-- How should I handle nullable value types? 2-- What could be returned by the arithmetic methods? Nothing like now, should I throw an exception? Any suggestions more …

Member Avatar
Member Avatar
+0 forum 3

Inheritance with generic types can sometimes be tricky. If you would inherit from a Stack<double>, no problem, but what if you want to keep it as generic as possible? Maybe it's a bad idea, but I wrote something like `class Stacker<T> : Stack<T>` and in Stacker I implemented some arithmetic methods like divide now if T is a double, all is well, but if T is a Person class? To divide two Persons would be hard to do. So our smart C# compiler does not let you use arithmetic operators here. This means T + T or T / T …

Member Avatar
Member Avatar
+1 forum 7

Im trying to implement queue with a linked list i think i have the enqueue function correct but im having problems with the dequeue. I can get it to delete the first number but then the rest of the list is empty can someone point me in the right direction? #include <stdio.h> #include <string.h> #include <stdlib.h> //Structure node struct _node { int num; struct _node * next; }; //type definitions typedef struct _node node; typedef node * link; //Structure list struct _list { link top;//points to node structure link bottom; }; //type definition typedef struct _list list; typedef list * …

Member Avatar
Member Avatar
+0 forum 4

how can I implement stack with one queue? the queue only can enqueue and dequeue

Member Avatar
Member Avatar
+0 forum 10

hey there i find it difficult to write pseudocode of two stacks that sum two binary numbers and print the answer i can use a third stack for help. for example S1 is 11001110 and S2 101010 the answer will print 11111000 please help me with that

Member Avatar
Member Avatar
+0 forum 4

Consider a stack module like (two files stack.h stack.cpp) which supports the these functions; void push (stack *, std::string); std::string & pop(stack &); bool isEmpty(stack &); std::string & top (stack *); I didnt understand this part what it means. Also I declared stack like; struct stack { … }; But with these functions, can i write this module without class?

Member Avatar
Member Avatar
+0 forum 9

Hi guys , I'm giving you the full C# project I have uploaded , since I'm working with windows form , so you can see the source code and run it . http://www.sendspace.com/file/u7z6h0 And now , to explain my problem . The program I wanted to make is sudoku solver . Now , It's something I'm only making for fun , so if you think it's going to take you too much time to help me , do not give yourself a hard time , it's enough that you even read this post . Now , in this code , …

Member Avatar
Member Avatar
+0 forum 4

|29|error: expected unqualified-id before ‘{’ token| |27|error: new types may not be defined in a return type| |27|note: (perhaps a semicolon is missing after the definition of ‘DynStack<T>::StackNode’)| 46|error: ‘StackNode’ does not name a type| ||In member function ‘DynStack<T>::StackNode DynStack<T>::StackNode(T, DynStack<T>::StackNode*)’:| |40|error: ‘value’ was not declared in this scope| ||In constructor ‘DynStack<T>::DynStack()’:| |51|error: ‘top’ was not declared in this scope| ||In member function ‘void DynStack<T>::push(T)’:| |67|error: ‘top’ was not declared in this scope| |67|error: expected type-specifier before ‘StackNode’| |67|error: expected ‘;’ before ‘StackNode’| ||In member function ‘void DynStack<T>::pop(T&)’:| |74|error: ‘temp’ was not declared in this scope| |77|error: expected ‘;’ before …

Member Avatar
Member Avatar
+0 forum 1

Hello, I have learnt a few assembly languages (MIPS/x86/ARM/MIX) and I have a question about the call stack. Each of those languages uses a different method for subroutine linkage, and the way I learnt them was not conducive to recursion. Granted, if I continue reading my copy of The Art of Computer Programming Knuth claims that he will explain how to do it, however the way he writes I will have to understand everything before that point which will be awhile. I am impatient. As such I would like to know, in a generic language, how does one implement proper …

Member Avatar
+0 forum 0

I need a help in generating ideas to create a program using stack+queue. Real life example of stack+queue is needed. Pleaseeeee?

Member Avatar
Member Avatar
+0 forum 1

hello! im trying to make my own stack program in c++. but my code doesnt seem to work. I got 6 errors, been trying to figure out what are those and how to solve it but theres no progress. Can somebody help me with my project. I would greatly appreciate any help please? by the way here is mycode.. http://pastebin.com/1bzr1MhZ

Member Avatar
Member Avatar
+0 forum 5

Hi, I've been testing about converting infix to postfix expression. I've made the code and it compiles. My problem is it stops working when I run it. This involves the use of stack and arrays. I just call the method polish to get the strings infix and postfix, and to run the other methods, like findRank to know if it is a well formed postfix exp'n and evaluate it in method evaluate(). Please give me some ideas on how to fix this. This is the code... /* From Infix Notation to Postfix form, Knowing if it is Well-Formed, and Evaluation …

Member Avatar
Member Avatar
+0 forum 3

Hi, i need to program this algorthim using 2 stack in java, for example to evaluate such a given valid infix expression : (5*3)+(4/(6-2)). i need help, i don't know much about stacks.. Create two empty stacks, one for operands, and one for operators. Read infix expression as a string ; while(there are more tokens in the string){ if(current token is an operand) push token in the operand stack; else if(current token is an operator){ push token in the operator stack; else if (current token is a left parentheses) ignore else if (current token is a right parentheses) { operand1 …

Member Avatar
Member Avatar
+0 forum 6

#include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> #define size 400 using namespace std; char infix[size],postfix[size],Stack[size]; int top; int precedence(char ch) { switch(ch) { case '^':return 5; case '/':return 4; case '*':return 4; case '+':return 3; case '-':return 3; default:return 0; } } char Pop() { char ret; if(top!=-1) { ret=Stack[top]; top--; return ret; } else return '#'; } char Topelem() { char ch; if(top!=-1) ch=Stack[top]; else ch='#'; return ch; } char Push(char ch) { if(top!=size-1) { top++; Stack[top]=ch; } } int braces(char* s) { int l,r; l=0;r=0; for(int i=0;s[i];i++) { if(s[i]='(') l++; if(s[i]=')') r++; } if(l==r) return 0; else …

Member Avatar
Member Avatar
+0 forum 5

i have written many programs using stack , but how do i write a program to find whether the stack is progressing in forward or reverse direction . ?

Member Avatar
Member Avatar
+0 forum 2

I am trying to write several different sorting algorithms in order to time the differences between them when reading a file of a half million integers. For testing purposes, I am only using a few hundred integers, but I am getting a stack overflow error. Also, for testing reasons, I have an output file being created during this run so that I can see if the code is working correctly. Originally, I had 3 nested for loops that I believed were causing the errors (and horrible effeciencey), but I cleaned those up and I am still having the error. Can …

Member Avatar
Member Avatar
+0 forum 4

I want to know how I can implement a function to open a file and read its contents into a linked list, and then print the contents reversed #include <stdio.h> typedef struct stack { char b[100]; int top; }stack; void push(stack *s,char k) { if(s->top==99) printf("\n Stack is full "); else s->b[++s->top]=k; } char pop(stack *s) { char c; if(s->top==(-1)) printf("\n Stack is empty"); else c=s->b[s->top--]; return c; } void main() { char name[100]; stack s; system("clear") ; s.top=-1; printf("\nEnter name :"); gets(name); int i=0; while(name[i]!='\0') { push(&s,name[i]); i++; } printf("\n Reverse string is :"); while(s.top!=-1) { printf("%c",pop(&s)); } getchar(); …

Member Avatar
Member Avatar
+0 forum 4

I am trying to change the order of the stack using z-index. as my HTML, CSS and javascript function show in the code below. The three tables are all read into the same location, with only the last table being printed on the screen, since all tables use a white background. I am calling onMouseOver() and want to change the z-index to pop that table to the top of the stack. The code below is not changing the z-index, what am I doing wrong? Thanks for any help. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <title>table …

Member Avatar
Member Avatar
+0 forum 2

I need help with implementing grow and shrink Here is the actually instructions---> •grow(). This method, when called, will “grow” arrayStack by utilizing the strategy outlined in 2 above. This method will only be called by push(). Note that grow() should be private. •shrink(). This method, when called, will shrink arrayStack by utilizing a strategy similar to that outline in 2 above. This method will only be called by pop() and will only be executed when the “occupied” part of the array is less than or equal to half the size of arrayStack. Note that after a call to shrink, …

Member Avatar
Member Avatar
+0 forum 5

Hello, Would someone be willing to take a look at this segment of code? I am trying to figure out how this segment of code operates. I can see how the program can evaluate a simple prefix statement like + 7 6. I cannot see how the program can solve a statement like + + 7 6 + 5 4. I've inserted some print statements in order to see what the program is doing and it is showing a = 7, b = 6, a = 13, a = 5, b = 4, b = 9, (22 = total). I …

Member Avatar
Member Avatar
+0 forum 3

Hello Friends, I am having trouble with a homework assignment and was wondering if you would please take a look at it for me. I have to write a program that receives a prefix expression. Then it calculates and displays the result. It does this by using a stack to store values of sub-expressions as they are computed, and another stack to store operators that have not yet been applied. Does this mean that I have to have a stack for the results of the subexpressions and then a stack for each subexpression that has not been solved yet? So …

Member Avatar
Member Avatar
+0 forum 2

Hi, Can anyone tell me how to create a class in C++ such that, the instance of that class cannot be created on stack? Am not able to figure out how to do it. Thank-you in advance, Sri

Member Avatar
Member Avatar
+1 forum 2

For this assignment due **3/4/2013**, I have to write a program to read in and evaluate a post fixed expression. I also have to print out the expression read in followed by the results of the evaluated expression (while handling the add, subtract, and multiply operators) and handle multi digit numbers. The expressions I'm using are in the textle is PostFix.txt, which I've attached to this article so you can look at it The thing is that I can't use stacks in my code. Instead I have to use functions to act the same way as stack member functions. I …

Member Avatar
Member Avatar
+0 forum 4

Hey everyone, I'm new to the concept of stacks and queues. I think I have the basics, but I have a quick question. If I am wanting to swap an object, say x, for another object, say y, in a stack or a queue, is this possible without introducing an array to store the objects? Am I missing someting fundemental about the ADTs? Thank you!

Member Avatar
Member Avatar
+0 forum 1

I have datatable looks like below: ![table2](/attachments/large/3/table2.JPG "table2") I want to create a stack chart that will produce something like this: ![stack2](/attachments/large/3/stack2.JPG "stack2") I don't know where to start. I have google about how to create stack column but still can't get it. So far I have a chart but mcname not include (only have LINENAME at X-Axis, DURATION at Y-Axis and Count (As Frequency) at Secondary Y-Axis) ![chart12](/attachments/large/3/chart12.JPG "chart12") This is my chart code: ' Setup the chart With Chart1 .DataSource = grpTot ''Datatable name .Legends.Clear() .ChartAreas.Clear() .BackColor = Drawing.Color.Linen .ChartAreas.Add(New ChartArea("Fred")) With .ChartAreas("Fred") .AxisY.LabelStyle.Format = "HH:mm:ss" .AxisY.Minimum = …

Member Avatar
Member Avatar
+0 forum 4

Hi, Please help me debug this code. I made a Stack template with two parameters: type and size. I am using it two times: first in conversion from infix expression to postfix (here, <char,50> stack is used), then in evaluation of postfix expression (here, <long double, 50> stack is used). There is an error while using 2nd stack. how to debug it. #include <iostream> #include <cctype> #include <cmath> using namespace std; template <class T,int size> class Stack { private: int top; T *nodes; public: Stack (); int empty (void); void push(T &); T pop(void); T pop(int &); ~Stack (); }; …

Member Avatar
Member Avatar
+0 forum 4

**my code should check if the Entered string is a palindrome or not** // stack.h typedef char comp; struct nodetype; typedef nodetype* nodeptr; class stack{ public: stack(); bool isfull()const; bool isempty()const; void push(comp elm); void pop(comp& elm); ~stack(); private: nodeptr top; }; /******************************************** stack.cpp */ #include<iostream> #include"stack.h" #include<cstddef> #include<cstdlib> #include<cstring> using namespace std; struct nodetype { comp data; nodeptr link; }; stack::stack() { top=NULL; } bool stack::isempty()const { return top==NULL; } bool stack::isfull()const { nodeptr temp=new nodetype; return temp==NULL; } void stack::push(comp elm) { if(isfull()) cout<<"No space ...!"<<endl; else { nodeptr newptr=new nodetype; newptr->data=elm; newptr->link=top; top=newptr; } } void stack::pop(comp& …

Member Avatar
Member Avatar
+0 forum 1

Below is the ip_options_build() in linux kernel 3.4, line 51 and 52: 51 if (opt->srr) 52 memcpy(iph+opt->srr+iph[opt->srr+1]-4, &daddr, 4); I understand that the two lines say, if source routing option is present, copy the destination address to the end of the option, that suggests that iph[opt->srr+1] is the length of the source routing option, but I don't get it why? Thanks! 31/* 32 * Write options to IP header, record destination address to 33 * source route option, address of outgoing interface 34 * (we should already know it, so that this function is allowed be 35 * called only …

Member Avatar
+0 forum 0

The End.