Introduction to Algorithms
Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
Question
Book Icon
Chapter 10.3, Problem 5E
Program Plan Intro

To write a procedure COMPACTIFY-LIST( L,F ) for the list L and free list F that has running time of Θ(n) and it should use only a constant extra space.

Blurred answer
Students have asked these similar questions
Add a new public member function to the LinkedList class named reverse() which reverses the items in the list.  You must take advantage of the doubly-linked list structure to do this efficiently as discussed in the videos/pdfs, i.e. swap each node’s prev/next pointers, and finally swap headPtr/tailPtr.  Demonstrate your function works by creating a sample list of a few entries in main(), printing out the contents of the list, reversing the list, and then printing out the contents of the list again to show that the list has been reversed.   Note: your function must actually reverse the items in the doubly-linked list, not just print them out in reverse order! Note: we won't use the copy constructor in this assignment, and as such you aren't required to update the copy constructor to work with a doubly-linked list.   This is what I have so far but its not working! template<class ItemType>void LinkedList<ItemType>::reverse(){   Node<ItemType>*curPtr,*prev,*next;…
In this question, you are to implement two functions for reversing linked lists. One function, reverse_iter(..), must use an iterative approach (i.e., loops), whereas the other function, reverse_rec(..), must use recursion instead. We have already implemented the linked list as well as all its helper-functions in the Ilist-module.
Consider a singly linked list where each node contains two fields – integerdata and node type pointer next. The head of the list and a value of the data isgiven. You have to find the node that contains the given data and delete thatnode. Data may occur at any position of the list including first or last. In caseof unavailability of the given data, you have to print a message. You have toImplement a delete operation of a singly linked list.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning