Skip to main content

All Questions

1 vote
2 answers
54 views

How to avoid getting garbage values while inserting a new node after a given node in singly linked lists?

I was restricted to using only one way of inserting a new node after a given node and implementing the linked list. I was getting a garbage value in my output. I'm not clear on how I can resolve this ...
dev0419's user avatar
  • 73
0 votes
0 answers
64 views

Segmentation fault in C program and stops running further

I am trying to run a link list program in C using Visual Code but after running it, it is giving me a segmentation fault error. Additionally, it gets stopped on running code. Code: #include<stdlib....
Prajwal Dhage's user avatar
1 vote
2 answers
653 views

Why nested structure is needed in singly linked list?

I'm new to data structures and algorithms. Right know I'm learning singly linked lists and I'm confused with a piece of code that creates a linked list. #include<stdio.h> #include<stdlib.h>...
Roshan Ojha's user avatar
-1 votes
1 answer
44 views

How can I fix this linked list output?

#include <stdio.h> #include <stdlib.h> struct node{ int sayi; struct node* sonraki; }; struct node* baslangic=NULL; struct node* olustur(int sayi){ struct node* yenidugum=(...
Azqaf's user avatar
  • 17
0 votes
1 answer
96 views

A function in C that adds a node at the end of a singly linked list is not working

I just wrote a function in C that is supposed to add a node at the end of a linked list, but when I compiled the program, I got nothing in the console. Here is the body of the function : void addAtend(...
CoderCat's user avatar
1 vote
2 answers
4k views

Incompatible types when assigning to type 'struct node *' from type 'struct node'

I have written a code to insert a node in Singly Linked List. But it keeps giving me error: incompatible types when assigning to type 'struct node ' from type 'struct node' void insert(int d, int pos) ...
Vansh Chaudhary's user avatar
0 votes
1 answer
39 views

Can't figure out why I am getting a segmentation fault when I try to append to the end of a linked list

I'm trying to practice and get comfortable with linked lists so i made this program to try to create nodes and add to the end of a linked list as it takes in data. Everything work until it gets to ...
breakthatbass's user avatar
0 votes
1 answer
426 views

How to delete Nodes in linked list with zero value in c

I'm using codeBlock and i'm trying to delete all the nodes with zero value at first i deleted the head nodes until there is no zero value in head like that void exo6(Node* head) { Node* p=(...
Aymen Mellah's user avatar
-1 votes
1 answer
1k views

Linked list - AppendLastNToFirst (C++), I have written only the logic for the problem. Please tell me the correction

Given a linked list and an integer n, append the last n elements of the LL to front. Indexing starts from 0. You don't need to print the elements, just update the elements and return the head of ...
John_Bradely's user avatar
2 votes
1 answer
1k views

How to count number of nodes in a linked-list ?Why does the output show the count of nodes as '2'?

I have written a c program to find the number of nodes in a link list. But the problem arises because the value of count that I am printing comes out to be '2'. My exact output looks like-> NUMBER ...
Kritin's user avatar
  • 115
0 votes
2 answers
424 views

Why do we use node* instead of just saying node when initializing a root for the linked list?

Let's say we have these kind of code for the linked list: #include <stdio.h> #include <stdlib.h> struct node { int data; node* next; } The code above makes sense as it has a pointer to ...
Nimbostratus's user avatar
1 vote
1 answer
54 views

my implementation of linked list doesn't print out anything

I have implemented the linked list in the code below but it doesn't print out anything. in the code I have add 3 nodes. someone please tell me where I am wrong. thanks for your help. #include <...
Becker's user avatar
  • 301
0 votes
2 answers
173 views

How do I avoid a segmentation fault while inserting nodes into a singly linked list?

The nodes get inserted when I insert them in order on the console How do I make sure that I take care of all boundary conditions? For example, what if the user enters a position greater than the size ...
user avatar
1 vote
2 answers
96 views

Why the elements of the linked list is not showing after changing the return type of the functions create_ll and display from struct node* to void?

I have written a linked list program and want to perform the operation of creating the linked list and displaying the elements of the list. As per the before code the create_ll and display functions ...
ANIKET ROY's user avatar
-2 votes
1 answer
85 views

Copying specific values between structs

Using C++ and not using STL containers' functions, I am trying to copy values from one struct to another in a specific fashion. I have such struct (singly-linked list), and this is how I add new ...
weno's user avatar
  • 866

15 30 50 per page