dev-cpp-users Mailing List for Dev-C++
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1
(3) |
2
(4) |
3
(4) |
4
|
5
|
6
(2) |
7
|
8
|
9
(3) |
10
|
11
(1) |
12
|
13
|
14
(1) |
15
|
16
|
17
(1) |
18
|
19
(1) |
20
(1) |
21
|
22
(1) |
23
|
24
|
25
|
26
(1) |
27
(1) |
28
|
29
|
30
(1) |
31
(1) |
|
|
|
|
From: Jordan B. <jor...@me...> - 2011-05-31 21:25:26
|
I am currently creating a simple console application that will connect to remote database. I am using visaul studio 2005 and have created a new win32 console application. I am wanting to know how do I go about conencting to a database within C++ using the available APIs. I know they are a couple and I have googled about three different one from many different sources and am still confused. If someone could show me a related article or internet tutorial on how to do this or a general example of what it should look like with a specfic API I would greatly appreciate it. |
From: William Mc C. <wil...@ms...> - 2011-05-30 22:22:33
|
hello! http://autoschoen.com/gods.html?xshowtopic=fxqjx |
From: William Mc C. <wil...@ms...> - 2011-05-27 12:02:27
|
hello! http://www.serviceitalia.it/terr.php?ohgmailID=28so0 |
From: William Mc C. <wil...@ms...> - 2011-05-26 05:13:28
|
http://www.haberbox.com/terr.php |
From: William Mc C. <wil...@ms...> - 2011-05-22 01:10:08
|
http://www.supersaw.us/ter.html |
From: William Mc C. <wil...@ms...> - 2011-05-20 16:22:23
|
http://tomassaucedo.com.ar/gods.html |
From: William Mc C. <wil...@ms...> - 2011-05-19 13:30:45
|
http://ecodepot.fr/gods.html |
From: William Mc C. <wil...@ms...> - 2011-05-17 15:19:22
|
http://stacon.pl/gods.html |
From: William Mc C. <wil...@ms...> - 2011-05-14 16:15:50
|
http://graficamanchester.com.br/goods.html |
From: Per W. <pw...@ia...> - 2011-05-11 20:49:56
|
What I can recommend here is that you really make yourself comfortable with the debugger of your choice. A couple of things: - Few programs will work on first attempt. Debugging is almost always needed. - With more experience, it will be easier and easier to just read code and see bugs so a very large percentage of bugs can be handled just by looking at symptoms and maybe adding some printouts to find out if the problem happens before or after something else. - In your case, you guess that you have a problem with your heap. It's important to not be too quick deciding what a problem is but always keep an open mind: What different problems may there be that makes a specific source code line or function call to fail. There are very often more than one potential reason, meaning that these alternatives have to be checked one-by-one. So very standard scientific methods to try to prove theories or prove that the theory was wrong. - Something you seem to constantly forget is to explicitly look at corner cases. What happens for the special case when you try to insert the first element in an empty list? What happens when you want to insert a new elemnt before the currently first element? What happens when you want to insert a new element after all other elements? - A very big question here - are you even building your source code with full warnings enabled? The compiler is very good at spotting uninitialized variables, unless the variables are global. Sometimes it takes a bit higher optimization to get the compiler to make more advanced flow-control analysis to figure out unreachable code or variables that can be reached without an initialization. - As already noted by other readers, you have source lines that assign a value to a specific variable and then directly the line after checks what value the variable has. Are you really working methodical and scientific when analyzing your program? Are you taking a break and then revisiting the code and single-stepping the code in your head, trying to see exactly what the different lines does and why you need the lines? A professional software developer normally don't have any web forums available for debugging their code. They may use a web forum or mailing list to try to ask for missing information or known workarounds to problems they have found. But actual debugging can't be offloaded to any web forum since the programs are too large and normally contains proprietary code that can't be posted. This means that a software developer really must spend the required time to try to master the craft of problem solving. Both solving the customers original problem - what program to write to fulfill a requirements specification. But also debugging written code to verify that it does work as expected and does solve the same problem as the requirements specification wanted solved. It really is very well invested time to work on the debugging skills. And what you will find in the end is that being a tiny bit slower when writing the code will save you a lot of time when trying to get the code to work as expected. So first think very carefully at the problem you have. Then decide how to solve it. Then write the code. Then look at the code and think: is this really good code for solving the problem? First them may it be meaningful to start any debugging. It is meaningless to debug code just to later realize that the code solved the wrong problem or is too slow or requires too much memory forcing you to rewrite it. Having to rewrite just means new code to debug. The interesting thing with your posts is that they just always contains a number of code lines and basically "it doesn't work". There is very little information showing exactly what work you have done to try to solve the problem. It should be quite easy to test if a memory allocation fails, or if it is the assign of the receied pointer that fails. There are almost always possible to divide a problem into two smaller problems until the bug is so totally cornered that you can see what is wrong and what needs to be done to fix the problem. Your posts does not show that you do subdivide your problems. When programs gets larger, you really must work that way or you will be unconditionally stuck since the number of potential alternatives will grow as a power function of the code size and only problem subdivision can compensate for the growing complexities. /pwm On Mon, 9 May 2011, Jordan Burnam wrote: > Hey Everyone and good morning, > > I am in the process of creating a to do list console application and > seems I have hit a wall so to speak. Below I have an exert from my > actualy class. I have been trying to get this linked list working and so > far it has failed. I did not know if it was the driver program that was > failing, the class as a whole or this new code. I have excerted this > code into another compiler and have tried to run it by itslef, Upon > running it the console states it has encountered and error and closes. I > have used the debugging mode on my compiler and it fails once it gets to > the first line to create a new varalbe in the heap. I believe this is > becasue all of my dynamic memory on my PC may be full as I get the > "segmentation fault" error. I do not think that all the memory is in use > by the other programs. If anything I should be able to make one Node in > the memory. I just wanted to know before I change computers that it is > in fact the memory being used and not some stupid mistake that I have > made that is causing the problem. Any help would be fantastic! > > > <code> > > > #include <iostream> > #include <cstdlib> > #include <string> > > using namespace std; > > int main() > { > > int numstep; > struct step > { > int stepNum; > string Instruction; > }; > > > struct Node > { > struct step steppy; > Node *ptr_next_node; > }; > Node *Head; > Node *Curr; > Node *Last; > > > > > numstep = 5; > > > for( int i = 1; i <= numstep; i++) > { > (*Head).ptr_next_node = NULL; > if((*Head).ptr_next_node == NULL) > { > > Last = Head; > Curr = Head; > cout << " The " << i << "step, please enter the text for this setp and then press enter: "; > cin >> (*Head).steppy.Instruction; > (*Head).steppy.stepNum = i; > (*Head).ptr_next_node = new Node; > Curr = (*Head).ptr_next_node; > > } > > cout << "The " << i << " step, please enter the text for this step and then press enter: "; > cin >> (*Curr).steppy.Instruction; > (*Curr).steppy.stepNum = i; > (*Curr).ptr_next_node = new Node; > Last = Curr; > Curr = (*Curr).ptr_next_node; > } > > > > > return 0;} > > > </code> |
From: Fernando L. <fer...@gm...> - 2011-05-09 22:17:11
|
Jordan, Head is a pointer, you use it before you assign anything to it, that is probably the cause of the "segmentation fault". It has to be assigned an actual address before you use it. Best regards, Fernando On 9 May 2011 12:44, Jordan Burnam <jor...@me...> wrote: > Hey Everyone and good morning, > > I am in the process of creating a to do list console application and seems > I have hit a wall so to speak. Below I have an exert from my actualy class. > I have been trying to get this linked list working and so far it has failed. > I did not know if it was the driver program that was failing, the class as a > whole or this new code. I have excerted this code into another compiler and > have tried to run it by itslef, Upon running it the console states it has > encountered and error and closes. I have used the debugging mode on my > compiler and it fails once it gets to the first line to create a new varalbe > in the heap. I believe this is becasue all of my dynamic memory on my PC may > be full as I get the "segmentation fault" error. I do not think that all the > memory is in use by the other programs. If anything I should be able to make > one Node in the memory. I just wanted to know before I change computers that > it is in fact the memory being used and not some stupid mistake that I have > made that is causing the problem. Any help would be fantastic! > > > <code> > > > #include <iostream> > #include <cstdlib> > #include <string> > > using namespace std; > > int main() > { > > int numstep; > struct step > { > int stepNum; > string Instruction; > }; > > struct Node > { > struct step steppy; > Node *ptr_next_node; > }; > Node *Head; > Node *Curr; > Node *Last; > > > > > numstep = 5; > > > for( int i = 1; i <= numstep; i++) > { > (*Head).ptr_next_node = NULL; > if((*Head).ptr_next_node == NULL) > { > > Last = Head; > Curr = Head; > cout << " The " << i << "step, please enter the text for this setp and > then press enter: "; > cin >> (*Head).steppy.Instruction; > (*Head).steppy.stepNum = i; > (*Head)ptr_next_node = new Node; > Curr = (*Head).ptr_next_node; > > } > > cout << "The " << i << " step, please enter the text for this step and > then press enter: "; > cin >> (*Curr).steppy.Instruction; > (*Curr).steppy.stepNum = i; > (*Curr).ptr_next_node = new Node; > Last = Curr; > Curr = (*Curr).ptr_next_node; > } > > > > > return 0;} > > </code> > > > ------------------------------------------------------------------------------ > WhatsUp Gold - Download Free Network Management Software > The most intuitive, comprehensive, and cost-effective network > management toolset available today. Delivers lowest initial > acquisition cost and overall TCO of any competing solution. > http://p.sf.net/sfu/whatsupgold-sd > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > |
From: Michal M. <mol...@se...> - 2011-05-09 19:31:04
|
Dne 9.5.2011 17:44, Jordan Burnam napsal(a): > Node *Head; > Node *Curr; > Node *Last; > > > > > numstep = 5; > > > for( int i = 1; i <= numstep; i++) > { > (*Head).ptr_next_node = NULL; Here you are using Head but you haven't allocated it anywhere. There must be Head = new Node; before the for loop. > if((*Head).ptr_next_node == NULL) What is this good for? You just set it to NULL on previous line. > { > > Last = Head; > Curr = Head; > cout << " The " << i << "step, please enter the text for this setp and > then press enter: "; > cin >> (*Head).steppy.Instruction; > (*Head).steppy.stepNum = i; > (*Head)ptr_next_node = new Node; Probably missing . here. Note that (*x).y is the same as x->y in this case. > Curr = (*Head).ptr_next_node; > > } Here you probably intended "else". However it won't work because the if condition will always be true as explained above. > cout << "The " << i << " step, please enter the text for this step and > then press enter: "; > cin >> (*Curr).steppy.Instruction; > (*Curr).steppy.stepNum = i; > (*Curr).ptr_next_node = new Node; > Last = Curr; > Curr = (*Curr).ptr_next_node; =================================== Node *Head; Node *Curr; numstep = 5; Curr = Head = new Node; Head->ptr_next_node = NULL; for( int i = 1; i <= numstep; i++) { cout << " The " << i << "step, please enter the text for this setp and then press enter: "; cin >> Curr->steppy.Instruction; Curr->steppy.stepNum = i; Curr->ptr_next_node = i == numstep ? NULL : new Node; Curr = Curr->ptr_next_node; } Curr = Head; while(Curr) { cout << Curr->steppy.stepNum << " " << Curr->steppy.Instruction << endl; Curr = Curr->ptr_next_node; } |
From: Jordan B. <jor...@me...> - 2011-05-09 15:45:12
|
Hey Everyone and good morning, I am in the process of creating a to do list console application and seems I have hit a wall so to speak. Below I have an exert from my actualy class. I have been trying to get this linked list working and so far it has failed. I did not know if it was the driver program that was failing, the class as a whole or this new code. I have excerted this code into another compiler and have tried to run it by itslef, Upon running it the console states it has encountered and error and closes. I have used the debugging mode on my compiler and it fails once it gets to the first line to create a new varalbe in the heap. I believe this is becasue all of my dynamic memory on my PC may be full as I get the "segmentation fault" error. I do not think that all the memory is in use by the other programs. If anything I should be able to make one Node in the memory. I just wanted to know before I change computers that it is in fact the memory being used and not some stupid mistake that I have made that is causing the problem. Any help would be fantastic! <code> #include <iostream> #include <cstdlib> #include <string> using namespace std; int main() { int numstep; struct step { int stepNum; string Instruction; }; struct Node { struct step steppy; Node *ptr_next_node; }; Node *Head; Node *Curr; Node *Last; numstep = 5; for( int i = 1; i <= numstep; i++) { (*Head).ptr_next_node = NULL; if((*Head).ptr_next_node == NULL) { Last = Head; Curr = Head; cout << " The " << i << "step, please enter the text for this setp and then press enter: "; cin >> (*Head).steppy.Instruction; (*Head).steppy.stepNum = i; (*Head).ptr_next_node = new Node; Curr = (*Head).ptr_next_node; } cout << "The " << i << " step, please enter the text for this step and then press enter: "; cin >> (*Curr).steppy.Instruction; (*Curr).steppy.stepNum = i; (*Curr).ptr_next_node = new Node; Last = Curr; Curr = (*Curr).ptr_next_node; } return 0;} </code> |
From: Jordan B. <jor...@me...> - 2011-05-06 19:50:25
|
I have the below files iin visaul studio and it keeps advising me that I am missing a ';' before using or it will say I am missing a ';' after std and I can not find what the heck it is talking about. I know what the std and using is and as you can see from the code it is the correct places and spelled correctly. When put in another compiler it works fine. Any hep would be great. *************Below is the file in the "source file" folder****************************** <code> //Created: 05-06-2011 #include "task.h" #include <iostream> #include <cstdlib> using namespace std; int main() { char clientcode[8] = {'A','B','C','D','E','F'}; string name = "FIRST TEST PROCESS!!! DATA WILL NOT BE SAVED"; task t = task(clientcode, name); return 0;} </code> ***********************************END OF FILE********************************** BELOW THESE FILES ARE IN THE HEADER FILES ****************CLASS(SPECIFICATION*********************************************** <code> //Robert Burnam // Created: 05-03-2011 //This is the specification file for my task class #include <iostream> #include <cstdlib> using namespace std; class task { private: string taskName; string taskDescription; int UID; char clientCode[8]; int numstep; char answer; bool correct; struct step { int stepNum; string Instruction; }; step instructions [50]; tm timeinfo; tm TODAY; tm YESTERDAY; bool DUE; bool LATE; bool DONE; void setUID(); //This will set a random number as the UID for this task and so it is not altered this is a private functon public: task(char clientcode [], string processname); //This function will create a new task and prompt the user for the intput for each field; int getUID(); //This function will return the UID of this task. string getName(); //This function will return a string which is the name of this task void changeName(); //This function will prompt the user to change the name of this task string getClientCode(); //This function will return the clientCode array as a string for the useer to see void changeDescription(); //This will prompt the user what the description is now and allow them to change it. string getDescription(); //This will get the description and return it as a string to the main function. void ChangeInstructions(); //This function will prompt the user to change the Insturctions for the class step by step void displayInstructions(); //This will display the instructions step by step for this task void changeDueTime(); //This function will prompt the user to change the time that the task is due. bool isDue(); //This function will decide wether or not the task is due ( will be true up to ten mintues fo the task being do) bool isLate(); //This function will decide if the task is late (this is only based off of time not date!) bool isDone(); // THis function returns wether the task has been completed or not </code> *******************END OF CLASS*************************** *************************Implementation File of class********************* //Robert Burnam //Created: 05-06-2011 //This is the implementation of the task program #include "task.h" #include <windows.h> #include <string> using namespace std; task :: task(char clientcode [], string processname) { cout << "You are now creating a new task for " << clientcode <<"." << endl; cout << "This task if for " << processname << " processing." <<endl; cout << "This task should be only somewhat specific and not too general." <<endl; cout << " For example, if you have to do Bankruptcies and Demographics for this client code, It may be better to use only one task for each one of the " << processname << "." << endl; //set the name of the task cout << "Now, we will need to fill in some information before this task can be completed." << endl; cout << "Anything before the colon below will describe what you are entering and will show any restrictions to what you can enter, in parathesis, if there are any." << endl; cout << "Name:" ; //cin >> taskName; cout << endl; cout << "Comments(if you do not have any type \" none \". Then press enter): " << endl; //cin >> taskDescription; cout <<"This takes care of the easy parts of creating this task. The next step will involve filling in each step indivivualy." << endl; cout << "If you need sometime to decide how many steps you will need and in which order they will be entered, please take your time as I will wait till time indefinite for your input!" << endl; cout << "I will first ask how many steps there are and then you are to enter the steps in numerical order you would like them to be listed starting with 1." << endl; do{ cout << " How many steps are there for this task to be completed?: "; cin >> numstep; cout << " It seems that I am going to be creating " << numstep << "." <<endl; cout << " If this is correct press y(yes) or n(no): "; cin >> answer; }while(correct == false); cout << endl; cout << "One moment, I am creating " << numstep << "s, should not take to long." << endl; } </code> ****************END OF IMPLEMENTATION FILE******** } |
From: William Mc C. <wil...@ms...> - 2011-05-06 09:52:08
|
http://plc-seeders.org/goods.html |
From: Per W. <pw...@ia...> - 2011-05-03 14:09:24
|
Yes, there are a number of n-log-n sorting algorithms. But there are no algorithm better than n-log-n. So worrying about the linear transfer times from moving list elements into a vector of pointers and then back again can not be a time issue when debating choices. Next thing is that many n-log-n algorithms does require direct-access to elements. If requiring traversals to locate the elements, then they will no longer be n-log-n. But a person who spends an hour or two with Google looking for different sort algorithms and looking for specific help on sorting lists should be able to quickly get a good view of what is recommendable solutions - obviously taking into account if the lists are always small or if the lists may have tens of thousands of entries where O(n^2) may be hundreds of times slower than O(n log n). If the OP did do as I suggested, he would be able to find the following (or similar) information about merge-sort (quote is from wikipedia but other sources of sorting algorithms would come to similar results): "Merge sort is often the best choice for sorting a linked list: in this situation it is relatively easy to implement a merge sort in such a way that it requires only .(1) extra space, and the slow random-access performance of a linked list makes some other algorithms (such as quicksort) perform poorly, and others (such as heapsort) completely impossible." So in my previous post, I was trying to debate two different things: The first thing I wanted to make clear was that a multipass solution (like copying data to an array) can match a single-pass algorithm since O(n) + O(n log n) + O (n) is still just O(n log n). And that a linked list means objects are accessed using pointers meaning that the array only needs to store these pointers and not the full node content. The second thing I wanted to make clear was that the net have lots of documentation about sort algorithms and about sorting of linked lists. So someone who don't know what to do can get far with quite limited time spent googling. Mailing lists and web forum are then great choices to ask questions if someone gets stuck after having spent that initial time reading up on a couple of available choices. It is way easier when someone comes back and say: "I have been trying to implement an insertion sort (since it is fast enough for my needs of no more than 100 elements) but now are stuck trying to ..." /pwm On Tue, 3 May 2011 mol...@se... wrote: > > > ------------ Pùvodní zpráva ------------ > > Od: Per Westermark <pw...@ia...> > > Pøedmìt: Re: [Dev-C++] Sorting Linked Lists and Array Members > > Datum: 03.5.2011 11:39:34 > > ---------------------------------------- > > It is very fast to walk through a linked list once and copy the element > > pointers into an array. That is a linear operation - one extra step for > > every extra element. > > > > Sorting an array taks n-log-n time which is the best possible for sorting. > > > > Rebuilding the linked list is one walk through the array, so linear time. > > > > So using an array is a good sorting method. > > > > Now try Google and look at bubble sort, insertion sort, merge sort, ... > > Merge sort is also n*logn; in fact it's often used on arrays as well. > The fact that sorting list in place may be slower than using temporary > array is because it needs more cpu instructions to traverse/manipulate a > list than an array. > > ------------------------------------------------------------------------------ > WhatsUp Gold - Download Free Network Management Software > The most intuitive, comprehensive, and cost-effective network > management toolset available today. Delivers lowest initial > acquisition cost and overall TCO of any competing solution. > http://p.sf.net/sfu/whatsupgold-sd > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: <mol...@se...> - 2011-05-03 13:41:36
|
> ------------ Původní zpráva ------------ > Od: Per Westermark <pw...@ia...> > Předmět: Re: [Dev-C++] Sorting Linked Lists and Array Members > Datum: 03.5.2011 11:39:34 > ---------------------------------------- > It is very fast to walk through a linked list once and copy the element > pointers into an array. That is a linear operation - one extra step for > every extra element. > > Sorting an array taks n-log-n time which is the best possible for sorting. > > Rebuilding the linked list is one walk through the array, so linear time. > > So using an array is a good sorting method. > > Now try Google and look at bubble sort, insertion sort, merge sort, ... Merge sort is also n*logn; in fact it's often used on arrays as well. The fact that sorting list in place may be slower than using temporary array is because it needs more cpu instructions to traverse/manipulate a list than an array. |
From: Per W. <pw...@ia...> - 2011-05-03 08:52:05
|
Large numbers of posts here. Note 1: School assignments are intended to be solved by the student. The student is intended to have the required knowledge to manage the tasks. Many schools do follow mailing lists and web forums (google works well for that) to catch students that offloads their work on the net. Note 2: Standard debugging work includes identifying corner cases. Things like: - what happens if first element is inserted/removed? - what happens if last element is inserted/removed? - what happens if internal (not first/last) element is inserted/removed? - what happens if there is no match? Should be trivial to step through the code in a debugger for the above four cases and see what happens. Note that if you have one pointer that is your "list" and points to the first element - what do you do when you remove this element? Note 3: You don't seem to have tried Google for finding information about how to sort linked lists. There is huge amounts of information. Note 4: You worry about time for copying if using a array for the sorting. But that means that you haven't spent any time learning about ordo - the cost of operations taking constant time O(1), proportional time O(n), quadratic time O(n^2) etc. It is very fast to walk through a linked list once and copy the element pointers into an array. That is a linear operation - one extra step for every extra element. Sorting an array taks n-log-n time which is the best possible for sorting. Rebuilding the linked list is one walk through the array, so linear time. So using an array is a good sorting method. Now try Google and look at bubble sort, insertion sort, merge sort, ... Now what do you find about efficiency? Do you still worry about any copying? You do realize that you only need to copy pointers - not any real content of the individual list elements? Note 5: Just about every function you are requested to add to your program ends up as a help request to this list. Isn't that a bit strange? Does your class mates also needs their own web forum or mailing list to get through? Or maybe they have looked in books about computer algorithms or have tried Google? Or just spends a bit more time debugging their code? Real programming means developers who sits and spends their own time solving problems. The world would ground to a stand-still if all development required people to ask for help on the net - and who would be competent enough to answer the questions if people don't learn to solve their own problems? Experience can't help, because bigger experience just means people starts working on more complex probems until they reach a level where they can't trivially write code but just have to spend lots of own time fighting with the problems at hand. When looking for a job, the job interview will focus a lot on your ability to solve problems. And many companies will not allow you to discuss your projects on the net, making it very hard to ask for magical online help. What would you do if you googled and found posts where developers from a major elevator manufactuer asks for help since they don't know how to safely calculate and regulate the speed of an elevator? If the developers for a car manufactuers asks about help on anti-lock break system configuration? If the alarm clock manufacturer needs help how to implement snooze functionality? /pwm On Mon, 2 May 2011, Jordan Burnam wrote: > Hey Everyone, > > I have the following function that I am implementing within a list class in order to be able to sort them. This list should sort the char array elements by the alphabet but so far have had little luck to implement this. At this point I know that I cannot compare the two values of the array with the ">" operand but if I type cast it to an int but then I also get the lowercase ASCII value for each letter and make it a constant to figure out which one goes first I could do it this way but there has to be an easier way to do this. Below I have pasted the entire program as to make it easier to understand the context of the function, the function in question is the very last one named "list_selection_sort". Any idea or comments would be much appreciated. > > Thanks, > Jordan > > <code> > > > > void list_selection_sort(Node_ptr &a_list) > > { > > Node_ptr currNode; > Node_ptr nextNode; > Node_ptr lastNode; > > int itiems = 1; > > > > > > currNode = a_list; > > while(currNode ->ptr_to_next_node != NULL) > > { > > currNode = currNode ->ptr_to_next_node; > > itiems++; > > > > } > > lastNode = currNode; > currNode = a_list; > nextNode = currNode ->ptr_to_next_node; > > while (itiems > 0) > { > if(currNode -> word[0] > nextNode -> word[0]) > { > curr > > > } > > else > { lastNode = currNode; > currNode = currNode ->ptr_to_next_node; > nextNode = currNode ->ptr_to_next_node;} > itiems--; > } > > system("pause"); > > } > > <\code> |
From: William Mc C. <wil...@ms...> - 2011-05-03 01:12:04
|
http://emisiontdt.com/goods.html |
From: Michal M. <mol...@se...> - 2011-05-02 18:22:51
|
Simple (bubble)sort can look like this: void swap(Node_ptr &list, Node_ptr n, Node_ptr next, Node_ptr prev) { n->ptr_to_next_node = next->ptr_to_next_node; next->ptr_to_next_node = n; if (prev) { prev->ptr_to_next_node = next; } else { /* we're at first node */ list = next; } } void sort(Node_ptr &list) { bool swapped; do { swapped = false; for (Node_ptr n = list, prev = NULL; n && n->ptr_to_next_node; prev = n, n = n->ptr_to_next_node) { Node_ptr next = n->ptr_to_next_node; if (strcmp(n->word, next->word) > 0) { swap(list, n, next, prev); swapped = true; } } } while (swapped); } |
From: Michal M. <mol...@se...> - 2011-05-02 06:30:58
|
Sorry for the formatting Dne 2.5.2011 4:33, Jordan Burnam napsal(a): > void linklist::append(int num) > { > node *newNode = new node; > node *nextNode = new node; > if (p == NULL) > { > p = newNode; > p ->data = num; > p->link = NULL; > } > > else { // missing > newNode = new node; > node * n = p; > while(n -> link){n = n -> link;} > n-> link = newNode; > > newNode -> data = num; > newNode -> link = NULL; } // missing > } > void linklist::next( int c, int num) > { > node *lastNode; you never read value of lastNode so can get rid of it > node *currNode; > node *nextNode; > > currNode = p; > lastNode = currNode; > nextNode = currNode -> link; the line above will fail if the list is empty, you should check that situation > > while(c != 0) > { > lastNode = currNode; > currNode = currNode -> link; > nextNode = currNode -> link; > c--; OK, but you should check if you are still inside the list if (currNode == NULL) { cerr << "linklist::next: outside the list" << endl; return; } > } > > node *newNode; > newNode = new node; > newNode -> data = num; > > currNode -> link = newNode; > newNode -> link = nextNode; > > } void linklist::del( int num ) { node * lastNode; node * currNode; currNode = p; lastNode = NULL; while(currNode != NULL) { if(currNode -> data == num) { if (lastNode) { lastNode->link = currNode->link; delete currNode; } else { // it was the first node in the list node* n = p; p = p->link; delete n; } return; } else { // should be here although it accidentally works even without them lastNode = currNode; currNode = currNode -> link; } // should be here although it accidentally works even without them } // if } // while cout << "Item not found" << endl; } > void linklist::display() should be OK int linklist:: count () { int count =0; node *a_node; a_node = p; while(a_node != NULL) { count++; a_node = a_node -> link; } return count;} |
From: Jordan B. <jor...@me...> - 2011-05-02 02:48:07
|
Hey Everyone, I have the following function that I am implementing within a list class in order to be able to sort them. This list should sort the char array elements by the alphabet but so far have had little luck to implement this. At this point I know that I cannot compare the two values of the array with the ">" operand but if I type cast it to an int but then I also get the lowercase ASCII value for each letter and make it a constant to figure out which one goes first I could do it this way but there has to be an easier way to do this. Below I have pasted the entire program as to make it easier to understand the context of the function, the function in question is the very last one named "list_selection_sort". Any idea or comments would be much appreciated. Thanks, Jordan <code> void list_selection_sort(Node_ptr &a_list) { Node_ptr currNode; Node_ptr nextNode; Node_ptr lastNode; int itiems = 1; currNode = a_list; while(currNode ->ptr_to_next_node != NULL) { currNode = currNode ->ptr_to_next_node; itiems++; } lastNode = currNode; currNode = a_list; nextNode = currNode ->ptr_to_next_node; while (itiems > 0) { if(currNode -> word[0] > nextNode -> word[0]) { curr } else { lastNode = currNode; currNode = currNode ->ptr_to_next_node; nextNode = currNode ->ptr_to_next_node;} itiems--; } system("pause"); } <\code> |
From: Jordan B. <jor...@me...> - 2011-05-02 02:30:26
|
I have the following code and have ran it through the debugger several times and still can not nail why it is acting so funny. I am doing this for a work project and am getting pretty desperate at this point with the meeting coming up and I still can not get down these simple linked lists program. As you can see the program should add the following numbers to the list and change as specified by the calls to the functions in respect to their arguments, The program will compile but has an infinite loop at the del function I belove as the memory fails once it gets to that location. Also when displaying the list the first time it does not show the digit 1 as it should. Upon displaying the list a second time it then shows it. Any help would be much appreciated. #include <iostream> using namespace std; class linklist { private: struct node { int data; node *link; }*p; public: linklist(); void append( int num ); void first( int num ); void next( int c, int num ); void del( int num ); void display(); int count(); ~linklist(); }; linklist::linklist() { p=NULL; } void linklist::append(int num) { node *newNode = new node; node *nextNode = new node; if (p == NULL) { p = newNode; p ->data = num; p->link = NULL; } else newNode = new node; node * n = p; while(n -> link){n = n -> link;} n-> link = newNode; newNode -> data = num; newNode -> link = NULL; } void linklist::first(int num) { node * newNode; newNode = new node; newNode -> data = num; newNode -> link = p; p = newNode; } void linklist::next( int c, int num) { node *lastNode; node *currNode; node *nextNode; currNode = p; lastNode = currNode; nextNode = currNode -> link; while(c != 0) { lastNode = currNode; currNode = currNode -> link; nextNode = currNode -> link; c--; } node *newNode; newNode = new node; newNode -> data = num; currNode -> link = newNode; newNode -> link = nextNode; } void linklist::del( int num ) { node * lastNode; node * currNode; node * nextNode; currNode = p; lastNode = currNode; nextNode = currNode -> link; while(currNode != NULL) { if(currNode -> data == num) { lastNode -> link = nextNode; break; } else lastNode = currNode; currNode = currNode -> link; nextNode = currNode -> link; } cout << "Itiems not found" << endl; } void linklist::display() { node * a_node; a_node = p; while(a_node != NULL) { cout << a_node -> data << endl; a_node = a_node -> link; } } int linklist:: count () { int count =1; node *a_node; if(p == NULL) { return count; } else { a_node = p; while(a_node -> link != NULL) { count++; a_node = a_node -> link; } } return count;} linklist::~linklist() { node *q; if( p == NULL ) return; while( p != NULL ) { q = p->link; delete p; p = q; } } void main() { cout << "Name: COMP 1302 Homework Four" << endl; cout << "Christine Kikuchi" << endl; cout << "Purpose: A simple list that will create a list," << endl; cout << " count the number of its elements, " << endl; cout << " and tell if an item is on the list." << endl; cout << endl; linklist ll; cout<<"No. of elements = "<<ll.count(); ll.append(12); ll.append(13); ll.append(23); ll.append(43); ll.append(44); ll.append(50); ll.first(2); ll.first(1); ll.next(3,333); ll.next(6,666); ll.display(); cout<<"\nNo. of elements = "<<ll.count(); cout << endl; ll.del(333); ll.del(12); ll.del(98); cout<<"\nNo. of elements = "<<ll.count(); cout << endl; ll.display(); system("pause"); } |
From: Michal M. <mol...@se...> - 2011-05-01 22:10:29
|
Dne 1.5.2011 18:21, Jordan Burnam napsal(a): > void linklist::append(int num) > { > node * newNode; > > if(p =NULL) should be if(p==NULL) > { > p = new node; > p -> data = num; > p -> link = newNode; should be p->link = NULL; > } > else { newNode = new node; node* n = p; while (n->link) { n = n->link; } n->link = newNode; > newNode -> data = num; newNode -> link = NULL; } // else > } > void linklist::first(int num) > { > node *newNode; > newNode = new node; newNode -> data = num; newNode -> link = p; p = newNode; > } |
From: Jordan B. <jor...@me...> - 2011-05-01 16:21:43
|
Below is the program that I have and am trying to fill in the blanks to help me better understand pointers. I have added the code to the append function and the first function I believe this is right but want to make sure I am heading in the right direction. The function "first" should add the variable being passed do it to the first of the list and the function append should add the element at the end of the list. #include <iostream> using namespace std; class linklist { private: struct node { int data; node *link; }*p; public: linklist(); void append( int num ); void first( int num ); void next( int c, int num ); void del( int num ); void display(); int count(); ~linklist(); }; linklist::linklist() { p=NULL; } void linklist::append(int num) { node * newNode; if(p =NULL) { p = new node; p -> data = num; p -> link = newNode; } else newNode -> data = num; newNode -> link = new node; newNode = newNode-> link; } void linklist::first(int num) { node *newNode; newNode = new node; newNode -> data = p -> data; newNode -> link = p -> link; p=NULL; p = new node; p -> data = num; p -> link = newNode; *newNode = NULL; } void linklist::next( int c, int num) { //Add implementation code here } void linklist::del( int num ) { //Add implementation code here } void linklist::display() { //Add implementation code here } linklist::~linklist() { node *q; if( p == NULL ) return; while( p != NULL ) { q = p->link; delete p; p = q; } } void main() { linklist ll; cout<<"No. of elements = "<<ll.count(); ll.append(12); llappend(13); ll.append(23); ll.append(43); ll.append(44); ll.append(50); ll.first(2); llfirst(1); ll.next(3,333); ll.next(6,666); ll.display(); cout<<"\nNo. of elements = "<<ll.count(); ll.del(333); ll.del(12); ll.del(98); cout<<"\nNo. of elements = "<<ll.count(); } |