Class 안에 new 선언 가능한가요.
So the constructor of your CircularList class will take an element argument and create a circular list with one node.
You need to implement the following methods:
new CircularList(el) constructs a circular list with one string element;
length returns the number of elements;
remove(p) returns the given node (and throws an exception if this is the last node);
first returns some node of the circular list. This must always be the node containing the element given in the list constructor if that node has not been deleted. You should implement first by simply returning head:
def first: Node = head
insert(p, el) inserts element el in front of node p;
append(el) appends element el at the end of the circular list (this is the same as insert(first, el).
이걸 하려고 Class CircularList를 짜는 중인데요.
Class CircularList안에 new CircularList 선언이 가능한가요? ;;; 저거만 빼면 거의 다 짰는데 -_-;
저걸 어떻게 해야할지 몰라서 그냥 Dummy node를 header로 정의하고 짜버렸는데 잘 굴러가줄거 같거든요
제가 제대로 안배워서 그런가ㅠㅠ.... 언어는 JAVA 계열 언어입니다.
댓글 달기