Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement class my str again, this time using a singly linked list for its representation. Note, your class my str will only have one data

Implement class my str again, this time using a singly linked list for its representation.

image text in transcribed

Note, your class my str will only have one data member, called head, which is a pointer to a list node. head should be private. You must not add any other data members (specifically do not add a length counter or a tail pointer). list node is a low-level class that has only two public data members, info, of type character, and next of type pointer to list node. Pay careful attention to memory management. Do not share memory across my str objects. Feel free to add additional definitions, but please do not add any more data members to class my str (such as the length of the list). Length, for example, should compute the length by counting the number of elements. Please use iteration (looping) to implement all the list methods and functions this time around.

// For my.str, N is the number of characters in this my_str private: static int length(list_node 1) // 0(N) public: int length) / O(N) 1/. ..calls the length function above

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions