Results 1 to 3 of 3

Thread: Circle linked list

  1. #1
    Junior Member
    Join Date
    Nov 2005
    Answers
    3

    Circle linked list

    one circle linked list is there how to find the starting node (first node) of the list


  2. #2
    Banned
    Join Date
    Oct 2007
    Answers
    173

    Re: Circle linked list

    the list.

    A good example of an application where circular linked list should be used is a timesharing problem solved by the operating system. In a timesharing environment, the operating system must maintain a list of present users and must alternately allow each user to use a small slice of CPU time, one user at a time. The operating system will pick a user, let him/her use a small amount of CPU time and then move on to the next user, etc. For this application, there should be no NIL pointers unless there is absolutely no one requesting CPU time.

    The insert, delete and search operations are similar to the singly linked list. In circular linked list, we should always maintain that the next node of the tail is linked to the head after the insertion and deletion operations:

    myList.tail^.next := myList.head



    The following is a procedure for inserting a node at the front of a circular linked list:

    Procedure CInsertFirst( var Head:ListType; X:InfoType);

    var

    NewNode:ListType; {Pointer to new node created}

    begin

    new(New Node); {Obtain a new node}

    NewNode^.Info: = X; {Store the information in the node}

    NewNode^.Link: = Head^.Link; {next node of the tail is linked to the head:}

    Head^.Link: = NewNode {Set Head to point to new node}

    end;



    Advantages:

    Each node is accessible from any node.
    Address of the first node is not needed.
    Certain operations, such as concatenation and splitting of string, is more efficient with circular linked list.
    Disadvantage:

    Danger of an infinite loop !


  3. #3
    Junior Member
    Join Date
    Mar 2008
    Answers
    1

    Re: Circle linked list

    Hold the address of the first element in a private / protected member variable.
    Create function IsFirst which compares the address of the element passed against the member variable address.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact