#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    0
    Rep Power
    0

    Intersection between Two Sorted List


    Dear all,

    I need to seek help with one of my tutorials, which i am terribly stuck with.

    The question is :

    Given two sorted lists, L1 and L2, and write a procedure to compute L1 n L2 (intersection) using only the basic list operations.


    I need a full running program for this question.
    But i only managed to get some simple codings done, which i don't even know if i am right.

    My simple codes :

    stack nodes;
    while (L1_cur_node != NULL or L2_cur_node != NULL)
    if (L1_cur_node.data = = L2_cur_node.data) {
    nodes.push (L1_cur_node.data);
    L1_cur_node = L1_cur_node.next;
    L2_cur_node = L2_cur_node.next
    } else if (L1_cur_node.data < L2_cur_node.data) {
    L1_cur_node = L1_cur_node.next;
    } else {
    L2_cur_node = L2_cur_node.next;
    }
    }


    Can someone please help me with a full running program?

    Thank you.

    lilpig
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    0
    Rep Power
    0
    I have got my program up and running already.
    Thanks for reading.

IMN logo majestic logo threadwatch logo seochat tools logo