?
Solved

add method of LinkedSortList

Posted on 2006-04-12
3
Medium Priority
?
282 Views
Last Modified: 2006-11-18
Hi,
   I'm trying to write an add method for a LinkedSortList class. Can someone explain the algorithm (don't write the code) step-by-step for the add method? The spec is to add an element without changing the order of the list (keeps it in order). The structure to use is linear nodes. I would really appreciate it. Thanks!
0
Comment
Question by:azcalv408
1 Comment
 
LVL 2

Accepted Solution

by:
borislavmarkov earned 480 total points
ID: 16438623
You have the list as follows:

A->B->D->Z
You have to add new element "W".
Begin to iterate elements and find position where new element is in relation like:

PREVIOUS < ADDED < NEXT

then you set pointers like:

PREVIOUS .next = ADDED
ADDED.previous = PREVIOUS
ADDED.next = NEXT
NEXT.previous = ADDED

so you begin to iterate elements of you current array and you find out that:

A,B - no action
B,D - no action
D,Z - here you take the action:

D.next = W
W.previous = D
W.next = Z
Z.previous = W

then you have structure:


A->B->D->W->Z

end.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month17 days, 9 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question