linked list (c#)


Published on

presentation for link lis in c++

Published in: Education, Technology
1 Comment
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • In the above code, we execute a for loop to traverse the array. The number of execution of this loop is equal to the size of the list. This for loop gets terminated when the value of loop variable ( j ) increases from the size of the list. However we terminate the loop with the break statement if the element is found at a position. When the control comes out from the loop, we check the value of j . If the value of j is less than the size of the array, it means that the loop was terminated by the break statement. We use the break statement when we find the required element (x) in the list. The execution of break statement shows that the required element was found at the position equal to the value of j . So the program sets the current position to j and comes out the function by returning 1 (i.e. true). If the value of j is greater than the size of the array, it means that the whole array has traversed and the required element is not found. So we simply return 0 (i.e. false) and come out of the function.
  • You may notice here that we are returning the size {in the length () }of the list and not the size of the array being used internally to implement the list. This size is the number of the elements of the list, stored in the array.
  • Add example from pg: 115
  • You don't need to use pointers to create a linked list in C#. Just store an object reference to the next list element.
  • Fig: Pg 194
  • linked list (c#)

    1. 3. List data structure <ul><li>This is a new data structure. </li></ul><ul><li>The List data structure is among the most generic of data structures. In daily life, we use shopping list, groceries list, list of people to invite to a dinner, list of presents to give etc. In this course, we will see how we use lists in programming. </li></ul><ul><li>A list is the collection of items of the same type. </li></ul><ul><li>The items, or elements of the list, are stored in some particular order. </li></ul><ul><li>It is possible to insert new elements at various positions in the list and remove any element of the list. </li></ul>
    2. 4. List data structure <ul><li>List is a set of elements in a linear order. Suppose we have four names a1, a2, a3, a4 and their order is as (a3, a1, a2, a4) i.e. a3 , is the first element, a1 is the second element, and so on. </li></ul><ul><li>The order is important here; this order is either due to sorting, the order may be due to the importance of the data items. </li></ul>
    3. 5. Operations a programmer performs with a list data structure. Operation Name Description createList() Create a new list (presumably empty) copy() Set one list to be a copy of another clear(); Clear a list (remove all elements) insert(X, ?) Insert element X at a particular position in the list remove(?) Remove element at some position in the list get(?) Get element at a given position update(X, ?) Replace the element at a given position with X find(X) Determine if the element X is in the list length() Returns the length of the list.
    4. 6. List Data Structure <ul><li>We need to know what is meant by “particular position”. There are two possibilities:  </li></ul><ul><ul><li>Use the actual index of element: i.e. insert it after element 3, get element number 6. This approach is used with arrays </li></ul></ul><ul><ul><li>Use a “current” marker or pointer to refer to a particular position in the list. </li></ul></ul><ul><li>The first option is used in the data structures like arrays. When we have to manipulate the arrays, we use index like x[3], x[6] . </li></ul><ul><li>In the second option we do not use first, second etc for position but say wherever is the current pointer. Just think of a pointer in the list that we can move forward or backward. When we say get, insert or update while using the current pointer, it means that wherever is the current pointer, get data from that position, insert data after that position or update the data at that position. In this case, we need not to use numbers. But it is our responsibility that current pointer is used in a proper way. </li></ul>
    5. 7. List Data Structure <ul><li>If we use the “current” marker, the following four methods would be useful: </li></ul>Functions Description start() Moves the “current” pointer to the very first element tail() Moves the “current” pointer to the very last element next() Move the current position forward one element back() Move the current position backward one element
    6. 8. List Implementation <ul><li>Now we will see what the implementation of the list is and how one can create a list. </li></ul><ul><li>Suppose we want to create a list of integers. For this purpose, the methods of the list can be implemented with the use of an array inside. </li></ul><ul><li>For example, the list of integers A= (2, 6, 8, 7, 1) can be represented in the following manner where the current position is 3. </li></ul>A 2 6 8 7 1 current size Index 1 2 3 4 5 3 5
    7. 9. add Method <ul><li>The add method is used for adding an element to the list. </li></ul><ul><li>Suppose we want to add a new element in the list i.e. add(9) . </li></ul><ul><li>To add(9) to the list at the current position, at first, we have to make space for this element. For this purpose, we shift every element on the right of 8 (the current position) to one place on the right. Thus after creating the space for new element at position 4, the array can be represented as </li></ul><ul><li>Now in the second step, we put the element 9 at the empty space i.e. position 4. </li></ul><ul><li>Thus the array will attain the following shape . </li></ul>A 2 6 8 7 1 current size Index 1 2 3 4 5 4 5 A 2 6 8 9 7 1 current size Index 1 2 3 4 5 6 4 6
    8. 10. next Method <ul><li>The next method moves the current position one position forward. </li></ul><ul><li>In this method, we do not add a new element to the list but simply move the pointer one element ahead. </li></ul><ul><li>There is an array to store the list in it. We also have two variables- current and size to store the position of current pointer and the number of elements in the list. </li></ul>
    9. 11. remove Method <ul><li>The remove method removes the element residing at the current position. </li></ul><ul><li>Suppose there are 6 elements (2, 6, 8, 9, 7, 1) in the list. The current pointer is pointing to the position 5 that has the value 7. We remove the element, making the current position empty. The size of the list will become 5. This is represented in the following figure. </li></ul><ul><li>We fill in the blank position left by the removal of 7 by shifting the values on the right of position 5 to the left by one space. This means that we shift the remaining elements on the right hand side of the current position one place to the left </li></ul>A 2 6 8 9 1 current size Index 1 2 3 4 5 6 5 6 5 A 2 6 8 9 1 current size Index 1 2 3 4 5 5 5
    10. 12. find Method <ul><li>find (x) function is used to find a specific element in the array. </li></ul><ul><li>We pass the element, which is to be found, as an argument to the find function. This function then traverses the array until the specific element is found. </li></ul><ul><li>If the element is found, this function sets the current position to it and returns 1 i.e. true. </li></ul><ul><li>On the other hand, if the element is not found, the function returns 0 i.e. false. </li></ul><ul><li>Following is the code of this find(x) function in C++. </li></ul><ul><li>int find (int x) </li></ul><ul><li>{ </li></ul><ul><li>int j ; </li></ul><ul><li>for (j = 1; j < size + 1; j++ ) </li></ul><ul><li> if (A[j] == x ) </li></ul><ul><li> break ; </li></ul><ul><li>if ( j < size + 1) // x is found </li></ul><ul><li>{ current = j ; //current points to the position where x found </li></ul><ul><li> return 1 ; // return true </li></ul><ul><li>} </li></ul><ul><li>return 0 ; //return false, x is not found </li></ul><ul><li>} </li></ul><ul><li>  </li></ul>
    11. 13. Other Methods <ul><li>There is a get() method , used to get the element from the current position in the array. </li></ul><ul><li>  return A[current] ; </li></ul><ul><li>Another function is update(x) . This method is used to change (set) the value at the current position. A [current] = x ; </li></ul><ul><li>Then there is a method length( ) .This method returns the size of the list. </li></ul><ul><li>return size ; </li></ul><ul><li>The back() method decreases the value of variable current by 1. In other words, it moves the current position one element backward. current -- ; </li></ul><ul><li>The start() method sets the current position to the first element of the list. We know that the index of the array starts from 0 but we use the index 1 for the starting position. We do not use the index zero. So we set the current position to the first element by writing. </li></ul><ul><li>current = 1 ; </li></ul><ul><li>Similarly, the end() method sets the current position to the last element of the list i.e. size . </li></ul><ul><li>current = size ; </li></ul><ul><li>  </li></ul>
    12. 14. Analysis of Array List <ul><li>Add </li></ul><ul><ul><li>Worst Case: To add an element at the beginning of the list is the worst case of add method. </li></ul></ul><ul><ul><li>Best Case: We have to shift no element if we add at the end. </li></ul></ul><ul><li>Remove </li></ul><ul><ul><li>Worst Case: To remove an element at the beginning of the list is the worst case of remove method. </li></ul></ul><ul><ul><li>Average Case: In average cases of the remove method we expect to shift half of the elements. </li></ul></ul><ul><ul><li>Best Case: We have to shift no element if we remove at the end. </li></ul></ul><ul><li>Find </li></ul><ul><ul><li>Worst Case: The worst case of the find method is that it has to search the entire list from beginning to end. </li></ul></ul><ul><ul><li>Average Case: On average the find method searches at most half the list. </li></ul></ul>
    13. 16. List using Linked Memory <ul><li>When we have declared the size of the array, it is not possible to increase or decrease it during the execution of the program. If we need more elements to store in the array, there is need of changing its size in the declaration. We have to compile the program again before executing it. </li></ul><ul><li>To avoid such problems, usually faced by the programmers while using an array, there is need of using linked memory in which the various cells of memory, are not located continuously. </li></ul><ul><li>In this process, each cell of the memory not only contains the value of the element but also the information where the next element of the list is residing in the memory. </li></ul><ul><li>It is not necessary that the next element is at the next location in the memory. It may be anywhere in the memory. We have to keep a track of it. </li></ul>
    14. 17. For the utilization of the concept of linked memory, we usually define a structure, called linked list.
    15. 18. Linked Lists <ul><li>A linked list, or one-way list is a linear collection of data elements called nodes, where linear order is given by means of pointer. </li></ul><ul><li>A linked list is a series of connected nodes </li></ul><ul><li>Each node contains at least </li></ul><ul><ul><li>A piece of data (any type) </li></ul></ul><ul><ul><li>Pointer to the next node in the list </li></ul></ul><ul><li>Head : pointer to the first node </li></ul><ul><li>The last node points to NULL </li></ul> Head data pointer node A B C A
    16. 19. Linked List <ul><li>Now let’s consider our previous list, used with an array i.e. 2, 6, 8, 7, 1. Following is the figure which represents the list stored as a linked list. </li></ul><ul><li>We also have a pointer current to point to the current node of the list. We need this pointer to add or remove current node from the list. </li></ul><ul><li>In the linked list, the current is a pointer and not an index as we used while using an array. </li></ul>Head  Current 2 6 1 7 8
    17. 20. Representation of Link List in Computer Memory
    18. 21. Inserting a new node <ul><li>Possible cases of Insertion </li></ul><ul><ul><li>Insert into an empty list </li></ul></ul><ul><ul><li>Insert in front </li></ul></ul><ul><ul><li>Insert at back </li></ul></ul><ul><ul><li>Insert in middle </li></ul></ul><ul><li>But, in fact, only need to handle two cases </li></ul><ul><ul><li>Insert as the first node (Case 1 and Case 2) </li></ul></ul><ul><ul><li>Insert in the middle or at the end of the list (Case 3 and Case 4) </li></ul></ul>
    19. 22. Inserting to the Front <ul><li>Allocate a new node </li></ul><ul><li>Insert new element </li></ul><ul><li>Have new node point to old head </li></ul><ul><li>Update head to point to new node </li></ul>head 48 17 142 head 93
    20. 23. Inserting to the End <ul><li>Allocate a new node </li></ul><ul><li>Insert new element </li></ul><ul><li>Have new node point to null </li></ul><ul><li>Have old last node point to new node </li></ul><ul><li>Update tail to point to new node </li></ul>48 17 142 head // 93 //
    21. 24. Inserting to the Middle <ul><li>Allocate a new node </li></ul><ul><li>Insert new element </li></ul><ul><li>Go to the node that should follow the one to add </li></ul><ul><li>Have that node point to the new node </li></ul><ul><li>Have new node point to node next node to the found node </li></ul>17 48 142 head // 93 // 142
    22. 25. Searching a Linked List <ul><li>Searching refers to finding a particular ITEM in the data. </li></ul><ul><li>Binary search algorithm can not be applied to sorted link list since there is no way indexing the middle element in the list. This property is one of the main drawbacks in using a linked list as a data structure </li></ul>
    23. 26. Deleting a node <ul><li>Possible cases of Deletion </li></ul><ul><ul><li>Delete in front </li></ul></ul><ul><ul><li>Delete at back </li></ul></ul><ul><ul><li>Delete in middle </li></ul></ul><ul><li>There are two special cases </li></ul><ul><ul><li>Delete first node </li></ul></ul><ul><ul><li>Delete the node in middle or at the end of the list </li></ul></ul>
    24. 27. The Scenario 4 17 head 4 17 head 4 17 head 4 17 head 42 6 42 6 42 42
    25. 28. Traversing a Link List <ul><li>Traversal means “visiting” or examining each node. </li></ul><ul><li>Simple linked list </li></ul><ul><ul><li>Start at the beginning </li></ul></ul><ul><ul><li>Go one node at a time until the end </li></ul></ul>
    26. 29. Link List in C# <ul><li>A linked list is a collection of class objects called nodes. </li></ul><ul><li>Each node is linked to its successor node in the list using a reference to the successor node. </li></ul><ul><li>A node is made up of a field for storing data and the field for the node reference. </li></ul><ul><li>The reference to another node is called a link. </li></ul>
    27. 30. AN OBJECT-ORIENTED LINKED LIST DESIGN <ul><li>A linked list will involve at least two classes. </li></ul><ul><li>We’ll create a Node class and instantiate a Node object each time we add a node to the list. </li></ul><ul><li>The nodes in the list are connected via references to other nodes. </li></ul><ul><li>These references are set using methods created in a separate LinkedList class. </li></ul>
    28. 31. The Node Class <ul><li>A node is made up of two data members: Element, which stores the node’s data; and Link, which stores a reference to the next node in the list. </li></ul><ul><li>Here’s the code for the Node class: </li></ul><ul><ul><ul><ul><li>public class Node { </li></ul></ul></ul></ul><ul><ul><ul><ul><li>public Object Element; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>public Node Link; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>public Node() { </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Element = null; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Link = null; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>} </li></ul></ul></ul></ul><ul><ul><ul><ul><li>public Node(Object theElement) { </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Element = theElement; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Link = null; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>} </li></ul></ul></ul></ul><ul><ul><ul><ul><li>} </li></ul></ul></ul></ul>
    29. 32. The LinkedList Class <ul><li>The LinkedList class is used to create the linkage for the nodes of our linked list. The class includes several methods for adding nodes to the list, removing nodes from the list, traversing the list, and finding a node in the list. </li></ul><ul><li>Here’s the code for the LinkedList class: </li></ul><ul><ul><ul><ul><li>public class LinkedList { </li></ul></ul></ul></ul><ul><ul><ul><ul><li>protected Node header; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>public LinkedList() { </li></ul></ul></ul></ul><ul><ul><ul><ul><li>header = new Node(); </li></ul></ul></ul></ul><ul><ul><ul><ul><li>} </li></ul></ul></ul></ul><ul><ul><ul><ul><li>. . . </li></ul></ul></ul></ul><ul><ul><ul><ul><li>} </li></ul></ul></ul></ul>
    30. 33. Insert Method <ul><ul><ul><ul><li>private Node Find(Object item) { </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Node current = new Node(); </li></ul></ul></ul></ul><ul><ul><ul><ul><li>current = header; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>while(current.header != item) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>current = current.Link; </li></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>return current; </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><li>} </li></ul></ul></ul></ul><ul><ul><ul><ul><li>public void Insert(Object newItem, Object after) { </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Node current = new Node(); </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Node newNode = new Node(newItem); </li></ul></ul></ul></ul><ul><ul><ul><ul><li>current = Find(after); </li></ul></ul></ul></ul><ul><ul><ul><ul><li>newNode.Link = current.Link; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>current.Link = newNode; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>} </li></ul></ul></ul></ul>
    31. 34. Remove Method <ul><ul><ul><ul><li>private Node FindPrevious(Object n) { </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Node current = header; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>while(!(current.Link == null) && (current.Link.Element != n)) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>current = current.Link; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>return current; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>} </li></ul></ul></ul></ul><ul><ul><ul><ul><li>public void Remove(Object n) { </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Node p = FindPrevious(n); </li></ul></ul></ul></ul><ul><ul><ul><ul><li>if (!(p.Link == null)) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>p.Link = p.Link.Link; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>} </li></ul></ul></ul></ul>
    32. 35. PrintList Method <ul><ul><ul><ul><li>public void PrintList() { </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Node current = new Node(); </li></ul></ul></ul></ul><ul><ul><ul><ul><li>current = header; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>while (!(current.Link == null)) { </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Console.WriteLine(current.Link.Element); </li></ul></ul></ul></ul><ul><ul><ul><ul><li>current = current.Link; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>} </li></ul></ul></ul></ul><ul><ul><ul><ul><li>} </li></ul></ul></ul></ul>
    33. 36. Analysis of Link List <ul><li>add and remove </li></ul><ul><ul><li>In case of an array, if we have to add an element in the centre of the array, the space for it is created at first. For this, all the elements that are after the current pointer in the array, should be shifted one place to the right. </li></ul></ul><ul><ul><li>In Link List we insert a new node after the current node in the chain. For this, we have to change two or three pointers while changing the values of some pointer variables. Its cost, in terms of CPU time or computing time, is not much as compared to the one with the use of arrays. </li></ul></ul>
    34. 37. Analysis of Link List <ul><li>find </li></ul><ul><ul><li>The worst-case in find is that we may have to search the entire list. In find, we have to search some particular element say x . If found, the currentNode pointer is moved at that node. </li></ul></ul><ul><ul><li>As there is no order in the list, we have to start search from the beginning of the list. We have to check the value of each node and compare it with x (value to be searched). </li></ul></ul><ul><ul><li>If found, it returns true and points the currentNode pointer at that node otherwise return false. Suppose that x is not in the list, in this case, we have to search the list from start to end and return false. </li></ul></ul><ul><ul><li>If we compare this with array, it will be the same. We don’t know whether x is in the array or not. So we have to search the complete array. </li></ul></ul>
    35. 38. Variations of Linked Lists <ul><li>Doubly linked lists </li></ul><ul><ul><li>Each node points to not only successor but the predecessor </li></ul></ul><ul><ul><li>There are two NULL: at the first and last nodes in the list </li></ul></ul><ul><ul><li>Advantage: given a node, it is easy to visit its predecessor. Convenient to traverse lists backwards </li></ul></ul>Head   A B C
    36. 39. Variations of Linked Lists <ul><li>Circular linked lists </li></ul><ul><ul><li>The last node points to the first node of the list </li></ul></ul><ul><ul><li>How do we know when we have finished traversing the list? (Tip: check if the pointer of the current node is equal to the head.) </li></ul></ul>Head A B C
    37. 40. Josephus Problem <ul><li>Consider there are 10 persons. They would like to choose a leader. The way they decide is that all 10 sit in a circle. They start a count with person 1 and go in clockwise direction and skip 3. Person 4 reached is eliminated. The count starts with the fifth and the next person to go is the fourth in count. Eventually, a single person remains. </li></ul>2 3 4 5 6 7 8 9 10 N=10, M=3 4 5 6 7 8 9 10 1 2 3 Eliminated
    38. 41. Josephus Problem <ul><li>Suppose if the value of N is 300 or 400 and the value of M is 5 or 10. Now who will be the leader? </li></ul><ul><li>This is a mathematical problem where we can change the values of N and M . There is a formula where the values of N , M are allotted. You can calculate who should become the leader. </li></ul><ul><li>Here we will solve this with the circular link list. We arrange these numbers in a circularly-linked list, point the head pointer at the starting number and after calling the next method for three times, we will reach the node which is to be removed. We will use the remove method to remove the node. Then the next method is called thrice from there and the node is removed. We will continue this till we have only one node. </li></ul>
    39. 42. Array versus Linked Lists <ul><li>Linked lists are more complex to code and manage than arrays, but they have some distinct advantages. </li></ul><ul><ul><li>Dynamic : a linked list can easily grow and shrink in size. </li></ul></ul><ul><ul><ul><li>We don’t need to know how many nodes will be in the list. They are created in memory as needed. </li></ul></ul></ul><ul><ul><ul><li>In contrast, the size of a C++ array is fixed at compilation time. </li></ul></ul></ul><ul><ul><li>Easy and fast insertions and deletions </li></ul></ul><ul><ul><ul><li>To insert or delete an element in an array, we need to copy to temporary variables to make room for new elements or close the gap caused by deleted elements. </li></ul></ul></ul><ul><ul><ul><li>With a linked list, no need to move other nodes. Only need to reset some pointers. </li></ul></ul></ul>
    40. 43. What is a Priority Queues? <ul><li>Stores prioritized elements </li></ul><ul><ul><li>No notion of storing at particular position. </li></ul></ul><ul><li>Returns elements in priority order </li></ul><ul><ul><li>Order determined by key. </li></ul></ul>
    41. 44. What’s so different? <ul><li>Stacks and Queues </li></ul><ul><ul><li>Removal order determined by order of inserting </li></ul></ul><ul><li>Priority Queue </li></ul><ul><ul><li>Order determined by key </li></ul></ul><ul><ul><li>Key may be part of element data or separate </li></ul></ul><ul><ul><li>Order of returned elements is not FIFO or LIFO (as in queue or stack) </li></ul></ul>
    42. 45. Priority Queue <ul><li>In Priority Queue data elements are arranged according to priority values and allows the insertion of any order but allows to remove data elements according to their priority values. </li></ul>
    43. 46. Continue…. <ul><li>The highest priority element is always at the front of the queue and is removed first of all </li></ul><ul><li>The highest priority can be either the minimum value of all the items, or the maximum value </li></ul><ul><li>We will assume the highest priority is the maximum value </li></ul><ul><li>Note that in a priority queue &quot;first in first out&quot; does not apply in general. </li></ul>
    44. 47. Why Priority Queue ? <ul><li>There are many practical situations which employ priority queue. </li></ul><ul><li>Scheduler for an Operating System </li></ul><ul><li>Printer Queue </li></ul><ul><li>Sorting </li></ul><ul><ul><li>Heap Sort </li></ul></ul>
    45. 48. The Concept of Key <ul><li>Suppose that you have a few assignments from different courses. Which assignment will you want to work on first? </li></ul>Course Priority Due Date Database Management System 3 26 th -December-2009 Data Structure And Algorithm 1 26 th -November-2009 Computer Architecture And Organization 2 6 th -December-2009
    46. 49. Representation of Priority Queue <ul><li>Queue can be represented as </li></ul><ul><ul><li>Array </li></ul></ul><ul><ul><li>Linked List </li></ul></ul><ul><ul><li>Heap </li></ul></ul>
    47. 50. One-Way List Representation of a Priority Queue <ul><li>Each node in the list will contain three items of information: an information field INFO, a priority number PRN and a link number LINK. </li></ul><ul><li>A node X precedes a node Y in the list: </li></ul><ul><ul><li>When X has higher priority than Y or </li></ul></ul><ul><ul><li>When both have the same priority but X was added to the list before Y. </li></ul></ul>
    48. 51. Array Representation of Priority Queue <ul><li>Another way to maintain a priority queue in memory is to use a separate queue for each priority number. </li></ul><ul><li>Each such queue will appear in its own circular array and must have its own pair of pointers, FRONT and REAR </li></ul><ul><li>If each queue is allocated the same amount of space, a two –dimensional array QUEUE can be used instead of the linear array . </li></ul>
    49. 52. Linked List based Implementation of Priority Queue
    50. 53. Continue….
    51. 54. Implementation of Operation
    52. 55. Continue….
    53. 56. Continue….