1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

linked list

Discussion in 'C' started by maverick, Dec 6, 2006.

  1. maverick

    maverick New Member

    Joined:
    Dec 5, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    i need to read matrix and i have to use linked list.for example how can i implement 4*5 matrix with two dimensional linked list?thanks for ur help
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
  3. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    A linked list is a degenerate form of a tree. If you make a linked list (which is linear) multidimensional, it ceases to be a list. It could be either a tree or a graph. If you want more help, you're going to have to be more specific. My crystal is in the shop for ball joints.
     
  4. maverick

    maverick New Member

    Joined:
    Dec 5, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    for examle i have to read 3*3 matrix from txt file like 4 5 2
    3 3 5
    2 1 6
    and do some operations like add new row,column,delete row,column.i decide to use doubly linked list.For examle 4(which is first element of matrix) have two links which are show next and below node.how can i do this??
     
  5. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    Your terminology is incorrect. A doubly-linked list is a structure in which each node has a pointer to the next node and to the previous node. As I mentioned in my previous post, what you are describing is a tree. For instance, a binary tree node has pointers to two children. This does not make it a doubly-linked list. Perhaps if you directed your efforts toward trees, rather than linked lists, you would have a clearer view of your problem and its requirements. If someone has imposed upon you the requirement of using a linked list, then I'd suggest you use an array or vector of linked lists. You could also use one form of a general tree. In a general tree a node has a pointer to a child; the siblings of a child are pointed to by the child, and are essentially a linked list. Each node in the list, however, is a general tree node which can also point to it's primary child. In a situation such as your matrix, you are redefining the tree structure such that a node may have multiple children, and children may have multiple parents. I have done this with some game trees, but one can easily get into some serious conceptual and implementation issues.
     
  6. maverick

    maverick New Member

    Joined:
    Dec 5, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    when we think matrix cant i do that each node points to the next node and below node?cant u understand that what i want to say for below node?why cant i use below node instead of prev node?thanks for dealing;)
     
  7. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    I'm not saying you can't do what you propose. I'm saying you are incorrect in referring to it as a doubly-linked list. It is not. Your unfortunate misuse of terminology causes your potential respondents to go off on a tangent and offer help for what you SAID, not for what you WANT.

    I recommend that you take a few minutes to clarify your thinking so that you can formulate your request effectively, without misinformation that sidetracks the process. Information (correct information) is key. You might also want to read Smart Questions.
     
  8. maverick

    maverick New Member

    Joined:
    Dec 5, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    did u understand what my problem is?do u have any idea to do this with linked list?(it is not important to do with singly,doubly,two dimensional linked-list)
     
  9. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    I understand exactly what you want to do (and can do it forty-leben different ways). The problem seems to be that you don't. That's the part you need to tackle. We all understand that you have a matrix. It's unlikely that we're going to do your assignment for you. You devise a scheme, you write some code, and you post where you're having problems. Then it's our turn to volunteer our efforts.
     

Share This Page