Du verwendest einen veralteten Browser. Es ist möglich, dass diese oder andere Websites nicht korrekt angezeigt werden. Du solltest ein Upgrade durchführen oder ein alternativer Browser verwenden.
a) What is recursive programming ?
b) What advantages / disadvantages have recursive implementations against non-recursive implementations (using loops) ?
c) You have one object rootNode – instance of the class Node. This rootNode is filled with a not specified tree children and subnodes. The deepest child level is also not specified. Please write a method :
Node findNode(String name);
This method should search the entire tree for the node with the given name and return it. This implementation should be as easy and as object oriented as possible.
d) What is meant by a “linked list” ? Please implement a linked list with Strings as value. You should be able to walk through this list in positive direction only (from first entry to the last). Please provide methods to
• add a new element at the end of the list
• insert a new element at the specified position
• delete an element at the given position and give it back.
• delete a specified element from the list
• get an element at the specified position.
The position counter should begin with 0. The java class LinkedList or something similar to it should NOT be used. Please write an own implementation. Please use recursive programming here !
e) Which advantages/disadvantages has a linked list in comparison to an Vector/Array ?
Leider hab ich davon nicht viel Ahnung könnt jmd mal kurz auf die frage stellungen eingehen? was ich bisher hab ist.
Code:
a) rekursives Programmieren bedeutet eben, dass sich eine Methode selber wieder aufruft.
b) Nachteile: keine gute Performance->hohem Arbeitsspeicherverbrauch
d)
public class ls
{
LinkedList l = new LinkedList();;
@SuppressWarnings("unchecked")
public void init()
{
l.addFirst("Anfang");
l.addLast("Ende");
}
public ls()
{
}
@SuppressWarnings("unchecked")
public void addEnd(Object O)
{
l.addLast(O);
}
public void insert(int i,Object O)
{
l.add(i,O);
}
public void delObj(Object O)
{
l.remove(O);
}
public void delID(int i)
{
l.remove(i);
}
public void getIndex(int i)
{
l.get(i);
}
}
Den rest wusste ich leider nicht und glaub auch, das die Aufgabe D nicht so wirklich richtig gelöst wurde.
'eben' würde ich nicht nicht mal so eben in eine Antwort reinschreiben,
deine Antwort ist natürlich richtig, aber auch knapp,
aber eigentlich solltest du und dein Lehrbuch besser wissen,
welche Standardsätze zum Aufzählen dazugehören
b stimmt wohl, Vorteil fehlt noch
--------
d: du sollst keine Java-LinkedList kapseln, sondern eine eigene bauen, komplett!