Initialize all stacks as empty with -1 Initialize n and k, and allocate memory for all arrays Array of size n to store next entry in all stacks and free list top array store indexes of top elements of stacks Array of size n to store elements i.e elements that will be pushed in stack Update the starting index of the free list as, free = index. Add the free slot to the free list as next = free.ĭ. Remove the element from the stack by updating the head/top of the stack list as top = next.Ĭ. Find the index of the top element of the stack and store it in a variable say index, i.e. Add the element to the stack by updating the head/top of the stack list as top = index. Update the next pointer of the new element as next = top.Į. Store the new element in the free slot as arr = X.ĭ. Update the starting index of the free list as, free = next.Ĭ. Store the index of the first free slot in a temporary variable, say index, i.e.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |