C source code for a queue module that uses this design is posted on cuLearn

C source code for a queue module that uses this

This preview shows page 13 - 16 out of 16 pages.

C source code for a queue module that uses this design is posted on cuLearn Exercise: use memory diagrams to visualize the execution of the functions 10 20 30 front rear enqueue() adds a node after the current last node front() , dequeue() deal with the first node
Image of page 13
Circular Linked List Instead of assigning NULL to the next field of the last node in the list to mark the end of the list, arrange for the last node to refer to the first node Eliminate the pointer to the first node in the list ( front ), but keep the pointer to the last node ( rear ) 10 20 rear 40 first node last node 30
Image of page 14
Queue Implementation The last node in the list (the node referred to by rear ) is the rear of the queue The first node in the list (the node referred to by the last node) is the front of the queue 10 20 30 rear 40 front() , dequeue() deal with the first node enqueue() adds a node after the current last node
Image of page 15
Big “O” Notation Summary Operation/Data Structure Singly Linked List Singly Linked List with Tail Pointer Array Ring Array Add at end O(n) O(1) O(1) O(1) Add at beginning O(1) O(1) O(n) O(1) Remove from end O(n) O(n) O(1) O(1) Remove from beginning O(1) O(1) O(n) O(1) Delete all O(n) O(n) O(1) O(1) Add in order O(n) O(n) O(n) O(n)
Image of page 16

You've reached the end of your free preview.

Want to read all 16 pages?

  • Spring '12
  • schram
  • Array data structure

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes