home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2768
Discussions: 186,608, Posts: 2,227,068, Members: 230,244
Free Scan: Update Your PC's Outdated Drivers to Optimize Performance
Old August 16th, 2008, 05:53 PM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Aug 2008
Posts: 5
Talking
^_^ the beautiful princess Eve

Hi
Everyone
I need help
I ask what is the solution to this program
Or I should explain how the solution

&
In an ancient land, the beautiful princess Eve had many suitors. She decided on the following procedure to determine which suitor she would marry . first , all of the suitor would be lined up one after the other and assigned number. The first suitor would be number1, the second number 2, and so on up to the last suitor ,number n . starting at the suitor in the first position. She would then count three suitors down the line ( because of the three letters in her name) and the third suitor would be eliminated from winning her hand and removed from the line. Eve would then continue, counting three more suitors, and eliminate every third suitor. When she reached the end of the line. She would continue counting from the beginning.
For example, if there were 6 suitors . the elimination proceed as follows:
123456 initial list of suitors , start counting from1
12456 suitor 3 eliminated , continue counting form 4
1245 suitor 6 eliminated , continue counting form 1
125 suitor4 eliminated , continue counting form 5
15 suitor 2 eliminated , continue counting form 5
1 suitor 5 eliminated , 1 is the lucky winner.
Write a program that creates a circular linked list of nodes to determine which position you should stand in to marry the princess if there are n suitors. Your program should simulate the elimination process by deleting the node that corresponds to the suitor that is elimination for each step in the process
With thanks
Yuki
^_^

Yuki81 is offline   Reply With Quote
TechIMO.com Ads - Login or register for less ads.
How many errors does your computer have?

You no longer need to guess! This free stability scan and registry cleaner download will give you a complete diagnosis of your Windows registry, identifying errors and conflicts.

FREE instant scan


Guest, Register Free! to remove this ad and get your tech support questions answered in minutes!
Old August 16th, 2008, 06:06 PM     #2 (permalink)
Junior Member
 
Join Date: Aug 2008
Posts: 5
pLZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

Yuki81 is offline   Reply With Quote
Old August 16th, 2008, 07:03 PM     #3 (permalink)
Ultimate Member
 
Rootstonian's Avatar
 
Join Date: Mar 2005
Location: Out of my mind
Posts: 2,742
Send a message via AIM to Rootstonian
Ugh, it's the weekend and I'm not much in algorithm mode

I take it you're in a Data Structures class...fun stuff. A cicular linked list just joins the tail node to the head node so you don't need a "head" AND "tail" pointer.

At this point in class (or whatever) you should now how to make a linked list; it's not hard. It's structure would probably be:

struct Node {
int SuitorNumber; // data element
Node *next; // point to next node
}

Then you would fill this list with 1....n suitors. You'll want procedures like:

Add_Node
Delete_Node
Find_Node
Display_Node

You'll want a Start_Pointer variable to point to beginning of list and note that the "next" pointer of the LAST node will be the same as Start_Pointer (circular).

Too much fun; I miss my college days


Last edited by Rootstonian : August 16th, 2008 at 07:14 PM.
Rootstonian is online now   Reply With Quote
Old August 16th, 2008, 07:15 PM     #4 (permalink)
Junior Member
 
Join Date: Aug 2008
Posts: 5
Please help me not have tried enough time
I am a mother of two children age two months and I do not have enough time please
Can you please fully resolved
Yuki81 is offline   Reply With Quote
Old August 16th, 2008, 07:28 PM     #5 (permalink)
Ultimate Member
 
Rootstonian's Avatar
 
Join Date: Mar 2005
Location: Out of my mind
Posts: 2,742
Send a message via AIM to Rootstonian
LOL Sorry...I did my college days and earned my 2 degrees.

If you don't have enough time to devote 100+% to your education, then you may want to wait till you can.

I have no problems HELPING you with debugging or coding problems, but I will not write code for you Besides, you would fail a test if asked in a question to code a Insert_Node function in a singular linked list (about 15 lines of code )
Rootstonian is online now   Reply With Quote
Old August 16th, 2008, 07:54 PM     #6 (permalink)
Junior Member
 
Join Date: Aug 2008
Posts: 5
thanxxxxxxxxxxxxxxxx
Yuki81 is offline   Reply With Quote
Old August 16th, 2008, 09:50 PM     #7 (permalink)
Sea-Ninja wannabe
 
no1_vern's Avatar
 
Join Date: Apr 2002
Location: Albany, Ga.
Posts: 8,244
O, My!
__________________
They say technology slows down for no one. I know it outruns my wallet. I figure its because my wallet isn't light enough yet.
no1_vern is online now   Reply With Quote
Old August 23rd, 2008, 04:47 AM     #8 (permalink)
Junior Member
 
Join Date: Aug 2008
Posts: 2
public class list
{

private class Node
{
private int Snum;
private Node link;

public Node()
{
Snum = 0;
link = null;
}

public Node(int newSnum, Node linkValue)
{
Snum = newSnum;
link = linkValue;
}


}
private Node head;

public list()
{
head = null;
}

public void addToStart(int newSnum)
{
head = new Node(newSnum,head);
}

public boolean deleteHeadNode()
{
if (head!=null)
{
head = head.link;
return true;
}
else
return false;
}

public int size()
{
int count = 0;
Node position = head;
while (position != null)
{
count++;
position = position.link;
}
return count;
}

public boolean contains(int num)
{
return (find(num) != null);
}

private Node find(int target)
{
Node position = head;
int SnumAtPosition;
while(position!=null)
{
SnumAtPosition = position.Snum;
if(SnumAtPosition==target)
return position;
position = position.link;
}
return null;
}

public void outputList()
{
Node position = head;
while (position != null)
{
System.out.println(position.Snum);
position=position.link;
}
}

public boolean isEmpty()
{
return (head == null);
}

public void clear()
{
head = null;
}

public int selectsuitor(int n)
{
Node current = head;
Node prev=null;
while(n!=1)
{
for(int i=1;i<3;i++)
{
prev=current;
System.out.print(" " + current.Snum);
current=current.link;
if(current==null)
{
current=head;
}

}
prev.link=current.link;
current=current.link;
if(current==null)
{
current=head;
}
n--;
}
return current.Snum;
}
}








import java.util.Scanner;
public class list2{
public static void main(String[] args)
{
Scanner kb = new Scanner(System.in);
int numsuitors;
lab8list list = new lab8list();
System.out.println("Enter number of suitors:");
numsuitors = kb.nextInt();
for (int i=numsuitors;i>0;i--)
{
list.addToStart(i);
}
int x=list.selectsuitor(numsuitors);
System.out.println("\n\n"+ x);
}




im a smart girl
helen55 is offline   Reply With Quote
Old August 23rd, 2008, 10:50 PM     #9 (permalink)
Ultimate Member
 
Rootstonian's Avatar
 
Join Date: Mar 2005
Location: Out of my mind
Posts: 2,742
Send a message via AIM to Rootstonian
Oh really? How did this piece of work compile and/or run?
Rootstonian is online now   Reply With Quote
Old August 25th, 2008, 05:47 PM     #10 (permalink)
Junior Member
 
Join Date: Aug 2008
Posts: 2
LOL Sorry...

i asked for help

I thought it dificult

like writing in english

but some one helped me to understand it

{How did this piece of work compile and/or run? }

you do not need my answer

but because you did your college days and earned your 2 degrees.
I may need you someday

thanx
helen55 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
New Zelda: Twilight Princess Screenshots RobRich Game News Discussion 7 June 1st, 2006 05:29 PM
Do you REALLY want a beautiful Princess?? John Prophet IMO Community 8 January 18th, 2004 11:39 PM
Scrapped Princess - Thoughts JacobM5727 IMO Community 2 December 5th, 2003 11:35 PM

Most Active Discussions
Is It Just Me? (535)
Misery Loves Company... (1849)
Why Does the MOON Grow Bigger as It.. (18)
heatsink issue (10)
New Mobo (18)
UPGRADING C/D DRIVE TO 250GB & .. (14)
1 internet. 1 house. 3 computer. ho.. (13)
Is This A Compatible Gaming PC? (18)
SSD's, RAID, and External Backup (7)
Recent Discussions
help! jumbled text and computer.. (1)
Scanning problem (4)
DFI socket 939 board acting up (5)
Building my first PC and need s.. (2)
32 or 64 bit vista (4)
Big problem with my PC (2)
system restore 'next' button wo.. (2)
firewall (1)
C++ compiler suggestions (4)
FS: Dell 6000 laptop, modded 36.. (2)
Apple iPod touch 16 GB $200 (4)
Six 28-Disc Cross Design Black .. (4)


All times are GMT -4. The time now is 12:39 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28