Cs 302 data structures
This presentation is the property of its rightful owner.
Sponsored Links
1 / 6

CS 302 Data Structures PowerPoint PPT Presentation


  • 86 Views
  • Uploaded on
  • Presentation posted in: General

CS 302 Data Structures. Linked Lists. Preliminaries. A Node: Several nodes linked together. Preliminaries. A head pointer to the first node. Time for some code:. // Programming exercise 2 void moveToBeginning () throw ( logic_error ); // Programming exercise 3

Download Presentation

CS 302 Data Structures

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Cs 302 data structures

CS 302 Data Structures

Linked Lists


Preliminaries

Preliminaries

  • A Node:

  • Several nodes linked together


Preliminaries1

Preliminaries

  • A head pointer to the first node


Time for some code

Time for some code:

// Programming exercise 2

void moveToBeginning ()

throw (logic_error);

// Programming exercise 3

void insertBefore(constDataType& newDataItem)

throw (logic_error);

void showStructure() const;

private:

class ListNode {

public:

ListNode(const DataType& nodeData,

ListNode* nextPtr);

DataTypedataItem;

ListNode* next;

};

ListNode* head;

ListNode* cursor;

};

template <typenameDataType>

class List {

public:

List(int ignored = 0);

List(const List& other);

List& operator=(const List& other);

~List();

void insert(constDataType& newDataItem)

throw (logic_error);

void remove() throw (logic_error);

void replace(constDataType& newDataItem)

throw (logic_error);

void clear();

boolisEmpty() const;

boolisFull() const;

void gotoBeginning() throw (logic_error);

void gotoEnd() throw (logic_error);

boolgotoNext() throw (logic_error);

boolgotoPrior() throw (logic_error);

DataTypegetCursor() const throw (logic_error);


Now to write some

Now to write some ….

  • Constructor

  • Destructor

  • operator=

    • Shallow Copy vs Deep Copy


End of chapter 4

End of Chapter 4


  • Login