Lab 5

Pair Programing Information

Part 1: Github Link

Extend the class linkedListType by adding the following operations :

  1. Find and delete the node with the smallest info in the list. (Delete only the first occurrence and traverse the list only once.)
  2. Find and delete all occurrences of a given info from the list. (Traverse the list only once.)
  3. Write a function that returns the info of the kth element of the linked list. If no such element exists, terminate the program.
  4. Write a function that deletes the kth element of the linked list. If no such element exists, output an appropriate message. Provide the definitions of these functions in the class linkedListType.
  5. Extend the class linkedListType by adding the following function:
    void rotate();
    //Function to remove the first node of a linked list and put it
    //at the end of the linked list.

  6. Modify the Test code to test all these functions using the unorderedLinkedList class.

Add these as abstract functions in the class linkedListType and provide the definitions of these functions in the class unorderedLinkedList.

Part 2: Github Link

Here is the orderlist template code: Link

Add the following operation to the class orderedLinkedList:

void mergeLists(orderedLinkedList<Type> &list1,
         orderedLinkedList<Type> &list2);
    //This function creates a new list by merging the
    //elements of list1 and list2.
    //Postcondition: first points to the merged list; list1
    // and list2 are emptyCode language: JavaScript (javascript)

Example: Consider the following statements:

orderedLinkedList<int> newList;
orderedLinkedList<int> list1;
orderedLinkedList<int> list2;Code language: HTML, XML (xml)

Suppose list1 points to the list with the elements 2 6 7 and list2 points to the list with the elements 3 5 8. The statement:

newList.mergeLists(list1, list2);Code language: CSS (css)

creates a new linked list with the elements in the order 2 3 5 6 7 8 and
the object newList points to this list. Also, after the preceding statement
executes, list1 and list2 are empty.

Write the definition of the function template mergeLists to implement the operation mergeLists. Also write a more code to test your function.

Grading

RequirementsGrading CommentsPointsScore
Good Code Design Part 115
All operations work as specified20
Complete Test Code Part 115
Good Code Design Part 215
Part 2 merges correctly20
Complete Test code Part215
Total100

Scroll to Top