GIDForums  

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 01-May-2006, 21:48
daking_09 daking_09 is offline
New Member
 
Join Date: Mar 2006
Posts: 15
daking_09 is on a distinguished road

C++ Help


Hey there,

I know you guys cant help when it comes to homework, so im kind of stuck. I need to make a c++ program that will sort a doubly linked like in decsending order and im not sure where to start. So maybe if someone could even just write a simple algorithm to give me a guide line?? or something like that, it would be very much appreciated.

Thank you
  #2  
Old 01-May-2006, 22:24
davis
 
Posts: n/a

Re: C++ Help


Quote:
Originally Posted by daking_09
Hey there,

I know you guys cant help when it comes to homework, so im kind of stuck. I need to make a c++ program that will sort a doubly linked like in decsending order and im not sure where to start. So maybe if someone could even just write a simple algorithm to give me a guide line?? or something like that, it would be very much appreciated.

Thank you

A doubly linked list containing what data type? Your sort algorithm is largely dependent on the data type stored in the list. Basically, you just implement the necessary features of the list for basic list management. Then, you enable your sort routine using iteration and list management functions.


:davis:
  #3  
Old 01-May-2006, 22:42
daking_09 daking_09 is offline
New Member
 
Join Date: Mar 2006
Posts: 15
daking_09 is on a distinguished road

Re: C++ Help


The data type would be integers....
  #4  
Old 02-May-2006, 07:21
daking_09 daking_09 is offline
New Member
 
Join Date: Mar 2006
Posts: 15
daking_09 is on a distinguished road

Algorithm help


Hey guys this what ive done for an algorithm to sort in descending order a doubly linked list. Dont know if its right completly, so if anyone can please point out anything they think is wrong

Thank You


BEGIN sortDoubleLink (PList, POne)
SET min to integer
SET array [1…n]
IF (PList not null)
SET min to PList -> data
SET POne to PList -> Link
WHILE (POne not null)
IF (POne < next data)
SET POne to PList
SET PList -> Link
ELSE INCREMENT to next array
ENDWHILE
ENDIF
RETURN (list)
END sortDoubleLink
Last edited by LuciWiz : 02-May-2006 at 07:35. Reason: [Merged thread]
  #5  
Old 02-May-2006, 07:22
cjavac#c++_vbP cjavac#c++_vbP is offline
Junior Member
 
Join Date: Mar 2006
Location: Miami, FL
Posts: 42
cjavac#c++_vbP is on a distinguished road

Re: C++ Help


Quote:
Originally Posted by daking_09
Hey there,

I know you guys cant help when it comes to homework, so im kind of stuck. I need to make a c++ program that will sort a doubly linked like in decsending order and im not sure where to start. So maybe if someone could even just write a simple algorithm to give me a guide line?? or something like that, it would be very much appreciated.

Thank you

search google for

probably 1 of these bubblesort, quicksort, mergesort algorithm.

When you say doubly linked list do you mean like a binary tree or a linear double linked list with current pointing to next and previous?


[leftlink][data][rightlink] - > [leftlink][data][rightlink] - > [leftlink][data][rightlink]

or
________________[leftlink][data][rightlink]
_______________ /___________________\
[leftlink][data][rightlink]________________[leftlink][data][rightlink]

excuse my attempt at drawing?
  #6  
Old 02-May-2006, 07:23
daking_09 daking_09 is offline
New Member
 
Join Date: Mar 2006
Posts: 15
daking_09 is on a distinguished road

Algorithm 2


Here is another algorithm that needs checking

here is the question:

Please write a non-recursive algorithm in pseudo code to solve the above problem using
stacks. The algorithm receives the following parameters: a two-dimensional array maze
(indexed from [1, 1]) that represents the maze, an integer N, where N > 0, which is the
size of the maze (hence, the array has valid elements from maze[1, 1] to maze[N, N]),
two integers (m1, m2) that are the coordinates of the starting point of the mouse (e.g.,
(m1=2, m2=1) means the starting point is row 2, column 1), and two integers (e1, e2) that
are the coordinates of the exist. For example, to represent the following figure (where the
shaded cells represent the wall), we have maze[1, 1] = 1, maze[1, 2] = 1, maze[1, 3] = 1,
maze[2, 1] = 0, maze[2, 2] = 1, maze[2, 3] = 0, maze[3, 1] = 0, maze[3, 2] = 0, maze[3, 3]
= 0; m1=2, m2=1, e1=2, e2=3.


here is the algorithm i have written


BEGIN mouseMaze
SET starting point (m1=2, m2=1)
SET exit (e1=2, e2=3)
WHILE (mouse = starting point)
move mouse (m1=1, m2=1) THEN
move mouse (m1=1, m2=2) & (m1=1, m2=3) THEN
exit maze if exit found
IF not exit
PRINT “(1, 1), (1, 2), (1, 3), (2, 3)”
ELSE
RETURN to start point
ENDIF
ENDWHILE
WHILE (mouse = starting point)
move mouse (m1=2, m2=2) THEN
exit maze if exit found
IF maze empty
PRINT “(2, 2), (2, 3)
ELSE
RETURN to start point
ENDIF
ENDWHILE
WHILE (mouse = starting point)
move mouse (m1=3, m2=1) THEN
move mouse (m1=3, m2=2) & (m1=3, m2=3) THEN
exit maze
IF not exit
PRINT “(3, 1), (3, 2), (3, 3), (2, 3)”
ELSE
RETURN to start point
ENDIF
ENDWHILE
END mouseMaze
Last edited by LuciWiz : 02-May-2006 at 07:45. Reason: [Merged thread]
  #7  
Old 02-May-2006, 07:27
daking_09 daking_09 is offline
New Member
 
Join Date: Mar 2006
Posts: 15
daking_09 is on a distinguished road

Re: C++ Help


i mean linear double linked list with current pointing to next and previous. Ive attempted a algorithm in the new post a few posts above this, dont know if its right tho...
  #8  
Old 02-May-2006, 07:43
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 889
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: C++ Help


Quote:
Originally Posted by daking 09
i mean linear double linked list with current pointing to next and previous. Ive attempted a algorithm in the new post a few posts above this, dont know if its right tho...

I have merged that thread with this one - you will find it as post #4 in this thread.

Please don't double post on the same problem. It makes it difficult for the people offering help to do so, as I think you might find happened in this case (since they couldn't see the algorithm you came up with). A more suggestive thread name would be helpful too.

I ask you to please try and read the "Guidelines for posting requests for help" (the link is in my signature), in order to help us help you.

I wish you happy learning.

Best regards,
Lucian
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #9  
Old 02-May-2006, 07:47
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 889
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: C++ Help


I have merged the new thread you started too... please post the next related issue in the same thread.
I am not sure how the software used for merging threads works (it porbably orders posts by date), but this post was merged as post #6 in this thread.
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
 

Recent GIDBlogFirst week of IA training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not 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
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 02:30.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.