Sorted Double Linked List.
public class DLinkedList {
class Node {
String data;
Node next = null;
Node prev = null;
public Node(String o, Node n, Node p){
data = o;
next = n;
prev = p;
private int max;
private Node head;
private Node current = null;
public DLinkedList(int max_size) {
head = null;
current = null;
max = max_size;
public boolean isEmpty() {
public void insert(String o) {
Node n;
while (current != null && o.compareToIgnoreCase(current.data) > 0)
current.prev = current;
current = current.next;
if (current.prev == null)
// First Item in List
n = new Node(o, current, null);
else
current.prev.next = new Node(o, current, current.prev);
I am working on the insert and keep getting a null pointer exception. Can someone point me in the right direction.
Thanks
if (current.prev == null)
// First Item in List
n = new Node(o, current, null);
}This code right here will cause a NullPointerException if current is still null, which is one of the possible exit conditions in your loop.
Similar Messages
-
Sorting singly linked list with minimum time complexity
Hi ...
anyone could tell me how can i sort singly linked list with minimum time complexity .... ????
Regards...By MergeSort or QuickSort O(n log n). But then you
have to first extract the objects in the list,sort
them, then rebuild the list. But it will still bealot
faster than by keeping the list linked.Technically, I believe insertion sort is marginally
faster for small n ( <20 or so).Woohoo! So for 20 out of the possible 2147483648 array
sizes Insetion is faster!
Unfortunately, checking for that case probably wastes
all the time you get from using the faster sort...
That would depend on the actual distribution off array sizes. So it's an engineering decision.
Sylvia. -
Revision: 18926
Revision: 18926
Author: [email protected]
Date: 2010-12-01 14:07:19 -0800 (Wed, 01 Dec 2010)
Log Message:
bug fix BLZ-570 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError
We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml.
This needs documentation.
Checkintests pass
Ticket Links:
http://bugs.adobe.com/jira/browse/BLZ-570
Modified Paths:
blazeds/trunk/modules/common/src/flex/messaging/errors.properties
blazeds/trunk/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.java
blazeds/trunk/modules/core/src/flex/messaging/io/SerializationContext.java
blazeds/trunk/modules/core/src/flex/messaging/io/amf/Amf0Input.java
blazeds/trunk/modules/core/src/flex/messaging/io/amf/Amf3Input.java
blazeds/trunk/modules/core/src/flex/messaging/io/amf/AmfIO.java -
Revision: 20451
Revision: 20451
Author: [email protected]
Date: 2011-02-24 08:33:31 -0800 (Thu, 24 Feb 2011)
Log Message:
backporting bug fix BLZ-570/BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml. This needs documentation. Checkintests pass
Ticket Links:
http://bugs.adobe.com/jira/browse/BLZ-570
http://bugs.adobe.com/jira/browse/BLZ-620
Modified Paths:
blazeds/branches/4.0.0_fixes/modules/common/src/flex/messaging/errors.properties
blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.j ava
blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/SerializationContext.java
blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/Amf0Input.java
blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/Amf3Input.java
blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/AmfIO.javaDear Pallavi,
Very useful post!
I am looking for similar accelerators for
Software Inventory Accelerator
Hardware Inventory Accelerator
Interfaces Inventory
Customization Assessment Accelerator
Sizing Tool
Which helps us to come up with the relevant Bill of Matetials for every area mentioned above, and the ones which I dont know...
Request help on such accelerators... Any clues?
Any reply, help is highly appreciated.
Regards
Manish Madhav -
Revision: 20443
Revision: 20443
Author: [email protected]
Date: 2011-02-23 21:19:22 -0800 (Wed, 23 Feb 2011)
Log Message:
back porting bug fix BLZ-570/BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml. This needs documentation. Checkintests pass
Ticket Links:
http://bugs.adobe.com/jira/browse/BLZ-570
http://bugs.adobe.com/jira/browse/BLZ-620
Modified Paths:
blazeds/branches/3.x/modules/common/src/java/flex/messaging/errors.properties
blazeds/branches/3.x/modules/core/src/java/flex/messaging/endpoints/AbstractEndpoint.java
blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/SerializationContext.java
blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/Amf0Input.java
blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/Amf3Input.java
blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/AmfIO.java -
Search in Double link list in java
Can any body give me the code implementation for searching an element in double link list in java as soon as possible...
Can any body give me the code implementation for
searching an element in double link list in java as
soon as possible...Psuedo code...
current = head of list
found = null
while(current is not null)
if doesItMatch(current, target)
break
current = current->next
if (current is null) Out("no match")
else Out("found it") -
Implementing Double Linked Lists
I have been set a task creating a java class to implement the data cells of a double linked list, then improving on this class so that it will implemt the interface of a LinearList using a double linked list.
HELP?!?!?!?!i have implemented a small method.u can implement the remaining methods as u want. I have not tested the code. Just for idea i am giving it. try it.
public class Node{
Node leftNode;
Node rightNode;
int data;
public Node addNode(Node node,int data,int position){
Node originalCopy=node;
for(int i=0;i<position;i++){
Node tempNode=new Node();
tempNode.data=data;
tempNode.leftNode=node;
tempNode.rightNode=node.rightNode;
node=node.rightNode;
return originalCopy;
This class represents a Doubly linked list and it provides operations on it. -
hi,
I am using Berkeley DB database and facing a problem while retrieving records. After building database i'm retrieving records from that database.After retrieving some records it gives the error as
*** glibc detected *** corrupted double-linked list: 0x004ec848 *** Aborted. What can i do solve this problem.
Thank you,
raviHi Ravi,
Have you googled for the error message? What are the results?
A good thing to do is to provide me a test program and more details about your operating system environment. Also, try to update your glibc version.
Regards,
Bogdan Coman -
users are getting this error
{noformat}*** glibc detected *** corrupted double-linked list: 0x0027f878 ***{noformat}{noformat} {noformat}
what could the issue for above error,
in concurrent reqest out put,
Apps:12i
os: LinuxSawwan,
Request language is :
AMERICAN
Request territory is :
AMERICA
Previous NLS_LANG Environment Variable was :
AMERICAN_AMERICA.WE8ISO8859P15
Current NLS_LANG and NLS_NUMERIC_CHARACTERS Environment Variables are :
AMERICAN_AMERICA.WE8ISO8859P15
stat_low = 6
stat_high = 0
emsg:was terminated by signal 6
Enter Password:
*** glibc detected *** corrupted double-linked list: 0x0027f878 ***
Report Builder: Release 10.1.2.0.2 - Production on Wed Mar 18 09:02:51 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Start of log messages from FND_FILE
End of log messages from FND_FILE
Reset original NLS_LANG in environment as :
AMERICAN_AMERICA.WE8ISO8859P15
Program was terminated by signal 6
Concurrent Manager encountered an error while running Oracle*Report for your concurrent request xxxxxxx -
I have been upgrading wine and I keep running into problems running Guildwars. Every time I upgrade wine to a newer version using pacman the program will not work correctly and freezes. So I have to downgrade to wine 1.1.20. When I run wine thru terminal I get
*** glibc detected *** c:\Program Files\Guild Wars\Gw.exe: corrupted double-linked list: 0x7d4bc4f8 ***
======= Backtrace: =========
/lib/libc.so.6(+0x6b6c1)[0xb75dc6c1]
/lib/libc.so.6(+0x6d003)[0xb75de003]
/lib/libc.so.6(cfree+0x6d)[0xb75e0f8d]
/usr/lib/libGLcore.so.1(+0x5964af)[0xb6b8d4af]
[0x200000]
/usr/lib/libGLcore.so.1(+0x5ed980)[0xb6be4980]
[0x138808b]
I think this is because somehow libc.so.6 and libGlcore.so.1 is double linked. If so how do I find where they are linked to and how do I get rid of the wrong link. I can only find one /lib/libc.so.6 and only one /usr/lib/libGLcore.so.1 so there are not two of each. Am I going in the right direction?That error does not mean a link as in a symbolic link, but as in a data structure in the code. See http://en.wikipedia.org/wiki/Linked_list for the idea. The trace is saying that somewhere in libGLcore, there is a linked list which is being corrupted somehow. This is an error inside the code, and not with your filesystem, so that would not be a way to fix it. Check out the wine app database at http://appdb.winehq.org/ to see if anyone has had your problem.
-
Delphi Double Linked List to Java
Does a Delphi Double Linked List correspond to any data type in Java?
Thanks for your time,
NateLook at the documentationf for java.util.*, in particular the collections therein.
java.util.LinkedList is probably closest to what you want. -
Hi everyone,
I have some problems about Double Linked Lists which I can not overcome. When I execute the following codes, there is an exception occured that is called NullPointer Exception in inser method.
So how can I fix it ??
class DoublyLinkedNode {
// properties
DoublyLinkedNode nextNode;
DoublyLinkedNode previousNode;
int size;
int data;
// constructors
public DoublyLinkedNode(int data,DoublyLinkedNode nextNode, DoublyLinkedNode previousNode){
this.data = data;
this.nextNode = nextNode;
this.previousNode = previousNode;
size = 0;
// methods
public void setNext(DoublyLinkedNode next){
nextNode = next;
public void setPrevious(DoublyLinkedNode pre){
previousNode = pre;
public DoublyLinkedNode getNext(){
return nextNode;
public DoublyLinkedNode getPrevious(){
return previousNode;
public int getData(){
return data;
public void setData(int value){
data = value;
class DoubleLinkedList {
// properties
int size;
DoublyLinkedNode tail;
DoublyLinkedNode head;
String s = "";
// constructors
public DoubleLinkedList(){
head = null;
tail = null;
size = 0;
// methods
public boolean isEmpty(){
if(head == null)
return true;
else
return false;
public DoublyLinkedNode next(){
return head.getNext();
public DoublyLinkedNode previous(){
return head.getPrevious();
public void insert(int data){
head = new DoublyLinkedNode(data, head.getNext(),head.getPrevious());
size++;
public String toString(){
s += head.getData() + "";
head = head.getNext();
if(isEmpty())
return s;
else
return toString();
public static void main(String args[]){
DoubleLinkedList list = new DoubleLinkedList();
list.insert(111);
list.insert(21);
list.insert(311);
list.insert(41);
list.insert(51);
list.insert(16);
list.insert(117);
System.out.println(list.toString());
// for(int a = 0; a < 5; a++){
// list.previous();
}Again, I changed insert method which is now correct I think.
But now, toString cause only appear the last object on the console.
So how can I fix toString method ???
public void insert(int data){
DoublyLinkedNode pointer = head.getPrevious();
DoublyLinkedNode pointer2 = pointer.getNext();
head = new DoublyLinkedNode(data,pointer2, pointer );
} -
If the circular double linked list has only one item, will that item's next/previous node references point to itself?
Yeah, it would make sense. But I'm wondering if there's any standard?
It could also make sense for the references to simply be null. -
Alright, here's the problem. I have my linked list, either imported from a text file or inputted by the user. Now, I need to sort it by the date and the time strings... Yet, every time I do I get an NullPointException. Can anyone help? Here's my code for the list:
public class ListReferenceBased implements ListInterface{
//references to the linked list items
private Node head;
private int numItems; //number of items that exist in list
//Default Constructor
//sets both items to null
public ListReferenceBased(){
numItems = 0;
head = null;
//if the numItems in the list is empty
//returns true.
public boolean isEmpty(){
return numItems == 0;
// returns numItems, aka the size of the list
public int size(){
return numItems;
//finds a node by setting a node to the 'head'
// and loops through to the index 'resetting'
// curr to the 'next' node.
private Node find(int index){
Node curr = head;
for( int skip = 1; skip < index; skip++){
curr = curr.getNext();
return curr;
public Object get(int index)
throws ListIndexOutOfBoundsException{
//catches if list does not reach the index given
//loops through the index
if(index >= 1 && index <= numItems){
//sets curr to the index through find()
Node curr = find(index);
//sets dataitem to the current node
Object dataItem = curr.getItem();
return dataItem;
}else{
throw new ListIndexOutOfBoundsException("The List index is out of bounds on get");
public void add(int index, Object item)
throws ListIndexOutOfBoundsException{
//checks to make sure there are no nodes yet
//if there are inserts them in the list
//by moving
if(index >=1&& index<= numItems+1){
if(index==1){
// if no list exists
//creates a new node and sets it to head
Node newNode = new Node(item, head);
head = newNode;
}else{
//inserts the node at the index
//by finding it first
Node prev = find(index-1);
//creates a new node by placing the Object item
//and the 'new prev' node into a node
//'deleting' the old 'bonds'
Node newNode = new Node(item, prev.getNext());
rev.setNext(newNode);
//increments number of items in list
numItems++;
}else{
throw new ListIndexOutOfBoundsException("List index out of bounds");
public void remove(int index)
throws ListIndexOutOfBoundsException{
//catches the list if it doesn't exist
//checks to make sure list exists
if(index>=1&& index<= numItems){
//if only the head exists
//calls next node else moves
//the node away and moves the prev
//on up.
if(index==1){
head = head.getNext();
}else{
Node prev = find(index-1);
Node curr = prev.getNext();
prev.setNext(curr.getNext());
//decreases the number of items in list
numItems--;
}else{
throw new ListIndexOutOfBoundsException("List index out of bounds");
//sets the numItem to null telling the list it
//does not exist
public void removeAll(){
head = null;
numItems=0;
Yeah, unfortunately, I had to design my own linked list for my assignment (that's taken almost 40+ hours). So, now every alogrithm I've tried to write seems to give me a null pointer, for example this one
public void sort(){
//loop through all existing nodes
for(Node curr = head; curr != null; curr = curr.getNext()){
//parse the string of the current node
//to a string value
Node current = curr.getNext();
Node next = current.getNext();
Node temp;
String thisline = current.getItem().toString();
System.out.println(thisline);
StringTokenizer parser = new StringTokenizer ( thisline, "\t" );
String thisdate = parser.nextToken();
String thistime = parser.nextToken();
String thisline2 = next.getItem().toString();
System.out.println(thisline2);
StringTokenizer parser2 = new StringTokenizer ( thisline2, "\t" );
String thisdate2 = parser.nextToken();
String thistime2 = parser.nextToken();
//compares the dates of next in list
if(thisdate.compareTo(thisdate2)==1){
next.setNext(current);
current.setNext(next.getNext());
printList();
//if dates equal, compare the times
//if equal move to new position
//delete old position
}Pretty much I believe moving the positions is causing the problems after the first run around. Any suggestions? -
so, everything works through the first iteration (don't know if this is an appropriate term for linked lists, but we just learned arrays) but then it stops. I thought that telling it to continue until position.next != null and increasing the position after every iteration would work but I think I have coded something incorrectly / am not taking something into consideration. I would be greatly obliged if you can offer any advice!
Thanks,
Hunter
public void bubbleSort()
Node current, a, previous, position;
position = new Node(0);
position.next = head;
head = position;
while (position.next != null)
{ current = position.next;
previous = position;
a = current.next;
while(a != null)
if (a.getVal() < current.getVal())
Node temp = a.next;
a.next = previous.next;
previous.next = current.next;
current.next = temp;
previous = a;
a = temp;
else
a = a.next;
current = current.next;
previous = previous.next;
position = position.next;
head = head.next;First, thanks for the response! I have been trying println statements and really don't understand the problem. I have also gone through line-by-line and drawn out what I think is supposed to happen and still can't seem to fully figure out what I am doing wrong. Here is the full code, this might help with the 'definition of my list'.
public class LinkedList
public Node head;
public LinkedList(int length)
head = null;
for (int i = 0; i < length; i ++)
insert(i);
public LinkedList()
head = null;
public void clear()
head = null;
public void insert(int n)
Node current = new Node(n);
current.next = head;
head = current;
public void insert(Node n, int index)
Node previous, current;
Node nnode = new Node(-10);
nnode.next = head;
previous = nnode;
current = head;
while (current != null && index > 0)
current = current.next;
previous = previous.next;
index --;
if (previous == nnode)
n.next = head;
head = n;
else
previous.next = n;
n.next = current;
//Delete the node at the zero-based index.
public void delete(int index)
int current;
Node currentnode = head;
for (current = index; current > 1; current --)
currentnode = currentnode.next;
if (currentnode == head)
head = head.next;
else
currentnode.next = currentnode.next.next;
public Node getNode(int index)
Node nnode = new Node(-10);
nnode.next = head;
Node current = head;
while(current.next != null && index > 0)
{ current = current.next;
index --;
return current;
public int getVal(int index)
int current;
Node currentnode = head;
for (current = index; current > 0; current --)
currentnode = currentnode.next;
//currentnode should point to the node whose value we want.
return currentnode.getVal();
public void print()
System.out.println();
head.print();
private void swap(Node pa, Node a, Node pb, Node b)
Node temp = b.next;
pa.next = b;
if (a.next != b)
b.next = a.next;
pb.next = a;
else
b.next = a;
a.next = temp;
public void selectionSort()
Node current, a, previous, position;
position = new Node(0);
position.next = head;
head = position;
while (position.next != null)
current = previous = position.next;
a = position.next;
while(a != null)
if (a.getVal() < current.getVal())
current = a;
while(previous.next != current)
previous = previous.next;
a = a.next;
if (current != previous)
Node t = position.next;
swap(position, t, previous, current);
//System.out.println("****************");
//head.print();
position = position.next;
head = head.next; //to lose the initial node.
//System.out.println("end of sorting, head.print is");
//head.print();
public void bubbleSort()
Node current, a, previous, position;
position = new Node(0);
position.next = head;
head = position;
while (position.next != null)
{ current = position.next;
previous = position;
a = current.next;
while(a != null)
if (a.getVal() < current.getVal())
Node temp = a.next;
a.next = previous.next;
previous.next = current.next;
current.next = temp;
previous = a;
a = temp;
else
a = a.next;
current = current.next;
previous = previous.next;
position = position.next;
head = head.next;
}
Maybe you are looking for
-
SharePoint 2010 Search Service is not working on replication of Servers.
Hi, I have a problem. I have a SharePoint Farm in which there are two servers with ip's 192.168.8.60 and 192.168.8.62. Both are replicas of each other. The search service is working on 192.168.8.60 and not working on 192.168.8.62. What can be the pro
-
How to delete header condtion line of sales order by BAPI
Hi, I want to delete the condtion line of sales order header using BAPI "BAPI_SALESORDER_CHANGE", it is work well in item level condition type, but it is not work for header condition type. show error message "missing item number" since of pass item
-
Problem while printing through citrix
Dear Gurus , We are facing the problem during printing through citrix . When we print locally without using citrix were able to get the proper print as it displayed in the spool . But When we try to take the printout of document having say 12 colum
-
Can only see desktop background & windows are blank
My computer (a G4 MDD) is not starting up properly. It will start up but icons, the dock, and text in the menu bar will not appear. It appears the computer works. I had an alert pop up which only appeared as a white window box. I couldn't read it. I
-
Color Correction for movie theaters
I am currently editing a commercial that will be played in a couple of local movie theaters before the movie previews. I am in no way a professional and I'm kind of a Color newbie. I am working on a Mid 2009 15" MacBook Pro with HDV 1080i60 footage.