Question
Asked by:
$22.00 The Java task code needed till the latest pth morning...
- From Computer-Science: General-CS , Computer-Science: Object-Oriented-Programming
- Closed, but you can still post tutorials
- Due on Feb. 08, 2009
- Asked on Feb. 08, 2009 at 09:47:38AM
Q:Just some words before the task itself: A circulary linked list is a linked list that having the last node points to the first,in other words:the first and final nodes are linked together..
if the whole list contains just a one single node,the of it just points to itself...
and an empty list represented just by NULL..
As we know- Queue is a stracture where first in first out..FIFO:)
the Question's purpose: In the task we needed using the circular linked list to make the best time compexity queue by using just 1 pointer on the list...!
For that task i attached the Class IntNode file
The Question(Task):
Write a class CircularLinked that contains a circular linked list of integer numbers(excluding 0).
the class has just one and only class variable and it must be IntNode(see the attached file).
The constructor of the class supposed to make the list to be empty.
Also add/use the following public functions to the class(and think where it makes sense to point on the list for that the adding/deleting items from it will be as O(1)...)
--Public void addNode(int val)- getting int numb,building a new item and adding it to the end of the list.
--public int deleteNode()- deleting the item that is first in the list from all the items and returning its value,if the list is empty it will return 0
--public StringtoString()- prints the values of all the items in the list,from the first item that came into the list till the last..
--public int length()- returns the number of the items in the list.
--public int removeLowest()- deleting the item with the lowest value in the list,and returning its value,if list
empty it will return 0.
--public void removeDuplicates()-
removes one of the duplicates values items from the list(no matter which)
--public void unify(CircularLinked other)- getting other circular list and unifies it with the current one to a common list..at the end of the process the other list will be empty,and the current one will be unified..
the order will be first the items of the current list and after them the other list items...(during this function its not allowed making new items and no using addNode)
--public boolean sameValues(CircularLinked other)-
getting another list and checking whether it contains the same item values as the current list (not neccesary in same order)..not allowed changing of original list here nor creating new items..
Write whats the time complexity of each function you wrote(it has to be taken the possibilties of full list option and 1 item list and empty list)
its allowed adding private functions as much as you wish..
Thanks...
full work RUNNING CODE is 22$
almost full CODE but with some problems(but running)12$
Attachments:
IntNode.txt (1K)



