Implement a c++ 'List' class to handle a list with general operations. That means you can insert and delete any element anywhere in the list. The list has no order, except for the order you insert or delete. The methods you are to implement are as given:
Constructor methods (two, default and copy constructor, a list to a newly defined list, ie 'List listA(listB)' )
empty returns true or false if list is empty or not.
front makes current position at the beginning of the list
end makes current position at the end of a list.
prev places current position at the previous element in the list
next places current position at the next element in the list
getPos returns current position or where you are in the list
setPos(int) places current position in a certain position in the list
insertBefore inserts a new element before the current position
insertAfter inserts a new element after the current position
get Element returns the one element that current position is pointing to
size returns the size of the list (number of elements in list)
replace(int) replace the current element with a new value
erase deletes the current element
clear makes the list an empty list
reverse reverse elements in a list
swap swaps all the elements of one list with the another list.
overload the operators: (at least) << output, == , + , = (assignment)
You are to implement the List class using an array. For now the array can be 20 in size.
You will need to use the 'ElementType' for 'typing' your data.
You will need to use CAPACITY constant for the size of the array, in case we need to change the array size.
Invariants: The elements in the list should be left justified.
Implement a c++ 'List' class to handle a list with general operations. That means you can...
Skip list, needs to be implemented in Java: - Implement the class NodeSkipList with two components, namely key node and array of successors. You can also add a constructor, but you do not need to add any method. - In the class SkipList implement a constructor SkipList(long maxNodes). The parameter maxNodes determines the maximal number of nodes that can be added to a skip list. Using this parameter we can determine the maximal height of a node, that is, the...
#1. Single linked list - find... Extra info/hint? It's free For this problem, I have a complete linked list program which supports the following commands from the user: insert, display, delete, average, find, insertBefore, insertAfter. insert allows them to insert a number into the current list, display will display the numbers in the current list etc. The program is complete except that I have removed the body of the method for find. Given the following class for the nodes in...
Implement the EasyStack interface with the MyStack class. You can use either a linked list or a dynamic array to implement the data structure. A stack is a specialised form of list in which you can only get and remove the element most recently added to the stack. The class should be able to work with the following code: EasyStack stack = new MyStack(); NB: You cannot import anything from the standard library for this task. The data structure must...
In Java, Implement a class MyArray as defined below, to store an array of integers (int). Many of its methods will be implemented using the principle of recursion. Users can create an object by default, in which case, the array should contain enough space to store 10 integer values. Obviously, the user can specify the size of the array s/he requires. Users may choose the third way of creating an object of type MyArray by making a copy of another...
c++ Your task is to implement a driver and a class for structure with the following specifications. insert(e) - If e is not in the queue then insert(e) inserts the element e at the front of the queue. If e is in the queue then insert(e) calls refq(e). remove0 -removes the element at the rear of the queue and discards it c refq(e) - a Boolean method that searches for the element e in the queue. If e is not...
Java Write the function void insertAtTail (int v). Don’t add any class variables to the List class. Here are the class definitions of Node and List that implement a linked list. class Node {private Node next; private int key; Node (Node nxt, int keyValue);//constructor Node getNext(); int getKey(); void putNext(Node nxt);} class List {//assume the class does not use a dummy Node private Node head; List ();//constructor boolean exists (int ky);//returns true if v is in the list void insertAtHead(int...
Java Program Create a class to store an array of with enough space to store 10 integer values. Using the principle of recursion, implement the following: *getSize : returns the size of the array. *get (i): returns the i-th element of the array. If the element does not exist, it throws a "NoSuchElementException” which is a subclass of Java class RunTimeException. *add (val): inserts value as the last element of the array. If necessary, double the size of the current...
Min heap class implementation in Python. Implement a min-using an array. Your min-heap class will have one private attribute, an array of integers. Implement the following methods for the min-heap class You may not use the built-in min function. init - Constructor makes an empty heap str - Prints the heap out in any way you want for debugging only) makenull(self) - Makes the heap empty insert(self,x) - Insert element x into the heap parent(self,i) - Returns the index of...
Java help: Please help complete the locate method that is in bold.. public class LinkedDoubleEndedList implements DoubleEndedList { private Node front; // first node in list private Node rear; // last node in list private int size; // number of elements in list ////////////////////////////////////////////////// // YOU MUST IMPLEMENT THE LOCATE METHOD BELOW // ////////////////////////////////////////////////// /** * Returns the position of the node containing the given value, where * the front node is at position zero and the rear node is...
Using C++ • Implement the following in both string linked list and in the template version of the class: • Add to the back and remove from back of the list : - void addBack(….); - string removeBack(); E removeBack(…); • Insert elements in a sorted list i.e., find the position where an element fits and add it to the list. Note you must call the addBack and addFront functions if you insert in the front or rare of the...