DB Error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2

SELECT * FROM `user` the_table WHERE the_table.userid = DB Error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2

SELECT * FROM `user` the_table WHERE the_table.userid = C++ - Quicksort Algorithm for Strings Help? Running slowly? - iTechForums
Login
Search   Moderators Wanted: If you're interested please send your portfolio to info[at]itechforums.com
Welcome to the iTechForums.
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
To register now click here.
Latest Threads
Advertisements
Forum Statistics
Threads:
Posts: 2
Members:
Number of Users Online:
Welcome to our newest member,
Reply
 
Thread Tools Display Modes
  #1  
Old 02-20-2010, 06:34 PM
David David is offline
Member
 
Join Date: May 2008
Posts: 97
Default

C++ - Quicksort Algorithm for Strings Help? Running slowly?


C++ - Quicksort Algorithm for Strings Help? Running slowly?

I'm writing a Quicksort algorithm that sorts an array of strings. However, I am also under the requirement that is sorts this array based on a certain set of keys, stored in another array. For example, if I had the strings:

bear, cat, yellow

I might be requested to sort them by only the 2nd and 3rd characters, so the array of keys contains:

ea, at, el

I've got the algorithm working, but for some reason, it is very slow. I was just wondering if anyone could figure out where I'm going wrong. Keep in might that list is the array of strings, keylist is the matching array of keys, left is the left index to consider while partitioning, and right is the right index in this case. Here's the code (I know the formatting is going to get messed up, try to bear with it):

void quickSort(string *keylist, string *list, int left, int right){
if(left = right){
return;
}
int lhs = left;
int rhs = right - 1;
while(lhs rhs){
while(lhs = rhs keylist[lhs] = keylist[right]){
lhs++;
}
while(rhs = lhs keylist[rhs] = keylist[right]){
rhs--;
}
if(lhs rhs){
swap(keylist[lhs], keylist[rhs]);
swap(list[lhs], list[rhs]);
}
}
swap(keylist[lhs], keylist[right]);
swap(list[lhs], list[right]);
if(lhs 0){
quickSort(keylist, list, 0, lhs-1);
}
if(lhs right - 1){
quickSort(keylist, list, lhs + 1, right);
}
}

I know it's running slowly, because it takes longer than Bubble Sort for some larger, unsorted sets of data, and this should not be happening. The swap function just swaps pointers, so it is not in that function or in the fact that two arrays are passed in, since they are by reference. Any ideas? Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2  
Old 02-20-2010, 06:34 PM
sweety sweety is offline
Junior Member
 
Join Date: Jun 2008
Posts: 6
Default

i dont find any problem with the coding
i dont think the time to compute the result will be affected since we are passing 2 arrays by reference.
may under certain input sequences bubble sort will work faster than quick sort
try running t program for larger number of input samples
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ - Quicksort Algorithm for Strings Help? David Software Design & Algorithms 4 02-18-2010 07:07 PM
Quicksort Lomuto's algorithm? Elf Huang Software Design & Algorithms 1 01-22-2010 10:52 AM
Help Quicksort algorithm? honkeetonk Software Design & Algorithms 1 04-07-2009 05:20 PM
Why is the Quicksort is a popular sorting algorithm ? arkangels75 Software Design & Algorithms 0 06-04-2008 10:07 AM
Quicksort Algorithm Program in C++ Help? mcar_2185 Software Design & Algorithms 0 05-06-2008 10:15 AM

Your Ad Here

All times are GMT. The time now is 03:37 AM.