Skip to content
This repository was archived by the owner on Dec 3, 2021. It is now read-only.

tjlauer/CIS223_20210920_Task2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

CIS223_Task2

In this practice, we will be implementing several custom methods for the linked list class.

  • You are required to use python.
  • For help you can use the lecture slides.

Given the code for the following linked list class...


The Problem - Part 1 (3 points)

Complete the printrange method. The method takes two integer numbers x and y as input and print the items from position x to y (Assuming the first item is at position 1 and x>=y).

Example 1:
P = 1->2->3->4->5
P.printrange(3,5) will print 3 4 5

Example 2:
P = None
P.printrange(3,5) will print “No item in range”

Example 3:
P = 1->2->3->4->5
P.printrange(3,10) will print 3 4 5



The Problem - Part 2 (4 points)

Complete the alternateListjoin method. Both p and q are LinkedList objects. The method inserts nodes of linked list q at alternate position of the list pointed by self.

Example 1:
P = 1->3->5->7->9 and
q = 2->4->6->8->10
P.alternateListjoin(q) method will result in P = 1->2->3->4->5->6->7->8->9->10 and q = null

Example 2:
P = 1->3->5 and
q = 2->4->6->8->10
P.alternateListjoin(q) method will result in P = 1->2->3->4->5->6 and q = 8->10

Example 3:
P = 1->3->5->7->9 and
q = 2->4->6
P.alternateListjoin(q) method will result in P = 1->2->3->4->5->6->7->9 and q = null



The Problem - Part 3 (3 points)

Write a code to test your implementation for various cases.

About

Implement several custom methods for the linked list class

Topics

Resources

Stars

Watchers

Forks

Contributors