代写C++代码 代做C++程序 C++辅导 C++教学

C++网络家教 远程写代码 在线Debug 讲解答疑 不是中介,本人直接写

微信: ittutor QQ: 14061936 Email: ittutor@qq.com

导航

CSE 232             

Background 

This is a singly-linked list (SLL) with a head and a tail. It differs from a standard SLL in 

that every insert places the new node into the list in sorted order. Thus, the SortedList is 

always sorted, not because a sort was done but because of the way inserts are done.  

 

Because of this, there are no push_front  or push_back operators as that would violate the 

sorted insertion principle.  

 

A Different Specification 

The spec is loosely provided below. I provide you with a class_skeleton-11.h file 

with some of the code already provided, and a main-11.cpp file which tests the code. 

Your job is to create class-11.h using class_skeleton.h as a starting point. 

You need to provide the needed details to run main-11.cpp. class_skeleton.h 

is clearly marked with what you can and cannot modify. If you modify some of the 

interface, that which is marked as don't change, the main will not run. Be careful with 

that. 

 

Header files 

You can change what header files are included in any way you need in the header part of 

class_skeleton-11.h  

 

Node class 

Already provided in class_skeleton-11.h . It is templated on the data_ member. 

It provides two constructors and an operator<. Do not modify the Node class in any 

way. 

 

SortedList class 

Here is the specification of the SortedList class 

 

Parts that are fully specified in class_skeleton-11.h, you do not change 

•  private members  

•  default constructor 

 Parts that are declared but not defined. You cannot change the declarations, but you must 

provide the definitions. 

•  constructor with initializer_list 

•  copy constructor 

•  destructor 

•  operator= 

•  insert 

o  T value arg to insert 

o  no return 

•  find 

o  T value arg to look for 

o  ptr return (nullptr if not found, Node<T>* ptr to element in the list if 

found) 

•  del 

o  T value arg to delete in list 

§  if multiple examples of T, delete the first one 

o  returns true if value deleted, false otherwise 

o  can use find 

•  length 

o  no args 

o  size_t return of the size of, number of elements in, the list 

•  min 

o  no args 

o  T value return of the smallest element 

•  max 

o  no args 

o  T value return of the largest element 

•  mid 

o  no args 

o  T value return of the element in the middle. If even number of elements, 

return the element to the right of the middle (basically the element of len/2 

using integer math). 

•  operator<< 

o  declaration is there, you need to fill in the definition in the SortedList 

header.  

 

 

Anything else you need!!! 

You are defining your class, so any other functions/members you might need, feel free to 

add them. The test will only involve using the main provided. 

 

Important things to Note 

Deliverables class-11.h your source code solution containing declarations and defintions in 

one file, since this is a template. remember to include your section, the date, project 

number and comments. Remember, you do not provide main-11.cpp 

 

1.  Please be sure to use the specified file names 

2.  Save a copy of your file in your CSE account disk space (H drive on CSE 

computers).   

3.  You will electronically submit a copy of the file using the "handin" program: 

http://www.cse.msu.edu/handin/webclient 

 

Assignment Notes 

swap. std::swap cannot be used to swap a user-defined class. However, it can be used 

to swap the individual elements of a user-defined class. Thus you will probably want to 

do individual swaps of the SortedList elements in operator= 

 


相关推荐