Working with a list of Object where one of the item has an empty String. Trying to write method which would return a sorted list. By sorting means the first item value of the list should always be an empty String. Since I don't want to manipulate the
Problem: I am not able to pop the element second time. For Example I have 4,3,2,1 with 4 on top of stack.I am not able to delete 3,2 Can anyone guide me why? Below is the Stack Implementation : public static void push(int data){ if(head==null){ Node
I was trying to solve the Partition List problem on LeetCode. The problem asks to sort an linked list given a target list node, so that all the list nodes having smaller value than the target will come before the target, while their original relative
I am extremely new to Java programming only been at it a few weeks and I have this question of traversing a linked list to find a dog with a matching name. I have made an attempt at what I need but I am struggling to understand the traversal. Note: I
I'm having some issue with a part of my homework for CS. I need to write a Linked List in Java and then only iterate the odd numbers with an Iterator. Essentially, a forEach loop must iterate only through odd numbers. So far I only have this in my Li
Are there any adventage of using linked lists in javascript? Its main adventage over arrays (for example) is that we can insert element at random index without moving every element and that they are not limited to size as arrays. However, arrays in J
So currently i have an if statement in the GetNth function that im trying to test. but when i inserted a printf function, it made me notice that it goes through the if statement even if the condition is not met, however, when i remove the printf stat
I have problem with deleting elements from list #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 30 typedef struct elem{ char name[MAX]; int statistic; int price; struct elem *next; struct elem *prev; } shop; I crea
According to this really wonderful book, "size, on the other hand, will always require n steps since there is no way to know how many nodes are in the linked list without traversing from head to end. Therefore, length is O(n).". I was wondering
This is a simple C program to creat and display a singly linked-list.The creat() function creats a new node after the previous node taking the node-data as parameter.The display() function prints the linked-list. This program fragment is not working
Ive looked around and I'm not sure if it has been posted or not, but I am trying to create two linked lists in C. When they are supposed to be 'empty' there are zeros. I am not sure where these zeros are coming from and its confusing the hell out of
I am trying to add Point into a linked list, in order to keep track of the frequency of each data entry. Everytime I run this code it gives me a NullPointerException. I don;t understand why, to me it seems as if after it adds the frequency it creates
I have a string and want to convert it into a LinkedList such that every line is a single element. I use Visual Studio 2012. Is there any easy way to do it? This string looks like: LOAD =5.01E+10 MPY $1 ADD $2 But in fact it contain LOAD =5.01E+10\r\
I made a linked list whose nodes hold 4 string values. When I call the newNode function, an error says 'Node has no member named familyName', as well as the other members. My code: I am really confused with how strings work in structs.Your immediate
In LinkedList we normally assign null value to last node and also use this condition to check for the last node. I am checking for the last node with the same condition either its "next" node link is null or not. But I'm unable to handle NullPoi
I am trying to insert into a doubly linked list. I am then trying to print the list in both forward and reverse direction. I have created a head node and I am trying to insert another one, but I am unable to do so. The program shows a runtime error.
I've been trying to make a program that creates a list of lists (the list Groups contains two lists: transform and obj. All the code is done, but when I try to print the elements of the list, I get a NULL. I suppose the problem is in the link between
I'm practicing with linked lists in c, I want to make a program that reads entries from keyboard and lists the contents of the linked list after adding each node, but the output is always the first node, i can't figure out why, could someone please p
The insert code seems to be working perfectly until the last insertion, where it doesn't add it in order instead it place it at the end of the list. public void insert(Comparable item) { if ( this.first == null || item.compareTo(this.first.data) <= 0
This is the code I have written for a linked list. Basically it just takes input and print it. At compile time it gives no error but also it gives no output. I am not getting what is wrong with this code? Help me out. #include<stdio.h> struct list {
We had a school project, any information system using C. To keep a dynamic-sized list of student records, I went for a linked list data structure. This morning my friend let me see his system. I was surprised with his list of records: #include <stdio
Basically we have to implement a queue (linked list) for a restaurant waiting queue. We get extra points for using enum but I've never used it before. I'm wondering does this look right how I am using it? I have looked it up but haven't seen any exam
i have a linked list and i need to write a method to take an input as a string and check all the elements in the linked list for a match, the method has to return the number of matches. The problem is that i need to refer to the current linked list w
I'm trying to make a custom linked list, so far I've figured out how to make the general structure and the two easiest methods (insertFirst and deleteFirst). The next thing I want to do is make a get method that takes the index of a link and then ret
So I've got this code already: http://pastebin.com/3wuFNWGA And I've got these typedefs in a .h file: http://pastebin.com/JTG9XHvW I need my push function to add a node to my_stack by allocating memory for the node, storing the data (new element) in
public static void main(String[] args) { LinkedList test = new LinkedList(); int[] numberPair; numberPair = new int[2]; numberPair[0] = 1; numberPair[1] = 2; test.add(numberPair); } How would I go about accessing the array in the first node of this l
If I have, for instance 5 nodes containing the variables 1, 2, 3, 4, 5, how can I link the nodes in order to obtain 3, 2, 1, 4, 5 ? (Change the first node with the third one, and the third with the first). Thanks.Remove the node with key==1 and inser
do{ System.out.println("inside do"); for (int i = 0; i < i2; i++) { String s2 = m_area.m_items.get(i).returnName(); if (s2.contains(s)) { itemexist_check = true; player.addItem(m_area.m_items.get(i)); m_area.m_items.remove(i); } else { //do n
Okay so I have a LinkedList, and I have a String. I want to check if the String is contained within any of the LinkedList elements. For example: String a = "apple"; String listelement = "a bunch of apples"; LinkedList list = new Linked
I am working on making a C++ program that will simulate a fantasy football draft.. I have used a linked list to create a list of team names, for each person participating in the draft. Now, I would like to know which way I should go about adding the