Skip to main content

All Questions

1 vote
1 answer
129 views

What happens to the lost part of a singly Linked list when I am introducing a loop at the middle?

I have created a singly linked list, and this is how it looks after displaying it: 19-->85-->50-->20-->33-->9-->1-->7-->null I have created a method that can add a node to a ...
NV basnayaka's user avatar
-4 votes
1 answer
103 views

Segmentation fault error singly linked lists C++ [closed]

Why is this getting an error: int main(){ lista *head, *x; head = nullptr; const int len = 3; int y[len] = {13, 4, 32}; for(int i = len - 1; i >= 0; i--){ x = new lista; ...
M1001's user avatar
  • 148
1 vote
2 answers
1k views

Pointers and Pointers to pointers in a singly linked list, help me understand in C++

I'm still trying to understand pointers, drawing nodes and everything but I can't seem to understand some things. For example here is a function that should delete nodes with even values from a list ...
Klau's user avatar
  • 11
0 votes
4 answers
259 views

Delete Nodes With The Value 0 In Singly Linked List In C++

I can't for the life of me figure this out I've spent days on this exercise but to no avail. I'm trying to delete nodes with the value 0 from a singly liked list. Let's say i have |1|3|0|4|0|5|0|0|. ...
BagPulaInEaProgramareNuInteleg's user avatar
-1 votes
1 answer
56 views

Getting an error when creating two separate linkedlists in Java

I will do the addition multiplication and print operations of two separate polynomials that I will get from the user. However, when creating two linkedlists in the main class, the nodes that I added ...
anon's user avatar
  • 1
0 votes
1 answer
229 views

Why is my linked list adding nodes to the beginning of the list rather than the end?

Why is this linked list adding nodes to the beginning and how can I change it to add them to the end of the list? ` struct Node { void *function; void *caller; void *...
bscottunit's user avatar
0 votes
1 answer
160 views

C how to iterate and add a new node after a desired node in single Linked List

typedef struct ITEM { int value; struct ITEM *next; }ITEM; int add_after(ITEM *list, ITEM *c_item, int value) { ITEM *elem; //if head is NULL, it is an empty list if(c_item == NULL ...
Heroking18's user avatar
-1 votes
1 answer
128 views

Perform arithmetic on a singly linked list which represent a large number

I have a linked list which represents the large number 2253239487. class ListNode: def __init__(self, val, next=None): self.val = val self.next = next def __repr__(self): ...
meallhour's user avatar
  • 15.7k
-1 votes
1 answer
839 views

Remove the value from the linked list

Given the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head. class ListNode: def __init__(self, val=0, next=None): ...
Goyam Jain's user avatar
0 votes
2 answers
139 views

Is there something wrong with my reverse a linked list function ? It does not print the reversed linked list?

#include "bits/stdc++.h" using namespace std; struct ListNode { int val ; ListNode * next; ListNode( int c ) { val = c; next = NULL; } }; void traversal ( ...
simple navi's user avatar
0 votes
1 answer
48 views

How can I display only one list represented from the display function?

Basically I have 10 files named src(=source) and each of them has packets (named so for my homework) which are represented by roll number, dest(=destination) and gentime (=generation time). I want to ...
wajaap's user avatar
  • 269
0 votes
1 answer
156 views

Merge Two Sorted LinkedLists in Java (using the default LinkedList class, not custom class)

So I'm trying to solve the Leetcode problem (#21) of merging two sorted lists, however I'm trying to do it using the standard LinkedList class in Java (the Leetcode problem uses a custom 'ListNode' ...
TorusWithSprinkles's user avatar
0 votes
0 answers
59 views

Reversed Linked List not showing the last element

Im implementing a reversed sorted Linked list. If I print the ascending version of this linked list,it works fine but printing the reversed list does chops off the last element (last input). private ...
Blue's user avatar
  • 1
0 votes
0 answers
128 views

How can I compare a value of time with a time slot?

I am reading from a file (fp) fourplets, that represent packets and if the generation time of the packet is less than the time running, then I am inserting it in to my list. The time increases by 20.0 ...
wajaap's user avatar
  • 269
0 votes
1 answer
110 views

How can I insert a specific number of elements in a list?

I tried to insert a specific number of elements (fourplets from a struct that each of them represents a packet) in the list by using size_t n but when I run the main programm it does not display ...
wajaap's user avatar
  • 269

15 30 50 per page
1
2 3 4 5
9