Need to be answered in C++ 1. Convert your dynamic array class to be a linked li
ID: 3782181 • Letter: N
Question
Need to be answered in C++
1. Convert your dynamic array class to be a linked list.
2. Convert your linked list class to handle generic types (i.e. C++ templates or Java generics)
3. Create a UDT (user defined type) to handle the data in the UProducts.CSV file (see documents folder).
4. Read the data from the CSV file and store it in your generic linked list.
5. Define a search routine to find a product in the linked list.
Linked List Interface
// Gets the current number of entries in the list
int getCurrentSize()
// Sees whether the list is empty
bool isEmpty()
// Adds a new entry to the list
bool insert(newEntry)
// Removes one occurrence of a given entry from the list
bool remove(anEntry)
// Removes all entries from the list
void clear()
// Tests whether the list contains the entry
bool contains(nEntry)
Explanation / Answer
1)
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
public class ArraytoLinkedList {
public static void main(String[] args) {
// Please provide some data in the array
String[] arr = new String[] { "M", "N", "O" };
// Array to linked list will be converetd here
LinkedList ll = new LinkedList(Arrays.asList(arr));
// Whatever is in the list will be printed each time
Iterator iterator = ll.iterator();
while (iterator.hasNext()) {
// printing elemens on the console
System.out.println((String) iterator.next());
}
}
}
2)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.