I need the node sorted (selection sort) whenever the data is entered front or end or deleted front or end. How to get it sort automatically everytime user entered a data? countItems() doesn't seem worked to the selection sort... This is my Node class. Mostly no problem... [CODE] public class Node { int num; Node next; Node() { num = 0; next = null; } Node(int num, Node next) { this.num = num; this.next = next; } }[/CODE] This is the List class. Most problems occured here... [CODE]import java.util.*; public class List { Node head; List() { this.head = null; …

Member Avatar
Member Avatar
+0 forum 4

[CODE] private Node<T> addAt(Node<T> node, T value) { if (node == null) { // special case return new Node<T>(value, null); } else if (node.getNext() == null) { // other special case node.setNext(new Node<T>(value, null)); } else if (node.getstuff().getName().compareTo(value.getName()) > 0) { node.setNext(new Node<T>(value, node.getNext())); } else addAtEnd(node.getNext(), value); } return node; } [/CODE] so my problem is that im trying to call a method of the object in a particular node, but it keep telling me that the method inside my object class is not recognized, cannot find symbol, in this case, the getName method, any ideas?

Member Avatar
Member Avatar
+0 forum 9

Hey guys, I'm writting a program that reads a list of names from a file called name.txt and instert these names directly into a linked list in alphabetical order of [B]last[/B] names. For example, if the text file has these names: Henry Johns III, Albert Einstein, Henry Johns II, Mary D Goly, Bob Apple Jr. , Bob Apple Sr. then the linked list will be in this order: Bob Apple Jr. , Bob Apple Sr., Alber Einstein, Mary D Goly, Henry Johns II, Henry Johns III. Someone suggested me to use CompareTo to compare the last names, but I'm still …

Member Avatar
Member Avatar
+0 forum 4

I have been working on a number of card games. Important, of course, is shuffling the deck. I have come up with a few different ways to do this. Currently I do not shuffle, but to deal a card, I lay out the deck in order, selecting a random number between 1 and the number of cards remaining and selecting that card. I then remove that card from the deck so that another card can be picked. There are two main ways to do this, and I am trying to figure out which one is optimal. The first is to …

Member Avatar
Member Avatar
+0 forum 1

Hello Guys, I have found many source codes to implement linked list. But all are inserting or deleting the node values after user's choice. I dont want that. Insertion should happen dynamically. I have a client program running on another system. I fetch the data from that system through my server program.As and when i receive the data, I shd insert them into my linked list. Kindly help me dng this. Thanks in advance. Deepika

Member Avatar
Member Avatar
+0 forum 6

I'm just a 4-months newbie in C++, and I have an assignment to do a small phonebook program for DOS or FreeDOS. This is what i got from days after searching: This is CTelrecord class that would save every record in details [CODE]class CTelRecord { private: int szTime; char szName[_MAX_NAME_LEN_]; char szNumber[_MAX_NUMBER_LEN_]; public: CTelRecord(); CTelRecord(char *name, char *number); void SetRecord(char *name, char *number); void SetRecTime(int); int Compare(CTelRecord *); void Show(); void ShowName(); void ShowNumber(); void ShowRecTime(short int); nTime TimeParser(); void ModifyNumber(char *number); void ModifyName(char *name); int LookChar(char key); int SearchMore(char key[_MAX_NAME_LEN_]); char *GetName() { return szName; } char *GetNum() { …

Member Avatar
Member Avatar
+0 forum 2

the inputs are these computer 21 sabanci 4 sabanci 6 university 6 university 12 computer 17 university 3 computer 9 computer 6 sabanci 2 university 9 problem occurs at third line when the input name1 is equal with the previous input name1. Really thx for helping. Sorry for mess. #include <fstream> #include <string> #include <iostream> using namespace std; class linklist { public: linklist(); void InsertOrdered(string name, string key); // void PrintList(); ~linklist(); private: struct sublink { string key; sublink *next; sublink() { next = NULL; key = ""; } }; struct link { string name; sublink *subnext; link *mainnext; link() …

Member Avatar
Member Avatar
+0 forum 1

I need to use an array of 5 elements. Each element of the array is a structure with 2 fields: the name of the hotel and a singly linked list of attendees staying in that hotel. Functions are: CheckIn CheckOut Transfer Count Print Quit If someone could just show me how the classes are supposed to be built and how one function would be implemented, I can do the rest. I just can't figure out how it is supposed to be implement with the extra array element structure in the middle. This is what I have so far [CODE]#ifndef DOUBLY_LINKED_LIST …

Member Avatar
Member Avatar
+0 forum 2

How do i compare two linkedLists so that the onutcome is a sorted linked list from least to greates. Heres my code so far. list1.txt 1 2 3 7 9 10 13 list2.txt 4 5 6 8 11 12 14 how do i compare the two and make it into a third sorted linked list? [CODE] import java.io.*; import java.util.Scanner; public class LinkedListDemo { public static void main(String[] args) throws IOException { Scanner s = null; try { LinkedList test = new LinkedList(); LinkedList test2 = new LinkedList(); s = new Scanner(new BufferedReader(new FileReader("list1.txt"))); while (s.hasNext()) { test.add(s.next()); } System.out.println(test.toString()); …

Member Avatar
Member Avatar
+0 forum 3

I am having trouble adding information from a ".txt" file to a linked list... here is what i have. list1.txt: 1 2 4 5 6 7 8 11 [CODE] /** The LinkedList1 class implements a Linked list. */ class LinkedList1 { /** The Node class stores a list element and a reference to the next node. */ private class Node { String value; Node next; /** Constructor. @param val The element to store in the node. @param n The reference to the successor node. */ Node(String val, Node n) { value = val; next = n; } /** Constructor. @param …

Member Avatar
Member Avatar
+0 forum 2

how do i read in files from a ".txt" file into a linked list heres my code. [CODE] import java.io.*; public class LinkedList1 { class Node { String element; // list element Node next; // successor link Node(String el, Node n) { element = el; next = n; } Node(String el) { element = el; next = null; } } public static main (String[] args) { Node myList = new Node("1"); // AT THIS PART OF MY CODE I WANT TO READ IN INTEGERS FROM A ".txt" FILE // USING FILE IO HOW DO I DO THAT? } } [/CODE]

Member Avatar
Member Avatar
+0 forum 1

hi guys im creating a dictionary which would show the word and the meaning of the word this is what i have done so far, i created a class called meaning which stores the meaning of the word [code] #ifndef MEANING #define MEANING #include<string> class Meaning { public: Meaning(); ~Meaning(); // setter methods void setmeaning(string Meaning); void setNext(Meaning*); // getter methods void printMeaning(); // display the meaning of a word on the screen string getMeaning(); // return the meaning of a word Meaning* getNext(); // get the next meaning for a word if it exists private: string Meaning; Meaning* next; …

Member Avatar
Member Avatar
+0 forum 2

The End.