write the interface of the following functions in the SortedArray.cpp, by the given functions in the SortedArray.h :
#ifndef SortedArray_H
#define SortedArray_H
//INCLUDES
#include <iostream>
using namespace std;
//----------------------------------
// SortedArray<Object>
//----------------------------------
template <typename Object>
class SortedArray
{
public:
/** insert
param: obj
Description: insert new elements into the correct position in
the
sorted array, sliding elements over the position to right, as
needed
*/
void insert(const Object
&obj);
/**
Description: remove the element in position 0, and
slide over all other item
*/
void deleteMin();
/**
Description: remove the last element in the sorted
array
*/
void deleteMax();
private:
int theSize;
int theCapacity;
Object *objects;
};
#include "SortedArray.cpp"
#endif
#ifndef SortedArray_H
#define SortedArray_H
//INCLUDES
#include <iostream>
using namespace std;
//----------------------------------
// SortedArray<Object>
//----------------------------------
template <typename Object>
class SortedArray
{
public:
SortedArray()
{
objects=new object[theCapacity];
}
/*Description: insert new elements into the correct position in
the
sorted array, sliding elements over the position to right, as
needed*/
void insert(const Object &obj)
{
theSize++;
for (int i = thesize - 2; i > 0; i--)
{
if (objects[i] > obj)//if current element is greater than
obj
objects[i + 1] = objects[i];
else //if current element is less than or equal to obj
{
objects[i] = obj;
i=0;
}
}
}
/*
Description: remove the element in position 0, and slide over all
other item
*/
void deleteMin()
{
theSize--;
for(int i=0;i<theSize;i++)
objects[i]=objects[i+1];
}
/*
Description: remove the last element in the sorted array
*/
void deleteMax()
{
theSize--;
}
private:
int theSize = 0 ,theCapacity = 10000;
Object *objects;
};
#endif
COMMENT DOWN FOR ANY QUERIES AND,
LEAVE A THUMBS UP IF THIS ANSWER HELPS YOU.
write the interface of the following functions in the SortedArray.cpp, by the given functions in the SortedArray.h : #if...
C++: Find Time Analysis Worst case O() of each member function with explanation: 1) /** insert function: parameters: obj Description: inserts new elements into the correct position in the sorted array, sliding elements over the position to right, as needed **/ template <typename Object> SortedArray::void insert(const Object &obj) { if (theSize >= theCapacity) { cout << "Error: there is no enough memory space. " << endl; return; } else { for (int i = ((2 * theSize) + 1); (i...
vector.h: #ifndef VECTOR_H #define VECTOR_H #include <algorithm> #include <iostream> #include <cassert> template <typename T> class Vector { public: Vector( int initsize = 0 ) : theSize( initsize ), theCapacity( initsize + SPARE_CAPACITY ) { objects = new T[ theCapacity ]; } Vector( const Vector & rhs ) : theSize( rhs.theSize), theCapacity( rhs.theCapacity ), objects( 0 ) { objects = new T[ theCapacity ]; for( int k = 0; k < theSize; ++k) objects[ k ] = rhs.objects[ k...
USE JAVA: Given the Interface Code and the Interface Implementation Code; Write Junit Tests to test all fuctionality. ------------- Interface code: public interface CustomList { /** * This method should add a new item into the CustomList and should * return true if it was successfully able to insert an item. * @param item the item to be added to the CustomList * @return true if item was successfully added, false if the item was not successfully added (note: it...
Please use the linked approach implement the BST ADT,
implement all the functions in the BSTree.cpp. Add the ouput of the
implementation.
use recursive functions to traverse the tree - read the
implementation notes on using helper functions.
Please use C++ programming
//////////////////////////////////////////////////////////////
#include "BSTree.h"
template <typename DataType, class KeyType>
BSTree<DataType, KeyType>::BSTreeNode::BSTreeNode ( const
DataType &nodeDataItem, BSTreeNode *leftPtr, BSTreeNode
*rightPtr )
{
}
template < typename DataType, class KeyType >
BSTree<DataType, KeyType>::BSTree ()
{
root = 0;
}
template...
The object manager's interface is given by the file ObjectManager.h and the implementation will be in the file ObjectManager.c. Your task is to implement the functions required for the object manager. This includes all the functions listed in ObjectManager.h. #ifndef _OBJECT_MANAGER_H #define _OBJECT_MANAGER_H #ifndef MEMORY_SIZE #define MEMORY_SIZE 1024*512 #endif #define NULL_REF 0 typedef unsigned long Ref; // This function trys to allocate a block of given size from our buffer. // It will fire the garbage collector as required. //...
I'm just not sure how to tackle all the template class this header wants me to write. I got this far into making the template for public and private and would like help on the template functions. Thank you! This is in C++ by the way. #include <iostream> #include <cassert> using namespace std; #ifndef ARRAYLIST_H #define ARRAYLIST_H template<typename T> class arrayList { public: arrayList(); //Constructor with default parameter. //Sets maxSize = 100 and length = 0 if no parameter...
1. void raw_push_front(const Object &x) { // insert x at the head of the list *without* using the iterator classes // Place your code here. } 2. void raw_push_back(const Object &x) { // insert x at the tail of the list *without* using the iterator classes // Place your code here. } #ifndef LIST_H #define LIST_H #include <algorithm> using namespace std; template<typename Object> class List { private: // The basic doubly linked list node. // Nested inside of List, can...
#ifndef HEAP_H_ #define HEAP_H_ namespace cse { template<typename dtype> class heap { public: /** TO DO:: default constructor perform new to reserve memory of size INITIAL_CAPACITY. set num_items = 0; */ heap() { // write your code here }; /** Create a heap from a given array */ heap(dtype *other, size_t len) { // write your code here }; /** copy constructor copy another heap to this heap. */ heap(const heap<dtype> &other) { //write your code here }; /** Accessor...
Given the Interface Code write a java class that implements this interface and show the working functionality in the main method: public interface CustomList<T> { /** * This method should add a new item into the <code>CustomList</code> and should * return <code>true</code> if it was successfully able to insert an item. * @param item the item to be added to the <code>CustomList</code> * @return <code>true</code> if item was successfully added, <code>false</code> if the item was not successfully added (note: it...
(C++) (VISUAL STUDIO) Circular Queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle. In a normal Queue, we can insert elements until queue becomes full. But once queue becomes full, we cannot insert the next element even if there is a space in front of queue. Efficiently implement a queue class using a circular...