Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.18 seconds.

  1. Replies
    7
    Views
    142

    You forgot the part where you tell readers what...

    You forgot the part where you tell readers what you are trying to do and how does it not work.
  2. You start off with n elements as the size of the...

    You start off with n elements as the size of the array. If there are any duplicates, after removing them, the size of the array would surely be less than n, but you did not update the value of n,...
  3. That's pretty vague: a scanf call can have...

    That's pretty vague: a scanf call can have various format specifiers and various corresponding arguments. Show the code.
  4. What you need to do is to compile at a high...

    What you need to do is to compile at a high warning level, and pay attention to warnings. Actually, even at a low warning level your compiler is probably warning you about a typo error in your third...
  5. I already told you: do a linear search of the...

    I already told you: do a linear search of the entire linked list.

    If you find this too difficult, try another problem first: find the smallest number in the linked list.

    EDIT:
    I'd also suggest...
  6. It sounds pretty straightforward since you...

    It sounds pretty straightforward since you already have an idea: what you're doing is finding the least number greater than the given number, so a linear search of the entire linked list should do...
  7. Replies
    33
    Views
    545

    Congratulations, it looks like you've implemented...

    Congratulations, it looks like you've implemented a working solution. I might tweak it a bit:

    void insertTail(list_t *list, node_t *node)
    {
    node->prev = list->tail;
    node->next = NULL;
    ...
  8. Replies
    33
    Views
    545

    You have it backwards. "Next" means "being the...

    You have it backwards. "Next" means "being the first one after the present one or after the one just mentioned". The next pointer links to the node after the current node, not the node before it,...
  9. Replies
    33
    Views
    545

    You have the right idea to treat the empty linked...

    You have the right idea to treat the empty linked list separately from a linked list that already has nodes. However, you have indeed made a mistake for the case where the linked list already has one...
  10. Replies
    33
    Views
    545

    If you excuse the ASCII art, this is how your...

    If you excuse the ASCII art, this is how your final diagram should look if you append 6 and then append 7 ("append" means "insert at the end", i.e., for a linked list it means "insert after the...
  11. Replies
    33
    Views
    545

    Ah, I should have been clearer: the head and tail...

    Ah, I should have been clearer: the head and tail boxes are meant for you to keep track of what is the head and what is the tail. You should not draw any arrows to them because they represent...
  12. Thread: Composition

    by laserlight
    Replies
    11
    Views
    566

    Ah, I see. When I was reading through it...

    Ah, I see. When I was reading through it previously, I was thinking that this was a bad idea to introduce so early in that tutorial, and it appears that my hunch was correct. As much as I am happy to...
  13. Replies
    33
    Views
    545

    Excellent. Now here's what you need to do: take a...

    Excellent. Now here's what you need to do: take a sheet of paper and a pencil. Pretend that you're executing your insertTail function, but on paper. So you draw a box, and put in 6 for the value....
  14. Replies
    33
    Views
    545

    What is the code of the insertTail function? ...

    What is the code of the insertTail function?

    Also, did you fix printlist to take a pointer to list_t argument?
  15. Replies
    33
    Views
    545

    Nodes don't have tails. What this does is set the...

    Nodes don't have tails. What this does is set the prev pointer of the node to be the tail of the linked list. This means that we're about to make this node the new tail of the linked list.


    Yes,...
  16. Replies
    33
    Views
    545

    Your linked list has a head node and a tail node,...

    Your linked list has a head node and a tail node, which it stores as pointers to the node objects. You could do without the list object: then you would pass pointers to the head node and the tail...
  17. Thread: Composition

    by laserlight
    Replies
    11
    Views
    566

    I mean, I explicitly wrote "if you have a...

    I mean, I explicitly wrote "if you have a reference or (smart) pointer to a Vehicle, you can invoke the StartVehicle() method, and the appropriate overriden method for the Vehicle derived class will...
  18. Replies
    33
    Views
    545

    Yes. Yes. Something like that, but you need...

    Yes.


    Yes. Something like that, but you need to compile and find out.


    What does this mean?

    list->tail = NULL;
    What does this mean?
  19. Replies
    33
    Views
    545

    The first thing I'd do is rename the insert...

    The first thing I'd do is rename the insert function: does it insert at the tail? Then name it append or tail_insert. Does it insert at the head? Then name it prepend or head_insert. Just calling it...
  20. Replies
    2
    Views
    159

    This should be declared within the main function:...

    This should be declared within the main function:

    struct tstr_node *head;
    This is not correct:

    int sorted_list_insert(head , pstr_node);
    You should include the parameter types in the function...
  21. Thread: Composition

    by laserlight
    Replies
    11
    Views
    566

    thmm: I'd say that's more relevant for dispatch...

    thmm: I'd say that's more relevant for dispatch among types that don't have a supertype/subtype relationship. In this case, the use of inheritance as in your example becomes useless (unless it was...
  22. Replies
    33
    Views
    545

    Yes, but note that that will only free the memory...

    Yes, but note that that will only free the memory allocated for the list_t object, not the memory for its nodes, if any.
  23. Thread: Composition

    by laserlight
    Replies
    11
    Views
    566

    If john.c's hunch is right, then yes, you should...

    If john.c's hunch is right, then yes, you should be linking to the other places where you've asked this.

    A few things stand out for me:

    friend std::ostream& operator<<(std::ostream& os, const...
  24. Replies
    33
    Views
    545

    This is wrong: void initList(list_t *list) {...

    This is wrong:

    void initList(list_t *list)
    {
    list = (list_t*)malloc(sizeof(list_t));
    list->head = NULL;
    list->size = 0;
    }
    The problem is that you are assigning the result of...
  25. Replies
    2
    Views
    165

    You forgot about the parameter type, i.e., ...

    You forgot about the parameter type, i.e.,

    void printlist(list_t list)
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4