Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help fast with this Data Structures with C guide problem, need to write hand written but any help is greatly appreciate. 3. Linked

I need help fast with this Data Structures with C guide problem, need to write hand written but any help is greatly appreciate.

image text in transcribedimage text in transcribed
3. Linked Lists. Complete both Part 1 and Part 2 of this question. Part 1: Assume that you have access to Pat Morin's singly linked list implementation SLList. Add a new member function to SLList named randomSwap( ) that adheres to the following (5) requirements: iv. Let an element of an SLList object be defined as the nodeElement located at a given list node. This definition must terminate without modifying the calling SLList object if it has less than two (2) elements. This definition must correctly swap the nodeElement values located at two pseudo-randomly selected positions of the calling SLList object. In other words, the nodeElements located at two randomly selected list nodes must exchange positions, not the nodes themselves. Prior to performing a swap, this definition must ensure that the two selected positions are not identical. If these positions are identical, the function must terminate without performing a swap. Assume that duplicate values can be inserted into a given SL List object. The values at each random position must only be swapped if their values are not identical; othenNise, neither node's nodeElement value will be modified. As a courtesy, the size of a SLList object is maintained in its member variable size; additionally, the template parameter in use within SLList is named L_Type. You may define randomSwap( ) as if it were to be placed directly inside of the SLList class template body :1 outside of the class template body. Part 2: V. Provide the most accurate best wworst case Big-O growth rates of your randomSwap( ) definition. Express these upper bounds in terms of the size of the list n (as examples, 0( nlogn) in the best case, 0(n ! ) in the worst case, etc). In 1-2 sentences. justify each upper bound selection. Partial credit will be given to any upper bound that is incorrect at larger than necessary. #ifndef SLLIST_H_ #define SLLIST_H_ #include template class SLList private : L_Type null; protected: class Node public: L_Type nodeElement ; Node *next; Node (L_Type nElement) nodeElement = nElement ; next = NULL; Node *head; Node *tail; int size

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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 Programming questions