Question

Download the List.zip file and then modify List.cpp to implement details for the predicate function called...

Download the List.zip file and then modify List.cpp to implement details for the predicate function called isInList(). The prototype for this function is as follows:

template

bool isInList(Object element, listmyList);

The implementation will use the C++ Standard Template Library list implementation. The function will determine if a given item (element) is in a given list (myList) and will return true (or 1) if it is and false (or 0) if it is not.

You only need to modify the areas of the code in the List.cpp file that are marked with the TODO comments. Everything else will remain that same. You can implement this function anyway you like, but you must use the provided list and function prototype.

Output: Once the function is implemented, the output for the program will appear as follows:

myList: 282 471 786 277 646 832 571 792 567 348

172 is in list (0=false, 1=true): 0

178 is in list (0=false, 1=true): 0

282 is in list (0=false, 1=true): 1

471 is in list (0=false, 1=true): 1

571 is in list (0=false, 1=true): 1

775 is in list (0=false, 1=true): 0

** Press any key to continue **

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Download the List.zip file and then modify List.cpp to implement details for the predicate function called...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • a7q3.cc File #include <iostream> #include <cstring> #include "ArrayList.h" using namespace std; // Algorithm copy(s) // Pre:...

    a7q3.cc File #include <iostream> #include <cstring> #include "ArrayList.h" using namespace std; // Algorithm copy(s) // Pre: s :: refToChar // Post: memory allocated on heap to store a copy // Return: reference to new string char *copy(char *s) { char *temp = new char[strlen(s)+1]; strcpy(temp,s); return temp; } void test_ListOperations(){    cout << "testing createList" << endl;    List *myList = createList(10);    if (myList == NULL){ cout << "createList failed" << endl; return; } else{ cout << "createList succeeded"...

  • You are given a Q1.h file with overloaded function prototypes for isOrdered. Implement this overloaded function...

    You are given a Q1.h file with overloaded function prototypes for isOrdered. Implement this overloaded function into a file named Q1.cpp. Q1.cpp should only include your function implementation, the necessary #include directives if needed, and should not contain anything else such as the main function or global variable declarations. Test your code using a separate main.cpp file where you implement a sufficient number of test cases. You should use Q1.h as a header file and Q1main.cpp as a main function...

  • Using the following definition (List.h file) for a list, implement the member functions (methods) for the...

    Using the following definition (List.h file) for a list, implement the member functions (methods) for the List class and store the implementation in a List.cpp file. Use a doubly linked list to implement the list. Write the client code (the main method and other non-class methods) and put in file driver.cpp. file: List.h typedef int ElementType; class node{ ​ElementType data; ​node * next; node* prev; }; class List { public: List(); //Create an empty list bool Empty(); // return true...

  • Implement these in Python 3 preferably. Task: Implement the following algorithms to solve the Stock Span...

    Implement these in Python 3 preferably. Task: Implement the following algorithms to solve the Stock Span Problem using the ADT for a Stack in ython. The implementation of the ADT of a Stack (10 points) Implementation of computeSpans1 (20 points) Implementation of computeSpan2 (30 points) Provide the derived computational complexity of both computeSpans1 and computeSpans2 (40 points) Algorithm computeSpans1 (P) Input: an n-element list P of numbers such that P[i] is the prices of the stock on day I Output:...

  • In C++ Please for both questions and thank you! Write a predicate function named isEqual that...

    In C++ Please for both questions and thank you! Write a predicate function named isEqual that is passed in 2 vectors of integers and returns true if the vectors are equal, otherwise returns false Two vectors are equal if they have exactly the same values, all in exactly the same location within the vector. You may not use the overloaded vector operator ==, since that is the functionality you are to reproduce. Hint: At what point in your solution can...

  • 1. To implement a stack as an array, the top element would be the one with...

    1. To implement a stack as an array, the top element would be the one with the lowest index. True or false 2. In a doubly-linked list, a node can be removed in constant time if you already have the reference to the node. True or false 3. Stack operations (push, pop, isEmpty) can be worst-case O(1) for a linked list implementation True or false

  • Add a recursive Boolean function called checkRecurse to class IntegerLinkedList to check if any two consecutive...

    Add a recursive Boolean function called checkRecurse to class IntegerLinkedList to check if any two consecutive integers in the linked list are equal (return true in this case, false otherwise). You may assume that the list is not empty. A recursion “helper” function is already included in class IntegerLinkedList. You only need to write the recursive function. For example, checkRecurseHelper() should return true for the linked list shown below. A main function (prob3.cpp) is given to you to add data...

  • Part 1: Implement a singly linked list -------------------------------------- (a) Your job is to implement a generic...

    Part 1: Implement a singly linked list -------------------------------------- (a) Your job is to implement a generic singly linked list that can hold any data type. The interface has been specified and provided to you in a header file called mylist.h. So your job is to write mylist.c that implements each function whose prototype is included in mylist.h. Specifically, you are asked to write the following functions: struct Node *addFront(struct List *list, void *data) void traverseList(struct List *list, void (*f)(void *))...

  • # DISCUSSION SECTION WORK: # # 1. STUDENTS: download this file, ds4.py, and wordsMany.txt, from #...

    # DISCUSSION SECTION WORK: # # 1. STUDENTS: download this file, ds4.py, and wordsMany.txt, from # http://www.cs.uiowa.edu/~cremer/courses/cs1210/etc/ds4/ # Save both in the same folder. # # 2. TA (aloud) and STUDENTS: Read the comments from START HERE! (just after these instructions) # to definition of anagramInfo function. Discuss any questions about what the functions should do. # # 3. TA demonstrate running anagramInfo("wordsMany.txt") on this unchanged file, to # see that it behaves reasonably despite having incomplete anagram-testing functions. #...

  • implement a doubly-linked list in C. Each node in the linked list should contain a string,...

    implement a doubly-linked list in C. Each node in the linked list should contain a string, a pointer to the previous node (or NULL), and a pointer to the next node (or NULL). The nodes should be sorted by their strings. struct node_t { char* str; struct node_t* prev; struct node_t* next; } To maintain the doubly-linked list, you should keep a pointer to the head node of the list (or NULL if the list is empty), and a pointer...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT