All Questions
Tagged with singly-linked-list stack
53 questions
1
vote
1
answer
72
views
valid Parenthese using stack in c
I was solving the problem 20. Valid Parentheses in Leetcode using c and when they check this input s ="{[]}" the code returns false instead of true but I don't see any problem with the code:...
0
votes
2
answers
52
views
Created function that pops the last value entered in the stack fails after second popping
struct n {
int data;
struct n* next;
};
typedef struct n node;
node* push(node* s, int x) {
node* temp;// temporary element
temp = (node*)malloc(sizeof(node));
if (temp == NULL) {...
0
votes
1
answer
62
views
Removing alternate sections of a singly linked list where each node points to two objects
I'm working with a Singly Linked List with nodes of type Segment, and each segment points to a position and a color. My list describes a caterpillar, so I want no discontinuities - i.e. if I remove ...
1
vote
1
answer
58
views
Code that gives an error that is not deleted when there is no element in the list on stack in C language
When I call the pop function with an empty list, it correctly outputs the "Stack is empty." message. However, after I add two elements to the list with two push function calls and then call ...
0
votes
2
answers
557
views
How to insert nodes into list by looping?
How to Implement in right way to store values into linked list? In this example the last element will be "0" . Is there a possible to write the content of while loop that allows me don't ...
0
votes
1
answer
94
views
Linked list is not displaying properly
For my assignment, I have to create a singly headed singly linked list of characters using a stack. I have created a class called Stack which contains "StackNodes" as private members. The ...
0
votes
1
answer
745
views
"AttributeError: 'LinkedList' object has no attribute 'next'" when trying to pop a None value in a Stack using a Linked List in Python
Hey I'm trying to implement a pop function in my Stack. It works as long there are elements in the list. After that this error "AttributeError: 'LinkedList' object has no attribute 'next'" ...
0
votes
2
answers
136
views
How implement the removal of elements with even numbers from the created stack?
How implement the removal of elements with even numbers from the created stack? Here is the code. I'm not well versed in this topic yet. I ask for help.
I need to implement the removal of elements ...
0
votes
2
answers
55
views
Missed Print Line
I am trying to print the program so it will look like this.
Inserting 1
Inserting 2
Inserting 3
Top element is 3
Removing 3
Removing 2
Removing 1
The stack is empty
But when I run the program, I ...
-1
votes
1
answer
170
views
Can I do a peep operation at any position in stack using linkedlist in the c language?
All my stack operations are working well except peep operation at any given position. My code is terminating automatically.Please check my code.
void peep()
{
if (top==NULL)
printf ("...
1
vote
1
answer
617
views
C++ STL stack vs forward_list
I have a use case where I need to store some amount of uint16_t variables in no particular order (although the actual type of variables is not relevant). I have decided to turn to the STL to look for ...
-1
votes
1
answer
79
views
Print stack or row in different ways with same function in Python
My task is to print Stack and Queues in different ways.
I implemented Stack with single linked list and Queue with double linked list.
This is main function where I push elements into Stog(Stack) and ...
0
votes
1
answer
215
views
parenthesis matching in python using stack
I am trying to use stacks to check parenthesis, but the following code cannot output the right result; after checking it several times, I still cannot find the mistakes; any hint or help is ...
0
votes
0
answers
50
views
Infix to Postfix using C stuck execution after halfway. Can any one tell me why?
I've been trying implementing Infix to Postfix using Stack(using LL) in C Language. When I first executed the code with input like(e.g: a+b/c*d-e) it's showing the correct notation from infix to ...
0
votes
1
answer
50
views
free() function does not clear well my stack
Sorry if my code and also English are a bit sketchy.
I am currently trying to print and deallocate the space in which my stack structs were stored with a function which the prototype is void ...