1,844 questions
1
vote
3
answers
113
views
Is this doubly linked list function implemented correctly?
I was watching a youtube video on doubly linked lists in C. One of the functions made for the doubly linked list was an "insert_after_node" function, which as the name suggests inserts a new ...
1
vote
1
answer
56
views
Im implementing a python dict. I´m using a doubly linked list, it works until the first resize. How can I change my resize method to make it work?
When inserting the first 8 pairs of keys and values it works perfectly fine and the order is maintained, the problem comes after the resizing. If I insert the pairs (4,4),(5,5),(6,6),(7,7),(1,1),(2,2),...
-2
votes
1
answer
55
views
Print the contents of a Doubly Linked List [closed]
I am trying to print the contents of a Doubly Linked list using the str method by converting the content into string. The problem I face is that it returns the memory location of the values, not the ...
-1
votes
1
answer
53
views
Bubble sort on Doubly Linked List not working
I have been doing DSA lately on python, this time tried bubble-sort algorithm on a doubly linked list.
Unfortunately, the method is not giving proper result.
Please correct me, tell me where I am ...
1
vote
2
answers
92
views
How to Initialize the tail pointer in a Doubly Linked List for it to not give Segmentation Fault
Now I have created a loop to make 25 nodes for the doubly linked list. By Initializing head pointer as NULL in the main function, now the forward_traversing and show_first functions do work as ...
1
vote
1
answer
142
views
How to insert data into Doubly Linked List using for loop in C
I made a Doubly Linked List, but instead of manually assigning the values (10, 20, 30) I want to make a for loop and put the data that way to make it efficient.
I did it in Singly Linked List but the ...
0
votes
1
answer
110
views
AddLast adds to the head of the doubly circular linked list intead of the tail in Java
I have this homework where I need to create a doubly circular linked list for a Music Player UI. I wrote the addFirst method and it works fine but when I create the addLast method I seem to not be ...
0
votes
2
answers
136
views
Why is there a trailing zero at the end of Doubly-Linked Circular Linked List in C++? [closed]
I have a Data Structure problem regarding a doubly-linked circular list in C++.
I've implemented a doubly linked circular list using class templates. When testing the circular nature of the list by ...
2
votes
3
answers
159
views
Deleting selected element in a doubly linked list [duplicate]
I have written a code on deleting a node by comparing its data from the data given. If equal, it deletes the node. My problem is that my code will delete every node in the list except the last node, I ...
1
vote
3
answers
148
views
Head keeps getting set to NULL
I made a doubly link list and ran it a couple times with functions to add nodes at end, output the length of the list and to print all the elements.
It was working fine.
Then I made a function to add ...
0
votes
0
answers
98
views
Why am i getting a segmentation fault in a code for checking palindrome using linked list?
The statements for my questions are:
Write a program to determine whether a linked list is a palindrome or not.
**Input Format:
**
The first line contains integers separated by spaces representing the ...
3
votes
1
answer
145
views
Why prefer DoubleLinkedList instead of queue and hashmap to design Least recently used (LRU)?
I am solving leetcode LRU design problem - Leetcode LRU:
Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.
Implement the LRUCache class:
LRUCache(int ...
0
votes
1
answer
188
views
Why does my double-linked list display the numbers in reverse order, except for the first added number?
I wrote this code where you can add or remove numbers from a list, and then display the list. The problem is: it displays the numbers in reverse order, except for the first added number.
program ...
0
votes
1
answer
60
views
How to print a Doubly Linked list?
I can't figure out why my print functions won't work.
It seems that when i create objects of the list they do not point at each other as expected.
Somehow when those objects are created they will ...
0
votes
1
answer
86
views
Reversing a Doubly Linked List in Rust
I have the following implementation for a Doubly Linked List ->
struct Node<T> {
value: T,
next: Option<Rc<RefCell<Node<T>>>>,
prev: Option<Weak<...
0
votes
1
answer
57
views
Print Linked List in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct data{
char help[5];
struct data *next;
struct data *prev;
}*head = NULL, *tail = NULL, *curr = NULL, *...
0
votes
1
answer
265
views
AttributeError: 'NoneType' object has no attribute 'next'; looked through multiple articles with the same error
I created a simple Doubly Linked List, with an append method and a str() that is supposed to return the elements present in the list.
Here is the code;
class Node:
def __init__(self,val):
...
0
votes
0
answers
41
views
Ran on an MCU (STM32F1), doubly-linked list code results in a call of HardFault() due to stack overflow
So there is code that is supposed to poll a GPIO read pin at a certain rate and put the SET/RESET result to a doubly linked list of 16 elements, deleting the first added (firstIn) element. formArray() ...
-3
votes
1
answer
94
views
Doubly-Linked Lists in Java [closed]
I am a freshman in IT and we did a quiz about linked lists and one of the questions was:
Linked List. Show the resulting list (redraw) after the following statements are executed.
So we have a doubly ...
2
votes
2
answers
285
views
How would you shuffle a doubly linked list?
Im trying to shuffle a doubly linked list without changing it's pointers. So far my idea to do this is to have a position integer value that gets assigned randomly to each struct in the doubly linked ...
-1
votes
1
answer
73
views
Segmentation fault in overloaded input operator in CPP
I am trying to import a book by prompting the user to provide its details in the command line one after another. For that I am using an overloaded input operator but when trying it out it results in a ...
0
votes
0
answers
21
views
How to Use a Function That Requires a Pointer Argument When Only Having the Name of the pointer?
I'm working with structures in C where I've defined a doubly linked list and a function to add elements to the left of the list (list_add_left). The problem I'm facing is that I only have the name of ...
0
votes
1
answer
141
views
Doubly Linked list Insertion
I made a program to insert a element in doubly linked list given below(ignore create and display functions
Which was working perfectly right till it found the index to be inserted is 5 ,where it fails ...
0
votes
1
answer
103
views
Where did I go wrong with my unsafe doubly linked list?
use std::{mem, ptr};
pub struct DList<T> {
dummy: DNode<T>,
}
struct DNode<T> {
data: T,
next: *mut DNode<T>,
prev: *mut DNode<T>,
}
impl<T> ...
0
votes
1
answer
120
views
Managing Hospital Data with C# and Doubly Linked Circular Lists: Issue with Patient Information Output Display
This code aims to create a hospital data management application using doubly linked circular lists. It can be divided into two main parts:
Classes:
The Patient, Medicine, Doctor, and Disease classes ...
1
vote
1
answer
111
views
I am having problem reversing doubly linked list
I am learning linked lists and was doing a question which asks you to reverse a doubly linked list. My code works perfectly fine but I don't understand how. You can ignore whole thing except the ...
0
votes
1
answer
328
views
How to create an efficient immutable tree, with parent pointers
I'm constructing a "scenegraph", which is a hierarchical data structure of Shape nodes (e.g. sphere, cube, mesh, etc. not shown in example code). A Shape can own zero or more child Shape ...
0
votes
2
answers
78
views
Why can't I use head directly in this linked list problem instead of initializing and using ptr?
I was going through this solution for implementing a doubly linked list when I came across this doubt
public class Solution
{
public static Node constructDLL(int []arr) {
Node head = new ...
0
votes
1
answer
39
views
How to fix error in doubleLinkedList java code where when adjacent nodes are inputted to switch the second node is twice, removing the first node
I am making a project right now to practice double linked lists and I have been working on a method in my double linked lists class which switches node locations. It works fine when trying to switch ...
0
votes
0
answers
47
views
How can I use this same Bubble sort layout to work on a doubly linked list
The code below works to sort a singly linked list using class functions.It takes user input into an array, turns that array into a linked list, and then sorts it. I am uncertain on what changes I ...
1
vote
2
answers
62
views
Print Backward not working Python doubly linked list
I am learning linked list and I'm creating doubly linked list. My print backward is not working as intended. For better Information I will highlight the print backward function.
Print Backward
class ...
1
vote
1
answer
80
views
Solution for removing duplicates in a doubly linked circular list not working
I've written the function for removing duplicate elements in a doubly linked circular list. However when traversing the list after removing, I am not getting the desired output.
I have used typedef to ...
2
votes
1
answer
279
views
Do I have to remove all references to an object using std::shared_ptr
So, as a hundreds of thousands of people before me, I am implementing a doubly linked list in С++.
Here's a Node and List struct:
struct Node {
std::shared_ptr<Node> prev, next;
int data;...
0
votes
1
answer
65
views
Infinite memory addresses output when deleting node from circular doubly linked list
I am trying to implement a function to delete a node from the end of a circular doubly linked list in C. However, when I run the code, it goes into an infinite loop and produces a continuous stream of ...
1
vote
0
answers
91
views
Problems with Big O Notation
I created two dictionaries, one using doubly linked lists and another using binary search trees, both with some basic functions. I want to estimate the Big O notation for both dictionaries and compare ...
2
votes
1
answer
109
views
Time complexity of this code that flattens a multilevel doubly linked list
I was solving this LeetCode question - Flatten a Multilevel Doubly Linked List:
You are given a doubly linked list, which contains nodes that have a next pointer, a previous pointer, and an ...
0
votes
0
answers
54
views
How to use void pointers/typecasting for implementation of a doubly_linked_list class
I have an assignment in which I have to implement a doubly linked list ADT. I do not have issues with that, I created something like this:
class DoublyLinkedList{
struct Node{
int value;
...
0
votes
1
answer
51
views
Use generics to support three different types to make a doubly linked list [duplicate]
I tried to make a doubly linked list class using generics, and make lists with three different data types (int, double, string).
As far as I know, T works just as a parameter for generics, and will ...
2
votes
1
answer
87
views
Is it possible to find the number of elements in a circular doubly linked list? [closed]
We have a circular doubly linked list with several elements. Every element has a link to the next element, a link to the previous element and a boolean value (true or false).
Four operations are ...
0
votes
1
answer
27
views
deleting node in a doubly linked list
I wrote this code to delete a node from a linked list:
void deleteNode(struct node **head, int element)
{
if (*head == NULL)
return;
struct node *temp = *head;
while (temp != NULL ...
-2
votes
1
answer
75
views
How do I add spaces between elements in a doubly linked list when concentrating them into a string in Java?
I'm creating a toString() function that should return a String created by concatenating each Nodes toString(). A single space: ‘ ’ should be inserted between each Nodes toString(). No trailing space ...
0
votes
1
answer
66
views
Doubly linked list consuming too much memory
I`m making an application that opens an image in a WindowsForm PictureBox and by clicking left arrow or right arrow, it will change to previous or next image in the same folder.
In order to change ...
1
vote
2
answers
58
views
What am I doing wrong in my Java implementation of a doubly linked list? [closed]
I am trying to create a doubly linked list in java and just need a little guidance as too where I am going wrong.I also wanted to be able to set a capacity for the list as well.
This is what I have so ...
0
votes
1
answer
130
views
How to make bubble sort in doubly linked list?
I want to make bubble sorting algorithm with doubly linked list in python.
Node has prev key and next key.
The list connected end node and start node(head)
This is My Node defenition
class Node:
...
-1
votes
1
answer
58
views
Double linked list improvements [closed]
I'm trying to improve my double linked list API.
int ll_create(linked_list_p list, void (*print_data)(uint8_t)) {
if (list == NULL) {
list = calloc(1, sizeof(linked_list_p));
...
-3
votes
2
answers
84
views
This C code declares an error (segfault) when I run it
#include <stdio.h>
#include <stdlib.h>
struct chambre {
int num;
struct chambre *prd;
struct chambre *svt;
};
typedef struct chambre chambre;
struct ascenseur {
char c;
struct ...
-1
votes
1
answer
77
views
-SOLVED- How to add List Comprehension and 'for in' loop for Doubly Linked List
I have created a python class for doubly linked list. It looks like this:
from tabulate import tabulate
class Node:
def __init__(self, value):
self.data = value
self.next = None # ...
0
votes
1
answer
51
views
Java; Swapping two elements in a DoublyLinkedList without changing the data without collections
Okay, so I'm trying to swap two elements in a doubly linked list without altering the data and without using collections. Here's what I have so far;
package q2b;
public class DoublyLinkedList {
...
1
vote
1
answer
50
views
Searching for string input using a function bool deleteAcc(const string name1) in doubly linkedlist in C++98?
All my other functions of my doubly linked list which consist of Account class and Node class are all working except this last function.
The function bool deleteAcc(string name) will take as it’s ...
-1
votes
1
answer
150
views
Build a spreadsheet from a list of tuples of (row, column, value) using doubly linked list (linked lists of linked lists)
I'm hoping to get a result like in Build a spreadsheet from a list of tuples of (row, column, value) using 2D array. no numpy, but instead of 2d lists it is a linked list of linked lists.
Currently I ...