Thread: algorithm for this fucntion ?

  1. #16
    Temporal Apparition qubit67's Avatar
    Join Date
    Jan 2007
    Posts
    85

    you know what?

    Quote Originally Posted by QuantumPete View Post
    Don't bump threads.
    I will bump my thread if i have to, and I have to.
    So, take your your thumb out of your a&& and give me a hand here, or leave me alone, wont make a difference... Over the last week I have grown quite accustomed to the lack of assistance, excessive condescension and down right rude and impolite responses from some posters.
    This is a tech forum, not a political one, so either provide some god damn tech help or better still, join a gossip forum.

    Thanks for the assistance, again

  2. #17
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by qubit67 View Post
    Over the last week I have grown quite accustomed to the lack of assistance, excessive condescension and down right rude and impolite responses from some posters.
    so go join another forum.
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  3. #18
    Temporal Apparition qubit67's Avatar
    Join Date
    Jan 2007
    Posts
    85
    trust me, i am a step ahead...

    oh, and again, thanks for the help
    Last edited by qubit67; 09-26-2007 at 02:39 AM. Reason: ps

  4. #19
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > I will bump my thread if i have to, and I have to.
    http://cboard.cprogramming.com/annou...t.php?f=4&a=51
    5. Don't bump threads. (Bumping: posting messages on threads to move them up the list or to post on a thread that has been inactive for two weeks or longer).
    Sure, if you've got something new to add then feel free to post it, but just posting "bump" will either get your message deleted or your thread closed.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #20
    Temporal Apparition qubit67's Avatar
    Join Date
    Jan 2007
    Posts
    85
    Ok, sorry for bumping, I just hate being avoided.... ;P

  6. #21
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Ok, sorry for bumping, I just hate being avoided.... ;P
    Acting like a jackass doesn't encourage people to help you.... ;P

    *plonk*
    My best code is written with the delete key.

  7. #22
    Temporal Apparition qubit67's Avatar
    Join Date
    Jan 2007
    Posts
    85
    I know, I get so KraZy sometimes...

  8. #23
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    I still can't figure out why insert_into_list() would need to recurse down the sub-tree when matches() already does that anyway.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #24
    Temporal Apparition qubit67's Avatar
    Join Date
    Jan 2007
    Posts
    85
    My logic is that matches searches from the root of the whole tree down each level through each node using the compare function to find a value that matches. The search starts from the root and moves down one level to compare and so on and so forth. I am not doing an in order traversal at this point, only searching down per level from the root until a match is found.

    When I reach the first matching node, I stop searching the whole tree and using insert into list, traverse from the smallest value of the mini/sub tree structure comparing, and inserting into the list. This function returns the list when all matches are inserted, back to matches who in turn returns the completed list to the caller.
    Last edited by qubit67; 09-26-2007 at 08:43 PM.

  10. #25
    Temporal Apparition qubit67's Avatar
    Join Date
    Jan 2007
    Posts
    85

    the logic I am supposed to use

    ok, so I have found that the best approach to the matches function is to not make it recursive, but to have it call another function that is recursive, and pass it the list to insert the phrases into.

  11. #26
    Temporal Apparition qubit67's Avatar
    Join Date
    Jan 2007
    Posts
    85
    this works too:
    Code:
    list_t *matches (bstree_t *index_tree, char *prefix)
    {
    	int len, compare;
    	bstree_t *current_node, *sub_tree;
    	list_t *list;
    	
    	list = make_empty_list ();
    	
    	len = strlen (prefix);
    	
    	current_node = index_tree; 
    	
    	while (current_node != NULL)
    	{
    		compare = strncmp (prefix, current_node->phrase, len);
    		if (compare == 0)
    		{	
    			sub_tree = current_node; 
    			list = insert_into_list (list, sub_tree, prefix);
    			return list;
    		}
    		else if (compare < 0)
    			current_node = current_node->left; 
    		else
    			current_node = current_node->right;
    	}
    	return list;
    }
    i think it is my final solution.

  12. #27
    Temporal Apparition qubit67's Avatar
    Join Date
    Jan 2007
    Posts
    85
    In concluding this thread, It saddens me to see how people can act as a hinderance to someone trying to figure out something. Instead of SIMPLE answers and support, I had an uphill battle with the some of the other posters who after reading their comments need a serious attitude adjustment, you know who you are.

    I mean why ask me the same question over and over again...
    My answer/theory/logic was explained in simpler ways again and again and again...

    There was obvioulsy some miss understanding, all we needed was some positive encouragement and a few possible strategies to break through this barrier. I am not a god at c, (no one but God is), but at my current level of skill in the subject, I feel confident when seeing the other posters questions on the board that I would be able to contribute to them finding their solution. That was what I wanted to do when I joined and recieved help at the beginning of the year.

    Give back to others the good help I had recieved.

    Now I break from c for the moment and move to Haskell, I just feel empty and dissillusioned by it all. I thought all computer scientists were cool, sturdy, hearty people, not any more.

    So a BIG thanks to those who were patient with me and assisted me in understanding c; MacGyver, dwks, Salem, citizen, quzah, zacs7, nadroj, Happy_Reaper, iMalc, , ZuK, swoopy, , brewbuckm vart, laserlight, KONI, matsp, robwhit, ssharish2005, and any one else I may have left out.

    For those that gave me a hard time, you don't know me, and I'd suggest you think hard next time about how to approach someone you don't know...

    if(1)
    return karma;

    qubit67

  13. #28
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    FWIW, your attitude, as a beginner, changes the answers of those who have already been down a similar path.

    Do you want:
    1. A cheap simple answer in less than a minute than someone else spent sweat, blood, and tears on for much longer?
    2. Some guidance from such folk by asking humbly, and not merely spamming forums for answers?

    Yes, you can find stuff here or there. Didja ever think that those here might also be there?

    Maybe some folks, such as myself, act cruelly on occasion by seeming to provide kindness? It's done like this: first give you the cheap answer; next be silent.


    Your next replies are shaped by your first questions. Hopefully your coding experience gets no tougher.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  14. #29
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Instead of SIMPLE answers and support
    The answers are rarely simple. Do you want us to dumb things down into uselessness just to make it simple for you? You're in the wrong field if you want simple.

    >My answer/theory/logic was explained in simpler ways again and again and again...
    Not everyone thinks like you, slick. Sometimes you have to describe your logic multiple times before you stumble on an explanation that others can fully grasp.

    >I thought all computer scientists were cool, sturdy, hearty people, not any more.
    We're people. People have unique personalities, and if you can't handle that, go be a hermit in a cave somewhere, because you're going to be disillusioned everywhere you go if you expect everyone to meet your unrealistic expectations..

    >For those that gave me a hard time, you don't know me, and I'd suggest
    >you think hard next time about how to approach someone you don't know...
    For what it's worth, I love how you .......... and moan about people giving you a hard time and then explicitly name quzah as an exception.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Implement of a Fast Time Series Evaluation Algorithm
    By BiGreat in forum C Programming
    Replies: 7
    Last Post: 12-04-2007, 02:30 AM
  2. Replies: 4
    Last Post: 12-10-2006, 07:08 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM