lab6-Q2 - #include<iostream> #include<fstream>...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream> #include<fstream> using namespace std; u const int MAX_ITEMS = 20; typedef int ItemType; t class SList { public: void Insert(ItemType item); //Pre:The list is not full. //Post:Item is in the list; list is stored in increasing order. void PrintList(); //Post:If the list is not empty, the elements are printed on the screen in increasing order; // otherwise "The list is empty" is printed on the screen. int Length(); //Post:Return value is the number of items in the list. bool IsEmpty(); //Post:Returns true if list is empty; false otherwise. bool IsFull(); //Post:Returns true if there is no more room in the list; false otherwise. SList(); //Constructor //Post:Empty list is created. private: int length; ItemType values[MAX_ITEMS]; }; } void SList::Insert(ItemType item) //each new value in int.txt is added in the next space in the array { bool moreToSearch; //Insert() function uses binary search to sort the int location = 0; //elements of the list into increasing order moreToSearch = (location < length);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

lab6-Q2 - #include&lt;iostream&gt; #include&lt;fstream&gt;...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online