This document describes implementing an EntryWayListInterface using either an array or linked nodes. It provides the interface methods that must be implemented which include insertHead, insertTail, deleteHead, deleteTail, display, contains, isEmpty, and isFull. It also describes creating a driver program to test the implementation by adding and removing elements from the list and checking for elements. A second class is to implement the interface using an AList or LList object instead of an array or linked nodes.
Implementation The starter code includes List.java. You should not c.pdfmaheshkumar12354
Implementation The starter code includes List.java. You should not change anything in List.java.
Your task will be to create LinkedList.java, make LinkedList use generics and inherit from List,
and complete several methods in LinkedList.java. Create LinkedList.java in IntelliJ. Add a main
method to LinkedList.java containing the following code. Your program will not compile again.
public static void main(String[] args) { LinkedList list = new LinkedList();
System.out.println(list.getHead()); System.out.println(list.getTail()); list.add("first");
list.add("middle"); list.add("last"); System.out.println(list.getHead().value);
System.out.println(list.getTail().value); System.out.println(list); } The first issue is that your
LinkedList class does not have a way of specifying what type of data it should store. You can fix
this using Java Generics. Change the first line of your class to the following: LinkedList .
Confirm that the first line in your main method no longer has an error. On the line that declares
the LinkedList class, add extends List before the bracket that begins the class. The first line in
your class will now have a compile error because LinkedList does not implement the methods
required by the List abstract class. Press Ctrl-i to have IntelliJ insert stubs of these methods.
Ensure that Copy JavaDoc is selected so you get JavaDoc comments which describe the method
requirements, then click OK. Your code should now compile again. Next add fields for the head
and tail. These will be of type Node. Create a getHead method which returns your head field, and
a getTail method which returns your tail field. Run your main method now and you will see that
there is a NullPointerException because the add method does not actually add anything to the
list, so head and tail will always be null. Complete the method boolean add(T value) for which
IntelliJ gave you a stub. You need to create a new node with value to add at the end of the list.
This means you will need to connect it to the old tail and update tail to point to the node you
created. Make sure that you handle the case where the list is empty and both head and tail should
be set to the new node you've created. Note: For the full Map I assignment, add will need to
prevent duplicate values being added to the list and should return true or false based on whether
the value was added or not. For this lab, you can ignore this requirement and simply return true.
Add a toString method to your LinkedList class. It should start at the head of your list and
proceed through all the nodes in a loop, combining the values of each node with a comma
between each and square brackets containing the whole thing. When you run your main method,
the final thing printed should be: [first, middle, last] List.java: /** * Specification for a List
ADT. * @author Shubham Chatterjee * @version 03/07/2019 * @param Type */ public abstract
class List { /** * Appends the specified value to the end of this list. * * @para.
Lecture 18Dynamic Data Structures and Generics (II).docxSHIVA101531
Lecture 18
Dynamic Data Structures and Generics (II)
*
*
Class ArrayListObject of an ArrayList can be used to store an unlimited number of objects.
*
Methods of ArrayList (I)
*
java.util.ArrayList
+ArrayList()
+add(o: Object) : void
+add(index: int, o: Object) : void
+clear(): void
+contains(o: Object): boolean
+get(index: int) : Object
+indexOf(o: Object) : int
+isEmpty(): boolean
+lastIndexOf(o: Object) : int
+remove(o: Object): boolean
+size(): int
+remove(index: int) : Object
+set(index: int, o: Object) : Object
Appends a new element o at the end of this list.
Adds a new element o at the specified index in this list.
Removes all the elements from this list.
Returns true if this list contains the element o.
Returns the element from this list at the specified index.
Returns the index of the first matching element in this list.
Returns true if this list contains no elements.
Returns the index of the last matching element in this list.
Removes the element o from this list.
Returns the number of elements in this list.
Removes the element at the specified index.
Sets the element at the specified index.
Creates an empty list.
Methods of ArrayList (II) Array is used to implement the methodsMethods get(int index) and set(int index, Object o) for accessing and modifying an element through an index and the add(Object o) for adding an element at the end of the list are efficient. Why?Methods add(int index, Object o) and remove(int index) are inefficient because it requires shifting potentially a large number of elements.
*
Linked Data StructureTo improve efficiency for adding and removing an element anywhere in a list.It containsCollection of objectsEach object contains data and a reference to another object in the collection
*
Linked ListA dynamic data structureA linked list consists of nodes. Each node contains an elementa link: linked to its next neighbor. Example: take notes in the class!
*
Linked List
*
ListNodes
ListNodes in Linked List
public class ListNode { // fill the comments
private String data; //
private ListNode link; //
/** */
public ListNode () {
link = null; //
data = null; //
}
/** */
public ListNode (String newData, ListNode linkValue) {
data = newData;
link = linkValue;
}
*
ListNodes in Linked List (cont’d)
/** */
public void setData (String newData) {
data = newData;
}
/** */
public String getData () {
return data;
...
Hi,I have added the methods and main class as per your requirement.pdfannaelctronics
Hi,
I have added the methods and main class as per your requirement. it is working fine now.
Highlighted the code changes.
MyLinkedListTest.java
public class MyLinkedListTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
MyLinkedList list = new MyLinkedList();
list.addFirst(\"AAAAA\");
list.add(\"1\");
list.add(\"2\");
list.add(\"3\");
list.addLast(\"ZZZZZ\");
System.out.println(\"Linked List Elements : \"+list.toString());
System.out.println(\"First element: \"+list.getFirst());
System.out.println(\"Second element: \"+list.getLast());
System.out.println(\"Removed First Element: \"+list.removeFirst());
System.out.println(\"Now Linked List Elements : \"+list.toString());
System.out.println(\"Removed Last Element: \"+list.removeLast());
System.out.println(\"Now Linked List Elements : \"+list.toString());
System.out.println(\"Removed all element: \");
list.removeAll();
System.out.println(\"Now Linked List Elements : \"+list.toString());
}
}
MyLinkedList.java
public class MyLinkedList extends MyAbstractList {
private Node head, tail;
/** Create a default list */
public MyLinkedList() {
}
/** Create a list from an array of objects */
public MyLinkedList(E[] objects) {
super(objects);
}
/** Return the head element in the list */
public E getFirst() {
if (size == 0) {
return null;
}
else {
return (E)head.element;
}
}
/** Return the last element in the list */
public E getLast() {
if (size == 0) {
return null;
}
else {
return (E)tail.element;
}
}
/** Add an element to the beginning of the list */
public void addFirst(E e) {
Node newNode = new Node(e); // Create a new node
newNode.next = head; // link the new node with the head
head = newNode; // head points to the new node
size++; // Increase list size
if (tail == null) // the new node is the only node in list
tail = head;
}
/** Add an element to the end of the list */
public void addLast(E e) {
Node newNode = new Node(e); // Create a new for element e
if (tail == null) {
head = tail = newNode; // The new node is the only node in list
}
else {
tail.next = newNode; // Link the new with the last node
tail = tail.next; // tail now points to the last node
}
size++; // Increase size
}
/** Add a new element at the specified index in this list
* The index of the head element is 0 */
public void add(int index, E e) {
if (index == 0) {
addFirst(e);
}
else if (index >= size) {
addLast(e);
}
else {
Node current = head;
for (int i = 1; i < index; i++) {
current = current.next;
}
Node temp = current.next;
current.next = new Node(e);
(current.next).next = temp;
size++;
}
}
/** Remove the head node and
* return the object that is contained in the removed node. */
public E removeFirst() {
if (size == 0) {
return null;
}
else {
Node temp = head;
head = head.next;
size--;
if (head == null) {
tail = null;
}
return (E)temp.element;
}
}
/** Remove all elements from list */
public void removeAll() {
while(true) {
if (size == 0) {
break;
}
else {
Node temp = head;
head =.
For this lab you will complete the class MyArrayList by implementing.pdffashiongallery1
Find the time it takes the boat to travel the given distance. A ball is thrown vertically upward
with a speed of 40.0 m/s. How high does it rise? How long does it take to reach its highest
point? How long does the ball take to hit the ground after it reaches its highest point? What is
its velocity when it returns to the level from which it started? The center of mass moves with
constant acceleration when constant forces act on the object. A gym ground. How high above
this point is her center of mass at the following times? Ignore the effects
Solution
initial velocity, u = + 40 m/s
a = - 9.8 m/s^2
(a) it will rise until its velocity becomes zero.
hence final velocity, v = 0
Applying, v^2 - u^2 = 2 a h
0^2 - 40^2 = 2(-9.8)(h)
h = 81.63 m
(B) v = u + at
0 = 40 - 9.8 t
t = 4.08 sec
(C) now for motion from highest point to ground,
initial velocity, v (velocity at highets point) = 0
displacement, y = - 81.63 m
a = - 9.8 m/s^2
applying, y = u t + a t^2 /2
- 81.63 = 0 - 9.8 t^2 / 2
t = 4.08 s
(D) applying v = u + at
v = 0 + (-9.8)(4.08)
v = - 40 m/s
(minus sign indicates that direction is downwards).
Interface @author prmsh public interface EntryWa.pdfarasequ
Interface
/**
*
* @author prmsh
*/
public interface EntryWayListInterface {
public boolean insertHead(T newEntry); // inserting new element at start of the list
public boolean insertTail(T newEntry);// inserting new element at end of the list
public T deleteHead(); // returns the object that has to be deleted.
public T deleteTail(); // returns the object that is deleted at last list
public void display(); // diplay the contents of the list
public int contains(T anEntry); // returns the position of the entry that was found
public boolean isEmpty(); // checking list is empty or not
public boolean isFull(); //checking list is full or not
}
Solution
Interface
/**
*
* @author prmsh
*/
public interface EntryWayListInterface {
public boolean insertHead(T newEntry); // inserting new element at start of the list
public boolean insertTail(T newEntry);// inserting new element at end of the list
public T deleteHead(); // returns the object that has to be deleted.
public T deleteTail(); // returns the object that is deleted at last list
public void display(); // diplay the contents of the list
public int contains(T anEntry); // returns the position of the entry that was found
public boolean isEmpty(); // checking list is empty or not
public boolean isFull(); //checking list is full or not
}.
STAGE 2 The Methods 65 points Implement all the methods t.pdfbabitasingh698417
STAGE 2: The Methods (65 points) Implement all the methods that are marked as Left as
Exercise. The Driver program only works when you have done all the methods. I have added the
template of all the methods with a placeholder value as return types of the methods. For example,
return 0 if method returns an int value.
List of the methods left as exercise are as follows: /** Create a list from an array of objects */
@SuppressWarnings("unchecked") public MyLinkedList(E[] objects) /** Add a new element at the
specified index in this list in ascending order */ public void addInOrder(E e) /** Check to see if this
list contains element e */ public boolean contains(E e) /** Remove all the occurrences of the
element e * from this list. Return true if the element is * removed. */ public boolean removeAll(E e)
/** Remove the first occurrence of the element e * from this list. Return true if the element is *
removed. */ public boolean remove(E e) /** Return the element at the specified index */ public E
get(int index) /** Return the index of the head matching element in * this list. Return -1 if no match.
*/ public int indexOf(Object e) /** Return the index of the last matching element in * this list. Return
-1 if no match. */ public int lastIndexOf(E e) /** Replace the element at the specified position * in
this list with the specified element. */ public E set(int index, E e) /** Print this list using recursion */
public void printList() /** Returns an array containing all of the elements * in this collection; * the
runtime type of the returned array is that of * the specified array. */ public <E> E[] toArray(E[]
array) /** Split the original list in half. The original * list will continue to reference the * front half of
the original list and the method * returns a reference to a new list that stores the * back half of the
original list.
public class MyLinkedList<E extends Comparable<E>> {
private Node<E> head, tail;
private int size = 0; // Number of elements in the list
public MyLinkedList() {
head=tail=null;
size=0;
}
/** Return the head element in the list */
public E getFirst() {
if (size == 0) {
return null;
}
else {
return head.element;
}
}
/** Return the last element in the list */
public E getLast() {
if (size == 0) {
return null;
}
else {
return tail.element;
}
}
/** Add an element to the beginning of the list */
public void addFirst(E e) {
Node<E> newNode = new Node<>(e); // Create a new node
newNode.next = head; // link the new node with the head
head = newNode; // head points to the new node
size++; // Increase list size
if (tail == null) // the new node is the only node in list
tail = head;
}
/** Add an element to the end of the list */
public void addLast(E e) {
Node<E> newNode = new Node<>(e); // Create a new for element e
if (tail == null) {
head = tail = newNode; // The new node is the only node in list
}
else {
tail.next = newNode; // Link the new with the last node
tail = newNode; // tail now points to the last node
}
size++; // Incr.
Note- Can someone help me with the private E get(int index- int curren (1).docxVictorzH8Bondx
Note: Can someone help me with the private E get(int index, int currentIndex, Node n)method. The code is not running. Also I need help with the public void add(int index, E element) method too. Please use the parameters provided with the code to solve. package edu.ust.cisc; import java.util.Iterator; import java.util.NoSuchElementException; public class CiscSortedLinkedList > implements CiscList { /** * A reference to this list's dummy node. Its next reference should refer to the node containing the first element * in this list, or it should refer to itself if the list is empty. The next reference within the node containing * the last element in this list should refer to dummy, thus creating a cyclic list. */ private Node dummy; /** * Number of elements in the list. */ private int size; /** * Constructs an empty CiscSortedLinkedList instance with a non-null dummy node whose next reference refers to * itself. */ public CiscSortedLinkedList() { dummy = new Node<>(null, null); dummy.next = dummy; } /** * Returns the number of elements in this list. * * @return the number of elements in this list */ @Override public int size() { return size; } /** * Returns {@code true} if this list contains no elements. * * @return {@code true} if this list contains no elements */ @Override public boolean isEmpty() { return size==0; } /** * Returns {@code true} if this list contains the specified element (compared using the {@code equals} method). * This implementation should stop searching as soon as it is able to determine that the specified element is not * present. * * @param o element whose presence in this list is to be tested * @return {@code true} if this list contains the specified element * @throws NullPointerException if the specified element is null */ @Override public boolean contains(Object o) { if(o==null){ throw new NullPointerException(); } return containsHelper(o,dummy.next); } private boolean containsHelper(Object o, Node node){ if(node== dummy){ return false; } else if(o.equals(node.data)){ return true; } else{ return containsHelper(o,node.next); } } /** * Returns an iterator over the elements in this list in proper sequence. * * @return an iterator over the elements in this list in proper sequence */ @Override public Iterator iterator() { //return new Iterator (){ //private Node curr = dummy.next; //private Node prev = dummy; //private boolean canRemove = false; return null; } /** * Returns an array containing all of the elements in this list in proper sequence (from first to last element). *
The returned array will be "safe" in that no references to it are maintained by this list. (In other words, * this method must allocate a new array even if this list is backed by an array). The caller is thus free to modify * the returned array. * * @return an array containing all of the elements in this list in proper sequence */ @Override public Object[] toArray() { Object[] arr = new Object[size]; int i = 0; for(Node current = dummy;current!=null;cur.
Note- Can someone help me with the Public boolean add(E value) method.pdfStewart29UReesa
Note: Can someone help me with the Public boolean add(E value) method and Private void
add(E value,Node n) method. I have everything but it is not working. Also need help with the
remove methods. Both public and private methods for remove. package edu.ust.cisc; import
java.util.Iterator; import java.util.NoSuchElementException; public class CiscSortedLinkedList
> implements CiscList { /** * A reference to this list's dummy node. Its next reference should
refer to the node containing the first element * in this list, or it should refer to itself if the list is
empty. The next reference within the node containing * the last element in this list should refer to
dummy, thus creating a cyclic list. */ private Node dummy; /** * Number of elements in the list.
*/ private int size; /** * Constructs an empty CiscSortedLinkedList instance with a non-null
dummy node whose next reference refers to * itself. */ public CiscSortedLinkedList() { dummy
= new Node<>(null, null); dummy.next = dummy; } /** * Returns the number of elements in
this list. * * @return the number of elements in this list */ @Override public int size() { return
size; } /** * Returns {@code true} if this list contains no elements. * * @return {@code true} if
this list contains no elements */ @Override public boolean isEmpty() { return size==0; } /** *
Returns {@code true} if this list contains the specified element (compared using the {@code
equals} method). * This implementation should stop searching as soon as it is able to determine
that the specified element is not * present. * @param o element whose presence in this list is to
be tested * @return {@code true} if this list contains the specified element * @throws
NullPointerException if the specified element is null */ @Override public boolean
contains(Object o) { if(o==null){ throw new NullPointerException(); } return
containsHelper(o,dummy.next); } private boolean containsHelper(Object o, Node node){
if(node== dummy){ return false; } else if(o.equals(node.data)){ return true; } else{ return
containsHelper(o,node.next); } } /** * Returns an iterator over the elements in this list in proper
sequence. * * @return an iterator over the elements in this list in proper sequence */ @Override
public Iterator iterator() { //return new Iterator (){ //private Node curr = dummy.next; //private
Node prev = dummy; //private boolean canRemove = false; return new CiscLinkedListIterator();
} /** * Returns an array containing all of the elements in this list in proper sequence (from first
to last element). * *
The returned array will be "safe" in that no references to it are maintained by this list. (In other
words, * this method must allocate a new array even if this list is backed by an array). The caller
is thus free to modify * the returned array. * * @return an array containing all of the elements in
this list in proper sequence */ @Override public Object[] toArray() { Object[] arr = new
Object[size]; int i = 0; for(Node current = dummy;curren.
Implementation The starter code includes List.java. You should not c.pdfmaheshkumar12354
Implementation The starter code includes List.java. You should not change anything in List.java.
Your task will be to create LinkedList.java, make LinkedList use generics and inherit from List,
and complete several methods in LinkedList.java. Create LinkedList.java in IntelliJ. Add a main
method to LinkedList.java containing the following code. Your program will not compile again.
public static void main(String[] args) { LinkedList list = new LinkedList();
System.out.println(list.getHead()); System.out.println(list.getTail()); list.add("first");
list.add("middle"); list.add("last"); System.out.println(list.getHead().value);
System.out.println(list.getTail().value); System.out.println(list); } The first issue is that your
LinkedList class does not have a way of specifying what type of data it should store. You can fix
this using Java Generics. Change the first line of your class to the following: LinkedList .
Confirm that the first line in your main method no longer has an error. On the line that declares
the LinkedList class, add extends List before the bracket that begins the class. The first line in
your class will now have a compile error because LinkedList does not implement the methods
required by the List abstract class. Press Ctrl-i to have IntelliJ insert stubs of these methods.
Ensure that Copy JavaDoc is selected so you get JavaDoc comments which describe the method
requirements, then click OK. Your code should now compile again. Next add fields for the head
and tail. These will be of type Node. Create a getHead method which returns your head field, and
a getTail method which returns your tail field. Run your main method now and you will see that
there is a NullPointerException because the add method does not actually add anything to the
list, so head and tail will always be null. Complete the method boolean add(T value) for which
IntelliJ gave you a stub. You need to create a new node with value to add at the end of the list.
This means you will need to connect it to the old tail and update tail to point to the node you
created. Make sure that you handle the case where the list is empty and both head and tail should
be set to the new node you've created. Note: For the full Map I assignment, add will need to
prevent duplicate values being added to the list and should return true or false based on whether
the value was added or not. For this lab, you can ignore this requirement and simply return true.
Add a toString method to your LinkedList class. It should start at the head of your list and
proceed through all the nodes in a loop, combining the values of each node with a comma
between each and square brackets containing the whole thing. When you run your main method,
the final thing printed should be: [first, middle, last] List.java: /** * Specification for a List
ADT. * @author Shubham Chatterjee * @version 03/07/2019 * @param Type */ public abstract
class List { /** * Appends the specified value to the end of this list. * * @para.
Lecture 18Dynamic Data Structures and Generics (II).docxSHIVA101531
Lecture 18
Dynamic Data Structures and Generics (II)
*
*
Class ArrayListObject of an ArrayList can be used to store an unlimited number of objects.
*
Methods of ArrayList (I)
*
java.util.ArrayList
+ArrayList()
+add(o: Object) : void
+add(index: int, o: Object) : void
+clear(): void
+contains(o: Object): boolean
+get(index: int) : Object
+indexOf(o: Object) : int
+isEmpty(): boolean
+lastIndexOf(o: Object) : int
+remove(o: Object): boolean
+size(): int
+remove(index: int) : Object
+set(index: int, o: Object) : Object
Appends a new element o at the end of this list.
Adds a new element o at the specified index in this list.
Removes all the elements from this list.
Returns true if this list contains the element o.
Returns the element from this list at the specified index.
Returns the index of the first matching element in this list.
Returns true if this list contains no elements.
Returns the index of the last matching element in this list.
Removes the element o from this list.
Returns the number of elements in this list.
Removes the element at the specified index.
Sets the element at the specified index.
Creates an empty list.
Methods of ArrayList (II) Array is used to implement the methodsMethods get(int index) and set(int index, Object o) for accessing and modifying an element through an index and the add(Object o) for adding an element at the end of the list are efficient. Why?Methods add(int index, Object o) and remove(int index) are inefficient because it requires shifting potentially a large number of elements.
*
Linked Data StructureTo improve efficiency for adding and removing an element anywhere in a list.It containsCollection of objectsEach object contains data and a reference to another object in the collection
*
Linked ListA dynamic data structureA linked list consists of nodes. Each node contains an elementa link: linked to its next neighbor. Example: take notes in the class!
*
Linked List
*
ListNodes
ListNodes in Linked List
public class ListNode { // fill the comments
private String data; //
private ListNode link; //
/** */
public ListNode () {
link = null; //
data = null; //
}
/** */
public ListNode (String newData, ListNode linkValue) {
data = newData;
link = linkValue;
}
*
ListNodes in Linked List (cont’d)
/** */
public void setData (String newData) {
data = newData;
}
/** */
public String getData () {
return data;
...
Hi,I have added the methods and main class as per your requirement.pdfannaelctronics
Hi,
I have added the methods and main class as per your requirement. it is working fine now.
Highlighted the code changes.
MyLinkedListTest.java
public class MyLinkedListTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
MyLinkedList list = new MyLinkedList();
list.addFirst(\"AAAAA\");
list.add(\"1\");
list.add(\"2\");
list.add(\"3\");
list.addLast(\"ZZZZZ\");
System.out.println(\"Linked List Elements : \"+list.toString());
System.out.println(\"First element: \"+list.getFirst());
System.out.println(\"Second element: \"+list.getLast());
System.out.println(\"Removed First Element: \"+list.removeFirst());
System.out.println(\"Now Linked List Elements : \"+list.toString());
System.out.println(\"Removed Last Element: \"+list.removeLast());
System.out.println(\"Now Linked List Elements : \"+list.toString());
System.out.println(\"Removed all element: \");
list.removeAll();
System.out.println(\"Now Linked List Elements : \"+list.toString());
}
}
MyLinkedList.java
public class MyLinkedList extends MyAbstractList {
private Node head, tail;
/** Create a default list */
public MyLinkedList() {
}
/** Create a list from an array of objects */
public MyLinkedList(E[] objects) {
super(objects);
}
/** Return the head element in the list */
public E getFirst() {
if (size == 0) {
return null;
}
else {
return (E)head.element;
}
}
/** Return the last element in the list */
public E getLast() {
if (size == 0) {
return null;
}
else {
return (E)tail.element;
}
}
/** Add an element to the beginning of the list */
public void addFirst(E e) {
Node newNode = new Node(e); // Create a new node
newNode.next = head; // link the new node with the head
head = newNode; // head points to the new node
size++; // Increase list size
if (tail == null) // the new node is the only node in list
tail = head;
}
/** Add an element to the end of the list */
public void addLast(E e) {
Node newNode = new Node(e); // Create a new for element e
if (tail == null) {
head = tail = newNode; // The new node is the only node in list
}
else {
tail.next = newNode; // Link the new with the last node
tail = tail.next; // tail now points to the last node
}
size++; // Increase size
}
/** Add a new element at the specified index in this list
* The index of the head element is 0 */
public void add(int index, E e) {
if (index == 0) {
addFirst(e);
}
else if (index >= size) {
addLast(e);
}
else {
Node current = head;
for (int i = 1; i < index; i++) {
current = current.next;
}
Node temp = current.next;
current.next = new Node(e);
(current.next).next = temp;
size++;
}
}
/** Remove the head node and
* return the object that is contained in the removed node. */
public E removeFirst() {
if (size == 0) {
return null;
}
else {
Node temp = head;
head = head.next;
size--;
if (head == null) {
tail = null;
}
return (E)temp.element;
}
}
/** Remove all elements from list */
public void removeAll() {
while(true) {
if (size == 0) {
break;
}
else {
Node temp = head;
head =.
For this lab you will complete the class MyArrayList by implementing.pdffashiongallery1
Find the time it takes the boat to travel the given distance. A ball is thrown vertically upward
with a speed of 40.0 m/s. How high does it rise? How long does it take to reach its highest
point? How long does the ball take to hit the ground after it reaches its highest point? What is
its velocity when it returns to the level from which it started? The center of mass moves with
constant acceleration when constant forces act on the object. A gym ground. How high above
this point is her center of mass at the following times? Ignore the effects
Solution
initial velocity, u = + 40 m/s
a = - 9.8 m/s^2
(a) it will rise until its velocity becomes zero.
hence final velocity, v = 0
Applying, v^2 - u^2 = 2 a h
0^2 - 40^2 = 2(-9.8)(h)
h = 81.63 m
(B) v = u + at
0 = 40 - 9.8 t
t = 4.08 sec
(C) now for motion from highest point to ground,
initial velocity, v (velocity at highets point) = 0
displacement, y = - 81.63 m
a = - 9.8 m/s^2
applying, y = u t + a t^2 /2
- 81.63 = 0 - 9.8 t^2 / 2
t = 4.08 s
(D) applying v = u + at
v = 0 + (-9.8)(4.08)
v = - 40 m/s
(minus sign indicates that direction is downwards).
Interface @author prmsh public interface EntryWa.pdfarasequ
Interface
/**
*
* @author prmsh
*/
public interface EntryWayListInterface {
public boolean insertHead(T newEntry); // inserting new element at start of the list
public boolean insertTail(T newEntry);// inserting new element at end of the list
public T deleteHead(); // returns the object that has to be deleted.
public T deleteTail(); // returns the object that is deleted at last list
public void display(); // diplay the contents of the list
public int contains(T anEntry); // returns the position of the entry that was found
public boolean isEmpty(); // checking list is empty or not
public boolean isFull(); //checking list is full or not
}
Solution
Interface
/**
*
* @author prmsh
*/
public interface EntryWayListInterface {
public boolean insertHead(T newEntry); // inserting new element at start of the list
public boolean insertTail(T newEntry);// inserting new element at end of the list
public T deleteHead(); // returns the object that has to be deleted.
public T deleteTail(); // returns the object that is deleted at last list
public void display(); // diplay the contents of the list
public int contains(T anEntry); // returns the position of the entry that was found
public boolean isEmpty(); // checking list is empty or not
public boolean isFull(); //checking list is full or not
}.
STAGE 2 The Methods 65 points Implement all the methods t.pdfbabitasingh698417
STAGE 2: The Methods (65 points) Implement all the methods that are marked as Left as
Exercise. The Driver program only works when you have done all the methods. I have added the
template of all the methods with a placeholder value as return types of the methods. For example,
return 0 if method returns an int value.
List of the methods left as exercise are as follows: /** Create a list from an array of objects */
@SuppressWarnings("unchecked") public MyLinkedList(E[] objects) /** Add a new element at the
specified index in this list in ascending order */ public void addInOrder(E e) /** Check to see if this
list contains element e */ public boolean contains(E e) /** Remove all the occurrences of the
element e * from this list. Return true if the element is * removed. */ public boolean removeAll(E e)
/** Remove the first occurrence of the element e * from this list. Return true if the element is *
removed. */ public boolean remove(E e) /** Return the element at the specified index */ public E
get(int index) /** Return the index of the head matching element in * this list. Return -1 if no match.
*/ public int indexOf(Object e) /** Return the index of the last matching element in * this list. Return
-1 if no match. */ public int lastIndexOf(E e) /** Replace the element at the specified position * in
this list with the specified element. */ public E set(int index, E e) /** Print this list using recursion */
public void printList() /** Returns an array containing all of the elements * in this collection; * the
runtime type of the returned array is that of * the specified array. */ public <E> E[] toArray(E[]
array) /** Split the original list in half. The original * list will continue to reference the * front half of
the original list and the method * returns a reference to a new list that stores the * back half of the
original list.
public class MyLinkedList<E extends Comparable<E>> {
private Node<E> head, tail;
private int size = 0; // Number of elements in the list
public MyLinkedList() {
head=tail=null;
size=0;
}
/** Return the head element in the list */
public E getFirst() {
if (size == 0) {
return null;
}
else {
return head.element;
}
}
/** Return the last element in the list */
public E getLast() {
if (size == 0) {
return null;
}
else {
return tail.element;
}
}
/** Add an element to the beginning of the list */
public void addFirst(E e) {
Node<E> newNode = new Node<>(e); // Create a new node
newNode.next = head; // link the new node with the head
head = newNode; // head points to the new node
size++; // Increase list size
if (tail == null) // the new node is the only node in list
tail = head;
}
/** Add an element to the end of the list */
public void addLast(E e) {
Node<E> newNode = new Node<>(e); // Create a new for element e
if (tail == null) {
head = tail = newNode; // The new node is the only node in list
}
else {
tail.next = newNode; // Link the new with the last node
tail = newNode; // tail now points to the last node
}
size++; // Incr.
Note- Can someone help me with the private E get(int index- int curren (1).docxVictorzH8Bondx
Note: Can someone help me with the private E get(int index, int currentIndex, Node n)method. The code is not running. Also I need help with the public void add(int index, E element) method too. Please use the parameters provided with the code to solve. package edu.ust.cisc; import java.util.Iterator; import java.util.NoSuchElementException; public class CiscSortedLinkedList > implements CiscList { /** * A reference to this list's dummy node. Its next reference should refer to the node containing the first element * in this list, or it should refer to itself if the list is empty. The next reference within the node containing * the last element in this list should refer to dummy, thus creating a cyclic list. */ private Node dummy; /** * Number of elements in the list. */ private int size; /** * Constructs an empty CiscSortedLinkedList instance with a non-null dummy node whose next reference refers to * itself. */ public CiscSortedLinkedList() { dummy = new Node<>(null, null); dummy.next = dummy; } /** * Returns the number of elements in this list. * * @return the number of elements in this list */ @Override public int size() { return size; } /** * Returns {@code true} if this list contains no elements. * * @return {@code true} if this list contains no elements */ @Override public boolean isEmpty() { return size==0; } /** * Returns {@code true} if this list contains the specified element (compared using the {@code equals} method). * This implementation should stop searching as soon as it is able to determine that the specified element is not * present. * * @param o element whose presence in this list is to be tested * @return {@code true} if this list contains the specified element * @throws NullPointerException if the specified element is null */ @Override public boolean contains(Object o) { if(o==null){ throw new NullPointerException(); } return containsHelper(o,dummy.next); } private boolean containsHelper(Object o, Node node){ if(node== dummy){ return false; } else if(o.equals(node.data)){ return true; } else{ return containsHelper(o,node.next); } } /** * Returns an iterator over the elements in this list in proper sequence. * * @return an iterator over the elements in this list in proper sequence */ @Override public Iterator iterator() { //return new Iterator (){ //private Node curr = dummy.next; //private Node prev = dummy; //private boolean canRemove = false; return null; } /** * Returns an array containing all of the elements in this list in proper sequence (from first to last element). *
The returned array will be "safe" in that no references to it are maintained by this list. (In other words, * this method must allocate a new array even if this list is backed by an array). The caller is thus free to modify * the returned array. * * @return an array containing all of the elements in this list in proper sequence */ @Override public Object[] toArray() { Object[] arr = new Object[size]; int i = 0; for(Node current = dummy;current!=null;cur.
Note- Can someone help me with the Public boolean add(E value) method.pdfStewart29UReesa
Note: Can someone help me with the Public boolean add(E value) method and Private void
add(E value,Node n) method. I have everything but it is not working. Also need help with the
remove methods. Both public and private methods for remove. package edu.ust.cisc; import
java.util.Iterator; import java.util.NoSuchElementException; public class CiscSortedLinkedList
> implements CiscList { /** * A reference to this list's dummy node. Its next reference should
refer to the node containing the first element * in this list, or it should refer to itself if the list is
empty. The next reference within the node containing * the last element in this list should refer to
dummy, thus creating a cyclic list. */ private Node dummy; /** * Number of elements in the list.
*/ private int size; /** * Constructs an empty CiscSortedLinkedList instance with a non-null
dummy node whose next reference refers to * itself. */ public CiscSortedLinkedList() { dummy
= new Node<>(null, null); dummy.next = dummy; } /** * Returns the number of elements in
this list. * * @return the number of elements in this list */ @Override public int size() { return
size; } /** * Returns {@code true} if this list contains no elements. * * @return {@code true} if
this list contains no elements */ @Override public boolean isEmpty() { return size==0; } /** *
Returns {@code true} if this list contains the specified element (compared using the {@code
equals} method). * This implementation should stop searching as soon as it is able to determine
that the specified element is not * present. * @param o element whose presence in this list is to
be tested * @return {@code true} if this list contains the specified element * @throws
NullPointerException if the specified element is null */ @Override public boolean
contains(Object o) { if(o==null){ throw new NullPointerException(); } return
containsHelper(o,dummy.next); } private boolean containsHelper(Object o, Node node){
if(node== dummy){ return false; } else if(o.equals(node.data)){ return true; } else{ return
containsHelper(o,node.next); } } /** * Returns an iterator over the elements in this list in proper
sequence. * * @return an iterator over the elements in this list in proper sequence */ @Override
public Iterator iterator() { //return new Iterator (){ //private Node curr = dummy.next; //private
Node prev = dummy; //private boolean canRemove = false; return new CiscLinkedListIterator();
} /** * Returns an array containing all of the elements in this list in proper sequence (from first
to last element). * *
The returned array will be "safe" in that no references to it are maintained by this list. (In other
words, * this method must allocate a new array even if this list is backed by an array). The caller
is thus free to modify * the returned array. * * @return an array containing all of the elements in
this list in proper sequence */ @Override public Object[] toArray() { Object[] arr = new
Object[size]; int i = 0; for(Node current = dummy;curren.
Please complete all the code as per instructions in Java programming.docxcgraciela1
Please complete all the code as per instructions in Java programming import org.w3c.dom.Node; import javax.xml.crypto.NodeSetData; import java.awt.*; import java.util.Iterator; import java.util.NoSuchElementException; /** * This class implements an acyclic (non-cyclic), doubly-linked list. * @param */ public class CiscDoublyLinkedList implements CiscList { /** * A reference to the first node in the list (or null if list is empty). */ private Node head; /** * A reference to the last node int the list (or null if list is empty). */ private Node tail; /** * Number of elements in the list. */ private int size; /** * Returns the number of elements in this list. * * * @return the number of elements in this list */ @Override public int size() { return size; } /** * Returns {@code true} if this list contains no elements. * * * @return {@code true} if this list contains no elements */ @Override public boolean isEmpty() { if (size == 0){ return true; } return false; } /** * Returns {@code true} if this list contains the specified element (compared using the {@code equals} method). * * * @param o element whose presence in this list is to be tested * @return {@code true} if this list contains the specified element * @throws NullPointerException if the specified element is null */ @Override public boolean contains(Object o) { if(o == null) { throw new NullPointerException(); } Node node = head; while(node != null) { if(node.data.equals(o)){ return true; } node = node.next; } return false; } /** * Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not * contain the element (compared using the {@code equals} method). * * * @param o element to search for * @return the index of the first occurrence of the specified element in this list, or -1 if this list does not * contain the element * @throws NullPointerException if the specified element is null */ @Override public int indexOf(Object o) { if (o == null){ throw new NullPointerException(); } for(int i =0; i = size){ throw new IndexOutOfBoundsException(); } return null; } /** * Appends the specified element to the end of this list. * * *
Lists may place the specified element at arbitrary locations if desired. In particular, an ordered list will * insert the specified element at its sorted location. List classes should clearly specify in their documentation * how elements will be added to the list if different from the default behavior (end of this list). * * @param e element to be appended to this list * @return {@code true} * @throws NullPointerException if the specified element is null */ @Override public boolean add(E e) { if(e == null){ throw new NullPointerException(); } return false; } /** * Replaces the element at the specified position in this list with the specified element. * * * @param index index of the element to replace * @param element element to be stored at the specified position * @return the element previously at the specified position *.
Note- Can someone help me with the public boolean isEmpty()- public bo.pdfAugstore
Note: Can someone help me with the public boolean isEmpty(), public boolean contains(Object
o), public int indexOf(Object o) and public E get(int index)methods using abstract List. package
edu.ust.cisc; import java.util.Iterator; public abstract class CiscAbstractList implements CiscList
{ /** * Returns the number of elements in this list. * * @return the number of elements in this
list */ @Override public int size() { int size = 0; Iterator itr = iterator(); while(itr.hasNext()) {
itr.next(); size++; } return size; } /** * Returns {@code true} if this list contains no elements. *
* @return {@code true} if this list contains no elements */ @Override public boolean isEmpty()
{ return false; } /** * Returns {@code true} if this list contains the specified element (compared
using the {@code equals} method). * * @param o element whose presence in this list is to be
tested * @return {@code true} if this list contains the specified element * @throws
NullPointerException if the specified element is null */ @Override public boolean
contains(Object o) { return false; } /** * Returns the index of the first occurrence of the specified
element in this list, or -1 if this list does not * contain the element (compared using the {@code
equals} method). * * @param o element to search for * @return the index of the first occurrence
of the specified element in this list, or -1 if this list does not * contain the element * @throws
NullPointerException if the specified element is null */ @Override public int indexOf(Object o)
{ return 0; } /** * Removes all of the elements from this list. The list will be empty after this call
returns. */ @Override public abstract void clear(); /** * Returns the element at the specified
position in this list. * * @param index index of the element to return * @return the element at
the specified position in this list * @throws IndexOutOfBoundsException if the index is out of
range */ @Override public E get(int index) { return null; } /** * Appends the specified element
to the end of this list. * *
Lists may place the specified element at arbitrary locations if desired. In particular, an ordered
list will * insert the specified element at its sorted location. List classes should clearly specify in
their documentation * how elements will be added to the list if different from the default
behavior (end of this list). * * @param e element to be appended to this list * @return {@code
true} * @throws NullPointerException if the specified element is null */ @Override public
boolean add(E e) { return false; } /** * Replaces the element at the specified position in this list
with the specified element (optional operation). * * @param index index of the element to
replace * @param element element to be stored at the specified position * @return the element
previously at the specified position * @throws UnsupportedOperationException if the {@code
set} operation is not supported by this list * @throws NullPointerException if the specified
el.
please i need help Im writing a program to test the merge sort alg.pdfezonesolutions
please i need help I\'m writing a program to test the merge sort algorithm for linked lists.
I need to Print the list before being sorted and the list after sorting the elements
here is my code only help in test program the four classes are ok except the test program.
TEST PROGRAM
import java.io.*;
import java.util.*;
public class Ch9_ProgExercise7 {
Scanner input = new Scanner(System.in);
public static void main(String[] args) throws IOException {
OrderedLinkedList list
= new OrderedLinkedList(); //Line 1
IntElement num = new IntElement(); //Line 2
// Prompt the user to enter some integers
System.out.println(\"Enter integers numbers \");
String temp = input.hasnextLine();
String[] split = temp.split(\" \");
for (int i = 0; i < split.length; i++) {
Integer a = Integer.parseInt(split[i]);
// insert the intgers into the list you created above
num.setNum(a);
list.insertNode(num);
}
System.out.println();
// Print the list before being sorted
// call the mergesort method
System.out.println();
// print the list after sorting the elements
}
}
ORDEREDLICKEDLIST CLASS
public class OrderedLinkedList extends LinkedListClass
{
//default constructor
public OrderedLinkedList()
{
super();
}
//copy constructor
public OrderedLinkedList(OrderedLinkedList otherList)
{
super(otherList);
}
public void linkedInsertionSort()
{
LinkedListNode lastInOrder;
LinkedListNode firstOutOfOrder;
LinkedListNode current;
LinkedListNode trailCurrent;
lastInOrder = first;
if(first == null)
System.out.println(\"Cannot sort an empty list\");
else
if(first.link == null)
System.out.println(\"The list is of length 1. \"
+ \"Already in order\");
else
while(lastInOrder.link != null)
{
firstOutOfOrder = lastInOrder.link;
if(firstOutOfOrder.info.compareTo(first.info) < 0)
{
lastInOrder.link = firstOutOfOrder.link;
firstOutOfOrder.link = first;
first = firstOutOfOrder;
}
else
{
trailCurrent = first;
current = first.link;
while(current.info.compareTo(firstOutOfOrder.info) < 0)
{
trailCurrent = current;
current = current.link;
}
if(current != firstOutOfOrder)
{
lastInOrder.link = firstOutOfOrder.link;
firstOutOfOrder.link = current;
trailCurrent.link = firstOutOfOrder;
}
else
lastInOrder = lastInOrder.link;
}
}
}//end linkedInsertionSort
//Method to determine whether searchItem is in
//the list.
//Postcondition: Returns true if searchItem is found
// in the list; otherwise, it returns
// false.
public boolean search(DataElement searchItem)
{
LinkedListNode current; //variable to traverse the list
boolean found;
current = first; //set current to point to the first
//node in the list
found = false; //set found to false
while(current != null && !found ) //search the list
if(current.info.compareTo(searchItem) >= 0)
found = true;
else
current = current.link; //make current point to
//the next node
if(found)
found = current.info.equals(searchItem);
return found;
}
//Method to insert insertItem in the list
//Postcondition: first points to the new list,
// newItem is inserted at the proper place
//.
Class DiagramIn the Assignment #10, you are given three files Ass.pdfxlynettalampleyxc
Class Diagram:
In the Assignment #10, you are given three files Assignment10.java, LinkedList.java, and
ListIterator.java. You will need to add additional methods in the LinkedList class in the
LinkedList.java file. The LinkedList will be tested using strings only.
Specifically, the following methods must be implemented in the LinkedList class:
(You should utilize listIterator() method already defined in the LinkedList class to obtain its
LinkedListIterator object, and use the methods in the LinkedListIterator class to traverse from
the first element to the last element of the linked list to define the following methods.)
1.
public String toString()
The toString method should concatenate strings in the linked list, and return a string of the
following format:
{ Apple Banana Melon Orange }
Thus it starts with \"{\" and ends with \"}\", and there is a space between strings and \"{\" or
\"}\". If the list is empty, it returns \"{ }\" with a space in between.
2.
public boolean isEmpty()
The isEmpty method returns true of the linked list is empty, false otherwise.
3.
public void addElement(Object element)
The addElement adds the parameter element at the parameter in the linked list in alphabetical
order. For instance, if the linked list contains {Apple, Banana, Grape}, and a user tries to add
\"Carrot\", then it should be added as:
{Apple, Banana, Carrot, Grape}.
4.
public Object removeElement(int index)
The removeElement removes the string (Object) at the parameter index and returns it. Note that
this index starts with 0 just like array indices. For instance, if the linked list contains {Apple,
Banana, Carrot, Grape} and the parameter index is 3, then \"Grape\" should be remove. If the
parameter index is larger or smaller than the existing indices, it should throw an object of the
IndexOutOfBoundsException class (and the content of the linked list should remain unchanged).
5.
public Object getElement(int index)
The getElement searches the string (Object) at the parameter index and returns it. Note that this
index starts with 0 just like array indices. For instance, if the linked list contains {Apple, Banana,
Carrot, Grape} and the parameter index is 3, then \"Grape\" will be returned. If the parameter
index is larger or smaller than the existing indices, it should throw an object of the
IndexOutOfBoundsException class (and the content of the linked list should remain unchanged).
6.
public void searchAndReplace(Object oldString, Object newString)
The searchAndReplace method searches all occurrences of the first parameter string (object) in
the list, and replaces them with the second parameter string (object). If the parameter string does
not exist in the linked list, then the linked list content will not change.
7.
public int indexOfLast(Object searchString)
The indexOfLast searches the parameter string (object) with the largest index, and returns its
index. If the parameter string does not exist in the linked list, then it should return -1.
For i.
package ADTs public interface CollectionADTltTgt .pdfsyedabdul78662
package ADTs;
public interface CollectionADT<T> {
public boolean isEmpty();
public int size();
@Override
public String toString();
}
**********************************************************
package ADTs;
import Exceptions.*;
/**
* An interface for an ordered (NOT SORTED) List
* Elements stay in the order they are put in to the list
* For use in Data Structures & Algorithms
*
*
* @author
*/
public interface ListADT<T> extends CollectionADT<T> {
/**
* Adds the specified element to the list at the front
*
* @param element: the element to be added
*
*/
public void addFirst(T element);
/**
* Adds the specified element to the end of the list
*
* @param element: the element to be added
*/
public void addLast(T element);
/**
* Adds the specified element to the list after the existing element
*
* @param existing: the element that is in the list already
* @param element: the element to be added
* @throws ElementNotFoundException if existing isn't in the list
*/
public void addAfter(T existing, T element) throws ElementNotFoundException,
EmptyCollectionException;
/**
* Removes and returns the specified element
*
* @return the element specified
* @throws EmptyCollectionException
* @throws ElementNotFoundException
*/
public T remove(T element) throws EmptyCollectionException, ElementNotFoundException;
/**
* Removes and returns the first element
*
* @return the first element in the list
* @throws EmptyCollectionException
*/
public T removeFirst() throws EmptyCollectionException;
/**
* Removes and returns the last element
*
* @return the last element in the list
* @throws EmptyCollectionException
*/
public T removeLast() throws EmptyCollectionException;
/**
* Returns (without removing) the first element in the list
*
* @return element at the beginning of the list
* @throws EmptyCollectionException
*/
public T first() throws EmptyCollectionException;
/**
* Returns (without removing) the last element in the list
*
* @return element at the end of the list
* @throws EmptyCollectionException
*/
public T last() throws EmptyCollectionException;
/**
* Return whether the list contains the given element.
*
* @param element
* @return
* @throws EmptyCollectionException
*/
public boolean contains(T element) throws EmptyCollectionException;
/**
* Returns the index of the given element.
*
* @param element
* @return the index of the element, or -1 if not found
*/
public int indexOf(T element);
/**
* Return the element at the given index of a list.
*
* @param element
* @return
* @throws EmptyCollectionException
*/
public T get(int index) throws EmptyCollectionException, InvalidArgumentException;
/**
* Set the at the given index of a list.
*
* @param element
* @return
* @throws EmptyCollectionException
*/
public void set(int index, T element) throws EmptyCollectionException, InvalidArgumentException;
}
**********************************************
package ADTs;
import Exceptions.EmptyCollectionException;
import Exceptions.QueueOverflowException;
public interface QueueADT<.
2.(Sorted list array implementation)This sorted list ADT discussed .pdfarshin9
2.(Sorted list: array implementation)This sorted list ADT discussed in class should be extended
by the addition of two new methods:
//Interface: ArrayListADT
//works for int
public interface ArrayListADT {
public boolean isEmpty(); //Method to determine whether the list is empty.
public boolean isFull(); //Method to determine whether the list is full.
public int listSize(); //Method to return the number of elements in the list.
public int maxListSize(); //Method to return the maximum size of the list.
public void print(); //Method to output the elements of the list.
public boolean isItemAtEqual(int location, int item); //Method to determine whether item is
the same as the item in the list at location.
public void insertAt(int location, int insertItem); //Method to insert insertItem in the list at
the position
public void insertEnd(int insertItem); //Method to insert insertItem at the end of the list.
public void removeAt(int location); //Method to remove the item from the list at location.
public int retrieveAt(int location); //Method to retrieve the element from the list at location.
public void replaceAt(int location, int repItem); //Method to replace the element in the list at
location with repItem.
public void clearList(); //Method to remove all the elements from the list.
public int search(int searchItem); //Method to determine whether searchItem is in the list.
public void remove(int removeItem); //Method to remove an item from the list.
}
//Class: ArrayListClass implements
//Interface: ArrayListADT
public abstract class ArrayListClass implements ArrayListADT {
protected int length; //to store the length of the list
protected int maxSize; //to store the maximum size of the list
protected int[] list; //array to hold the list elements
//Default constructor
public ArrayListClass() {
maxSize = 100;
length = 0;
list = new int[maxSize];
}
//Alternate Constructor
public ArrayListClass(int size) {
if(size <= 0) {
System.err.println(\"The array size must be positive. Creating an array of size 100.\");
maxSize = 100;
}
else
maxSize = size;
length = 0;
list = new int[maxSize];
}
public boolean isEmpty() {
return (length == 0);
}
public boolean isFull() {
return (length == maxSize);
}
public int listSize() {
return length;
}
public int maxListSize() {
return maxSize;
}
public void print() {
for (int i = 0; i < length; i++)
System.out.print(list[i] + \" \");
System.out.println();
}
public boolean isItemAtEqual(int location, int item) {
if (location < 0 || location >= length) {
System.err.println(\"The location of the item to be compared is out of range.\");
return false;
}
return list[location]== item;
}
public void clearList() {
for (int i = 0; i < length; i++)
list[i] = 0;
length = 0;
System.gc(); //invoke the Java garbage collector
}
public void removeAt(int location) {
if (location < 0 || location >= length)
System.err.println(\"The location of the item to be removed is out of range.\");
else {
for(int i = location; i < length - 1; i++)
list[i] .
The LinkedList1 class implements a Linked list. class.pdfmalavshah9013
/**
The LinkedList1 class implements a Linked list.
*/
class LinkedList1
{
/**
The Node class stores a list element
and a reference to the next node.
*/
private class Node
{
String value;
Node next;
/**
Constructor.
@param val The element to store in the node.
@param n The reference to the successor node.
*/
Node(String val, Node n)
{
value = val;
next = n;
}
/**
Constructor.
@param val The element to store in the node.
*/
Node(String val)
{
// Call the other (sister) constructor.
this(val, null);
}
}
private Node first; // list head
private Node last; // last element in list
/**
Constructor.
*/
public LinkedList1()
{
first = null;
last = null;
}
/**
The isEmpty method checks to see
if the list is empty.
@return true if list is empty,
false otherwise.
*/
public boolean isEmpty()
{
return first == null;
}
/**
The size method returns the length of the list.
@return The number of elements in the list.
*/
public int size()
{
int count = 0;
Node p = first;
while (p != null)
{
// There is an element at p
count ++;
p = p.next;
}
return count;
}
/**
The add method adds an element to
the end of the list.
@param e The value to add to the
end of the list.
*/
public void add(String e)
{
if (isEmpty())
{
first = new Node(e);
last = first;
}
else
{
// Add to end of existing list
last.next = new Node(e);
last = last.next;
}
}
/**
The add method adds an element at a position.
@param e The element to add to the list.
@param index The position at which to add
the element.
@exception IndexOutOfBoundsException When
index is out of bounds.
*/
public void add(int index, String e)
{
if (index < 0 || index > size())
{
String message = String.valueOf(index);
throw new IndexOutOfBoundsException(message);
}
// Index is at least 0
if (index == 0)
{
// New element goes at beginning
first = new Node(e, first);
if (last == null)
last = first;
return;
}
// Set a reference pred to point to the node that
// will be the predecessor of the new node
Node pred = first;
for (int k = 1; k <= index - 1; k++)
{
pred = pred.next;
}
// Splice in a node containing the new element
pred.next = new Node(e, pred.next);
// Is there a new last element ?
if (pred.next.next == null)
last = pred.next;
}
/**
The toString method computes the string
representation of the list.
@return The string form of the list.
*/
public String toString()
{
StringBuilder strBuilder = new StringBuilder();
// Use p to walk down the linked list
Node p = first;
while (p != null)
{
strBuilder.append(p.value + \"\ \");
p = p.next;
}
return strBuilder.toString();
}
/**
The remove method removes the element at an index.
@param index The index of the element to remove.
@return The element removed.
@exception IndexOutOfBoundsException When index is
out of bounds.
*/
public String remove(int index)
{
if (index < 0 || index >= size())
{
String message = String.valueOf(index);
throw new IndexOutOfBoundsException(message);
}
String element; // The element to return
if (index == 0)
{
// Removal of first item in the list
element.
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfclimatecontrolsv
PROBLEM STATEMENT:
In this assignment, you will complete DoubleEndedList.java that implements the ListInterface as
well as an interface called DoubleEndedInterface which represents the list's entries by using a
chain of nodes that has both a head reference and a tail reference. Be sure to read through the
code and understand the implementation.
WHAT IS PROVIDED:
- A driver class to test your code. You should not modify this file!
- A list interface (ListInterface.java)
- A double ended interface (DoubleEndedInterface.java)
- An incomplete DoubleEndedList class (DoubleEndedList.java)
WHAT YOU NEED TO DO:
4. Complete the DoubleEndedList class
4. Run the driver and make sure your output is exactly the same as mine (at the bottom of
Driver.java)
\} // end else numberofEntries--; else throw new IndexOut0fBoundsException("Illegal position
given to remove operation."); return result; // Return removed entry }//endreturnreve public T
replace(int givenPosition, T newEntry) \{ T replace(int givenPosition, T newEntry) \{ if
((givenPosition >=1)&& (givenPosition <= numberOfEntries)) \{ // Assertion: The list is not
empty Node desiredNode = getNodeAt (givenPosition); ToriginalEntry = desiredNode.getData();
desiredNode.setData(newEntry); return originalEntry; f // end if else throw new
IndexOut0fBoundsException("Illegal position given to replace operation."); replace if ((
givenPosition >=1)&& (givenPosition <= number0fEntries)) \{ // Assertion: The list is not
empty Node desiredNode = getNodeAt ( givenPosition); T originalEntry = desiredNode.
getData( ); desiredNode.setData(newEntry); return originalentry; \} // end if throw new
Index0ut0fBoundsException("Illegal position given to replace operation."); \} // end replace
public T getEntry(int givenPosition) \{ if ((givenPosition >=1) \&\& (givenPosition < =
number0fEntries ) ) \{ // Assertion: The list is not empty return getNodeAt (givenPosition).
getData(); else // end if throw new IndexOut0fBoundsException("Illegal position given to
getEntry operation."); \} // end getEntry public boolean contains ( T anEntry) \{ boolean found =
false; Node currentNode = firstNode; while (!found && (currentNode != null)) \{ if
(anEntry.equals (currentNode.getData())) else found = true; \} // end while currentNode =
currentNode. getNextNode () ; return found; \} // end contains public int getLength() \{ return
numberofEntries; \} // end getLength public boolean isEmpty() \{ return number0fEntries ==0;
\} // end isEmpty public T[] toArray() \{ // The cast is safe because the new array contains null
entries aSuppressWarnings ("unchecked") T[] result =(T[]) new 0bject [numberofEntries]; //
Unchecked cast int index =0; Node currentNode = firstNode; while ((index < numberOfEntries)
\&\& (currentNode != null)) \& result [ index ]= currentNode. getData () ; currentNode =
currentNode.getNextNode ( ); index++; 3 // end while return result; 3 // end toArray // Returns a
reference to the node at a given position. // Precondition: L.
public class MyLinkedListltE extends ComparableltEgtg.pdfaccostinternational
public class MyLinkedList<E extends Comparable<E>> {
private Node<E> head, tail;
private int size = 0; // Number of elements in the list
public MyLinkedList() {
head=tail=null;
size=0;
}
/** Return the head element in the list */
public E getFirst() {
if (size == 0) {
return null;
}
else {
return head.element;
}
}
/** Return the last element in the list */
public E getLast() {
if (size == 0) {
return null;
}
else {
return tail.element;
}
}
/** Add an element to the beginning of the list */
public void addFirst(E e) {
Node<E> newNode = new Node<>(e); // Create a new node
newNode.next = head; // link the new node with the head
head = newNode; // head points to the new node
size++; // Increase list size
if (tail == null) // the new node is the only node in list
tail = head;
}
/** Add an element to the end of the list */
public void addLast(E e) {
Node<E> newNode = new Node<>(e); // Create a new for element e
if (tail == null) {
head = tail = newNode; // The new node is the only node in list
}
else {
tail.next = newNode; // Link the new with the last node
tail = newNode; // tail now points to the last node
}
size++; // Increase size
}
public void add(int index, E e) {
if (index == 0) {
addFirst(e);
}
else if (index >= size) {
addLast(e);
}
else {
Node<E> current = head;
for (int i = 1; i < index; i++) {
current = current.next;
}
Node<E> temp = current.next;
current.next = new Node<>(e);
(current.next).next = temp;
size++;
}
}
//Add e to the end of this linkedlist
public void add(E e) {
// Left as Exercise
}
/** Remove the head node and
* return the object that is contained in the removed node. */
public E removeFirst() {
if (size == 0) {
return null;
}
else {
E temp = head.element;
head = head.next;
size--;
if (head == null) {
tail = null;
}
return temp;
}
}
/** Remove the last node and
* return the object that is contained in the removed node. */
public E removeLast() {
if (size == 0) {
return null;
}
else if (size == 1) {
E temp = head.element;
head = tail = null;
size = 0;
return temp;
}
else {
Node<E> current = head;
for (int i = 0; i < size - 2; i++) {
current = current.next;
}
E temp = tail.element;
tail = current;
tail.next = null;
size--;
return temp;
}
}
/** Remove the element at the specified position in this
* list. Return the element that was removed from the list. */
public E remove(int index) {
if (index < 0 || index >= size) {
return null;
}
else if (index == 0) {
return removeFirst();
}
else if (index == size - 1) {
return removeLast();
}
else {
Node<E> previous = head;
for (int i = 1; i < index; i++) {
previous = previous.next;
}
Node<E> current = previous.next;
previous.next = current.next;
size--;
return current.element;
}
}
/** Clear the list */
public void clear() {
size = 0;
head = tail = null;
}
/** Override toString() to return elements in the list in [] separated by , */
public String toString() {
StringBuilder result = new StringBuilder("[");
Node<E> current = head;
for (int i = 0; i < size; i++) {
result.append(current..
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdfezzi97
Homework 05 - Linked Lists (C++)
(1) Implement the concepts of a union, and difference as defined noted in Chapter 1 questions 6,
and 8 using a linked list. You should not use arrays, dynamic arrays or the STL vector or STL
list classes.
You will be linking a series of nodes together to implement a single linked list class. Define a
Node as a struct that holds a character (like they did in the book) and a pointer to another Node:
struct Node {
char data;
Node* next;
};
Then define a LinkedList class which has (at a minimum) these member functions:
LinkedList();
~LinkedList();
bool insertAtFront();
bool insertBeforePosition(int index);
bool insertAtBack();
bool deleteAtFront();
bool deleteBeforePosition(int index);
bool deleteAtBack();
Implement each of these functions to provide the correct functionality. These functions return
true if successful in inserting or deleting, otherwise they return false (indicating the operation
was not successful).
Finally, create an overloaded + operator to handle the Union of two linked lists and an
overloaded - operator to handle the Difference of two linked lists.
Because we are dealing with pointers you should have both a LinkedList Constructor and
Destructor. Remember that you do not directly call a Constructor or Destructor Function. The
Destructor is automatically called when the variable loses scope or the program ends.
Remember, that we are dealing with not just one dynamically allocated Node (with the new
operator), but many, so you will have to start at the head of the list and go until the Node points
to nullptr. Then keep deleting the previous Node pointer until there are no Nodes left to delete.
(2) To verify your set class, write a main function that takes two lines of characters from the
input file input.txt and store each line of characters into two separate linked lists. Then using
these two lists, perform the Union and set Difference of the characters from the file, and print the
results to the console.
(3) Please also complete an asymptotic (Big O) analysis of your insertAtFront() and
insertAtBack() member functions. Place this in a file called analysis.txt.
Solution
Here is the complete code for your question. Please do rate the aswer if you are happy with
program. Please read comments in the program. Also pay special attention to comments in + and
- operators. You WILL NEED to comment out if condition in + if you want all elements in both
lists irrespective of if they duplicates or no. For now implemented to have true behaviour of no
duplicates in union.
check the functions by creating some lists and playing around different fucntions like its done in
main and commented out.
As far as complexity:
for insertAtFront() its O(1) since it does not depend on the size of the list. It just replaces the start
of the list. Hence it is O(1) and independent of the size of list.
for insertAtBack(), its O(n) since it depends on the number of elements in the list. It should
traverse till end of list and .
package linkedLists- import java-util-Iterator- --- A class representi.pdfarcellzone
package linkedLists;
import java.util.Iterator;
/** A class representing a singly linked list from scratch. Fill in code.
*
* Note: you may NOT use any of Java's built in classes that store a collection of elements
* such as ArrayList, LinkedList (Java's built in), HashMap, HashTree, HashSet etc. */
public class LinkedList {
private Node head, tail;
/** Constructor */
public LinkedList() {
head = null;
tail = null;
}
/**
* Creates a new node with the given element and adds it to the back of the
* list. No need to change this method.
*/
public void append(int elem) {
Node newNode = new Node(elem);
if (tail != null) {
tail.setNext(newNode);
tail = newNode;
} else {
head = tail = newNode;
}
}
/** Prints all the nodes in the link list. No need to change this method. */
public void printNodes() {
Node current = head;
while (current != null) {
System.out.print(current.elem() + " ");
current = current.next();
}
}
/**
* Return a sublist of this list where the values of elements are in the range
* from value1 to value2, inclusive.
* Your method should not destroy the original list and its nodes should *not* reference
* the nodes in the input list (you need to create new nodes instead).
* Example:
* If the list is 6->40->3->17->1 and value1 is 3 and value2 is 20,
* then the result should be 6->3->17.
* @param value1 value 1
* @param value2 value 2
* @return a sublist of this list where the values of elements are in the range
* * from value1 to value2, inclusive.
*/
public LinkedList sublist(int value1, int value2) {
LinkedList res = new LinkedList();
// FILL IN CODE
return res;
}
/**
* Insert a new node with the given element into the sorted linked list.
* Insert it in the right place based on the value in the node. Assume the
* list is sorted by the elem, from smallest to largest. The
* list should remain sorted after this insert operation.
* Example: If this list is 5->10->18 and we insert 15, then after that the operation,
* the list will become 5->10->15->18.
*/
public void insertInSortedList(int elem) {
// insert a node into the sorted list
// FILL IN CODE
}
/**
* Assume this linked list is sorted in ascending order, and we do not know the
* * number of elements.
* * Return a LinkedList that contains k largest elements in the list.
* * Use slow & fast pointers to find the k-th node from the end (required). Note: This method
* * should be linear and should not count the number of nodes. Do NOT use reverse().
* @param k index from the end
* @return linked list that contains k largest elements (k elements from the end of the list)
*/
public LinkedList getKLargest(int k) {
LinkedList result = new LinkedList();
// FILL IN CODE
return result;
}
/**
* Merge two sorted linked lists into a single sorted linked list.
*
* @param list1
* @param list2
* Your method should not destroy the original list and its nodes should *not* reference
* the nodes in the input list (you need to create new nodes instead).
*/
public static LinkedList mergeSortedLists(LinkedLis.
Given below is the completed implementation of MyLinkedList class. O.pdfinfo430661
Given below is the completed implementation of MyLinkedList class. Other classes are not
modified and remain same as in question - MyList, MyAbstractList, TestMyLinkedList.
The output of TestMyLinkedList is shown below. Please don\'t forget to rate the answer if it
helped. Thank you very much.
Since the MyList is not completely pasted in the question ... giving the complete class file below
MyList.java
public interface MyList> extends java.lang.Iterable
{
// Add a new element at the end of this list
public void add (E e);
// Add a new element at specified index in this list
public void add (int index, E e);
// Return true if this list contains the element
public boolean contains (E e);
// Return the element at the specified index
public E get (int index);
// Return the index of the first matching element
// Return -1 if no match.
public int indexOf (E e);
// Return the index of the last matching element
// Return -1 if no match.
public int lastIndexOf (E e);
E remove(int index);
void clear();
E set(int index, E e);
}
MyLinkedList.java
public class MyLinkedList> extends MyAbstractList
implements Comparable>
{
private Node head, tail; // head and tail pointers
// Create a default list
public MyLinkedList()
{
}
public int size()
{
return size;
}
// Need this for implementing Comparable
public int compareTo (MyLinkedList e)
{
return(size() - e.size());
}
// Create a list from an array of objects
public MyLinkedList (E[] objects)
{
super(objects); // Passes the array up to abstract parent
}
// Return the head element in the list
public E getFirst()
{
if (size == 0)
{
return null;
}
else
{
return head.element;
}
}
// Return the last element in the list
public E getLast()
{
if (size == 0)
{
return null;
}
else
{
return tail.element;
}
}
// Add an element to the beginning of the list
public void addFirst (E e)
{
// Create a new node for element e
Node newNode = new Node(e);
newNode.next = head; // link the new node with the head
head = newNode; // head points to the new node
size++; // Increase list size
if (tail == null) // new node is only node
{
tail = head;
}
}
// Add an element to the end of the list
public void addLast (E e)
{
// Create a new node for element e
Node newNode = new Node(e);
if (tail == null)
{
head = tail = newNode; // new node is only node
}
else
{
tail.next = newNode; // Link the new with the last node
tail = tail.next; // tail now points to the last node
}
size++; // Increase size
}
// Remove the head node and
// return the object from the removed node
public E removeFirst()
{
if (size == 0)
{
return null;
}
else
{
Node temp = head;
head = head.next;
size--;
if (head == null)
{
tail = null;
}
return temp.element;
}
}
// Remove the last node and return the object from it
public E removeLast()
{
if (size == 0)
{
return null;
}
else if (size == 1)
{
Node temp = head;
head = tail = null;
size = 0;
return temp.element;
}
else
{
Node current = head;
for (int i = 0; i < size - 2; i++)
{
current = current.next;
}
Node temp = tail;
tai.
import java.util.Iterator; import java.util.NoSuchElementException; /** * An implementation
of MyList with a linked list (a longer exercise would be to * implement the List interface as is
done in the class java.util.LinkedList: * the source of the LinkedList class is available from Sun.
Check it out). */ public class MyLinkedList implements MyList { // A private class to
represent a Node in the linked list private class Node { public E item;
public Node next; // a convenient constructor public Node(E o) {
this.item = o; this.next = null; } } // The start of the linked
list private Node head; // The last Node in the linked list private Node tail;
// Number of elements in the list private int size; /** * Creates an empty list (this
constructor is not necessary) */ public MyLinkedList() { } /** *
Returns the number of elements in this list. */ public int size() { return size;
} /** * Returns true if this list contains no elements. */ public boolean
isEmpty() { return size == 0; } /** * Appends the specified element to
the end of this list */ public boolean add(E o) { Node n = new Node(o);
// If this is the first element in the list if (head == null) { head = n;
} else { // If the list is not empty, use tail tail.next = n;
} // update tail tail = n; // update size size++;
return true; } /** * Empties this List */ public void clear() {
// update head, tail and size head = tail = null; size = 0; } /**
* Returns the element at the specified position in this list. */ public E get(int index) {
if (index < 0 || index >= size) { throw new
IndexOutOfBoundsException(\"index = \" + index); } // Find it
Node n = head; for (int i = 0; i < index; i++) { n = n.next; }
return n.item; } /** * Returns the index of the specified element (-1 if
there is no match) */ public int indexOf(Object o) { // If o is null
int index = 0; Node p = head; if (o == null) // look for a null element in the
list { while (p != null) { if (p.item == null) {
return index; } index++;
p = p.next; } } else // o is an object (use equals) {
while (p != null) { if (o.equals(p.item)) { return
index; } index++; p = p.next;
} } // if we get here, o is not in the list return -1; }
/** * Returns true if this list contains the specified element. */ public boolean
contains(Object o) { // easy with indexOf return indexOf(o) != -1; }
/** * Removes the element in the List at position index */ public boolean
remove(int index) { if (index < 0 || index >= size) { throw new
IndexOutOfBoundsException(\"index = \" + index); } // Find the
corresponding node Node prev = null, p = head; for (int i = 0; i < index; i++)
{ prev = p; p = p.next; } // Remove it
// Special case for the first node if (p == head) { head = head.next;
} else { prev.next = p.next; } // If the last node has been
removed, update tail if (p == tail) { tail = prev; } //
update size size--; return true; } /** * Removes the element
in the List at position index */ public boolean remove(Object o) { // easy
with indexOf and remove int index = i.
Describe an algorithm for concatenating two singly linked lists L and.pdfdeepak596396
Dataset:
https://docs.google.com/spreadsheets/d/1NxuGt4LJ3ofi2PaWLWpAl90JmfqMKcGV/edit?usp=sharing&ouid=111109979069524025260&rtpof=true&sd=true
Q1) What is the average tenure of those customers of the telecom operator who are still with the
company as a customer and also those who have stopped using the services provided by the
company? (1 mark)
Here, churn = 'No' means that the customer is currently associated with the company, and churn
= 'Yes' means that the customer has stopped using the services provided by the company.
Q2)What is the monthly average revenue generated by the customers who are with the company
and also those who have left? (1 mark)
Q3) Find the percentage of churn and non-churn customers for each category of the following
services: (4 marks)
-MultipleLines
-PaperlessBilling
-OnlineSecurity
-OnlineBackup
-DeviceProtection
-TechSupport
-StreamingTV
-StreamingMovies.
A popular implementation of List is ArrayList- Look up how to instanti.pdfarsarees
A popular implementation of List is ArrayList. Look up how to instantiate one.
*
* @return a List<Integer> object.
*/
public List<Integer> createList(){
}
return null;
}
/**
* Get the size of a list.
*
* @param list a List<Integer> object.
* @return the size of List (number of items it holds.)
*/
return 0;
}
/**
* Add an item to a list.
* When we add a value to a list, it gets appended to the end.
*
* @param list a List<Integer> object that we would like to modify.
* @param value an integer that we would like to add to list.
* @return nothing, pass by reference will cause changes to the list object to be reflected across
the program.
*/
public void addToList(List<Integer> list, int value){
}
/**
* Get a particular index of a list.
* Lists, like arrays, are zero-indexed, so they start counting at zero. For instance,
* index 0 of {0,2,4,6} is 0.
* index 1 of {0,2,4,6} is 2.
* Index is the same as saying the position, number, etc of a value.
* Let's get the element from a list at a certain index.
*
* @param list a List<Integer> object that we would like to examine.
* @param index represents the index of the element we would like to retrieve.
* @return the int at the location in 'list' represented by 'index'.
*/
public int get(List<Integer> list, int index){
return 0;
}
/**
* Remove an index from a list.
* We can remove an item from the list, which will cause all items after it to reduce their index by
1 (they are
* all still ordered, without any empty spaces in the list.)
*
* @param list a List<Integer> object that we would like to modify.
* @param position represents the index of the element we would like to remove.
* @return nothing, pass by reference will cause changes to the list object to be reflected across
the program.
*/
public void removeFromList(List<Integer> list, int position){
}
/**
* Update an index of a list.
* We can update a value in the list, which will overwrite a value at a certain position.
*
* @param list a List<Integer> object that we would like to modify.
* @param position represents the index of the element we would like to change.
* @param value the new value which we would like to assign to the item at position in list
* @return nothing, pass by reference will cause changes to the list object to be reflected across
the program.
*/
public void updateAtPosition(List<Integer> list, int position, int value){
}
.
Please help me to make a programming project I have to sue them today- (1).pdfseoagam1
Please help me to make a programming project I have to sue them today. Please help me make a
UnsortedList and SortedList classes. The instructor give me The code of the List and AbstracList
Classes that 2 pages we do not modify them. Do not modify this pages!!! List.java import
java.util.Iterator; /** * Represents List interface. * * @author Varik Hoang * @version Sep 26,
2016 * @param is of any object type. */ public interface List { /** * The method returns the
current number of elements in the list. * * @return the current number of elements in the list
greater than or equal 0 */ public int getSize(); /** * The method returns whether the list is empty.
* * @return true if list is empty, false otherwise. */ public boolean isEmpty(); /** * The method
returns whether value is in the list. * * @param value the value is assigned * @return true if
value in the list, false otherwise. */ public boolean contains(Type value); /** * The method
inserts an element into the list. * * @param value the value is assigned */ public void insert(Type
value); /** * The method clears the list. */ public void clear(); /** * The method returns a string
representation of list contents. * * @return a string representation of list contents. * @see
Object#toString() */ @Override public String toString(); /** * /** * The method removes first
element occurrence from the list. * * @param value the value is assigned * @return the removed
value */ public Type remove(Type value); /** * The method returns the index of value. * *
@param value the value is assigned. * @return the index of value if in the list, -1 otherwise. */
public int getIndex(Type value); /** * The method removes value at the given index. * *
@param index the index must be in range of 0 and size * @return the removed value * @throws
IndexOutOfBoundsException if index less than 0 or index greater than * or equal size */ public
Type removeAtIndex(int index); /** * The method replaces the value at the given index with the
given value. * * @param index the index must be in range of 0 and size * @param value the
value is assigned * @throws IndexOutOfBoundsException if index less 0 or index greater than
size */ public void set(int index, Type value); /** * Returns the value at the given index in the
list. * * @param index the index must be in range of 0 and size * @throws
IndexOutOfBoundsException if index less than 0 or greater size * @return the value at the given
index in the list. */ public Type get(int index); /** * The method returns an iterator for this list. *
* @return an iterator for the list. */ public Iterator iterator(); } Do not modify this pages public
abstract class AbstractList implements List { /** * The reference to the last element */ protected
ListNode tail; /** * The size of the list */ protected int size; /** * The constructor that initiate the
tail and size references */ public AbstractList() { tail = null; size = 0; } @Override public int
getSize() { return size; } @Override public bool.
File LinkedList.java Defines a doubly-l.pdfConint29
File: LinkedList.java
/**
* Defines a doubly-linked list class
*/
import java.util.NoSuchElementException;
public class LinkedList {
private class Node {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
private int length;
private Node first;
private Node last;
private Node iterator;
/**** CONSTRUCTORS ****/
/**
* Instantiates a new LinkedList with default values
* @postcondition
*/
public LinkedList() {
}
/**
* Converts the given array into a LinkedList
* @param array the array of values to insert into this LinkedList
* @postcondition
*/
public LinkedList(T[] array) {
}
/**
* Instantiates a new LinkedList by copying another List
* @param original the LinkedList to copy
* @postcondition a new List object, which is an identical,
* but separate, copy of the LinkedList original
*/
public LinkedList(LinkedList original) {
}
/**** ACCESSORS ****/
/**
* Returns the value stored in the first node
* @precondition
* @return the value stored at node first
* @throws NoSuchElementException
*/
public T getFirst() throws NoSuchElementException {
return null;
}
/**
* Returns the value stored in the last node
* @precondition
* @return the value stored in the node last
* @throws NoSuchElementException
*/
public T getLast() throws NoSuchElementException {
return null;
}
/**
* Returns the data stored in the iterator node
* @precondition
* @return the data stored in the iterator node
* @throw NullPointerException
*/
public T getIterator() throws NullPointerException {
return null;
}
/**
* Returns the current length of the LinkedList
* @return the length of the LinkedList from 0 to n
*/
public int getLength() {
return -1;
}
/**
* Returns whether the LinkedList is currently empty
* @return whether the LinkedList is empty
*/
public boolean isEmpty() {
return false;
}
/**
* Returns whether the iterator is offEnd, i.e. null
* @return whether the iterator is null
*/
public boolean offEnd() {
return false;
}
/**** MUTATORS ****/
/**
* Creates a new first element
* @param data the data to insert at the front of the LinkedList
* @postcondition
*/
public void addFirst(T data) {
return;
}
/**
* Creates a new last element
* @param data the data to insert at the end of the LinkedList
* @postcondition
*/
public void addLast(T data) {
return;
}
/**
* Inserts a new element after the iterator
* @param data the data to insert
* @precondition
* @throws NullPointerException
*/
public void addIterator(T data) throws NullPointerException{
return;
}
/**
* removes the element at the front of the LinkedList
* @precondition
* @postcondition
* @throws NoSuchElementException
*/
public void removeFirst() throws NoSuchElementException {
return;
}
/**
* removes the element at the end of the LinkedList
* @precondition
* @postcondition
* @throws NoSuchElementException
*/
public void removeLast() throws NoSuchElementException {
return;
}
/**
* removes the element referenced by the iterator
* @precondition
* @pos.
Problem- Describe an algorithm for concatenating two singly linked lis.pdfJamesPXNNewmanp
Problem: Describe an algorithm for concatenating two singly linked lists L and M, into a single
list L that contains all the nodes of L followed by all the nodes of M.
Modify the SinglyLinkedList class to contain the method:
public void concatenate(SinglyLinkedList other) { ... }
---------------Below is the code--------------------
public class SinglyLinkedList<E> implements Cloneable {
//---------------- nested Node class ----------------
/**
* Node of a singly linked list, which stores a reference to its
* element and to the subsequent node in the list (or null if this
* is the last node).
*/
private static class Node<E> {
/** The element stored at this node */
private E element; // reference to the element stored at this node
/** A reference to the subsequent node in the list */
private Node<E> next; // reference to the subsequent node in the list
/**
* Creates a node with the given element and next node.
*
* @param e the element to be stored
* @param n reference to a node that should follow the new node
*/
public Node(E e, Node<E> n) {
element = e;
next = n;
}
// Accessor methods
/**
* Returns the element stored at the node.
* @return the element stored at the node
*/
public E getElement() { return element; }
/**
* Returns the node that follows this one (or null if no such node).
* @return the following node
*/
public Node<E> getNext() { return next; }
// Modifier methods
/**
* Sets the node's next reference to point to Node n.
* @param n the node that should follow this one
*/
public void setNext(Node<E> n) { next = n; }
} //----------- end of nested Node class -----------
// instance variables of the SinglyLinkedList
/** The head node of the list */
private Node<E> head = null; // head node of the list (or null if empty)
/** The last node of the list */
private Node<E> tail = null; // last node of the list (or null if empty)
/** Number of nodes in the list */
private int size = 0; // number of nodes in the list
/** Constructs an initially empty list. */
public SinglyLinkedList() { } // constructs an initially empty list
// access methods
/**
* Returns the number of elements in the linked list.
* @return number of elements in the linked list
*/
public int size() { return size; }
/**
* Tests whether the linked list is empty.
* @return true if the linked list is empty, false otherwise
*/
public boolean isEmpty() { return size == 0; }
/**
* Returns (but does not remove) the first element of the list
* @return element at the front of the list (or null if empty)
*/
public E first() { // returns (but does not remove) the first element
if (isEmpty()) return null;
return head.getElement();
}
/**
* Returns (but does not remove) the last element of the list.
* @return element at the end of the list (or null if empty)
*/
public E last() { // returns (but does not remove) the last element
if (isEmpty()) return null;
return tail.getElement();
}
// update methods
/**
* Adds an element to the front of the list.
* @param e the new element to add
*/
publ.
write a short essay report to describe a topic of your interest rela.pdfrishabjain5053
write a short essay report to describe a topic of your interest related to the past, or current, or
future technologies of cellular communications, bandwidths, antennas or their impact to the
human society
Solution
past, or current, or future technologies of cellular communications:
Mobile computing is to describe technologies thatenable people to access network services
anyplace, anytime, and anywhere.
past,present technologies of cellular communications:
1896 Guglielmo Marconi,First demonstration of wireless telegraphy.Based on long wave,
requiring very large transmitters
1907 Commercial Trans-Atlantic Wireless Service.Huge ground stations: 30 x 100m antenna
masts
1920 Discovery of short waves by Marconi.Cheaper, smaller, better quality transmitters by
vacuum tube
1982 Start of GSM in Europe (1G analog)
1983 Start of AMPS in America (1G analog)
1992 Start of GSM (2G digital)
1997 Wireless LAN - IEEE802.11
1998 Iridium satellite system.
1999 Standardization of additional wireless LANs
2000 GSM with higher data rates (2.5G digital).HSCSD offers up to 57,6kbit/s.First GPRS trials
with up to 50 kbit/s
2001 Start of 3G systems.IMT - 2000, several “members” of a “family”, CDMA2000 in Korea,
UMTS tests in Europe.
GPRS: General Packet Radio Service
It is a mobile data service available to users of GSM mobile phones. It is often described as
\"2.5G“.
GPRS is packet-switched which means that multiple users share the same transmission channel,
only transmitting when they have data to send.
GPRS provides moderate speed data transfer, by allocating unused cell bandwidth to transmit
data.Poor bit rate in busy cells.Usually, GPRS data is billed per kilobytes of information
transceived.
future technologies of cellular communications:
Improved radio technology and antennas.smart antennas, beam forming, multiple-input multiple-
output (MIMO) 802.11N.dynamic spectrum allocation.Core network convergence.IP-based,
quality of service, mobile IP.Ad-hoc technologies.spontaneous communication, power saving,
redundancy.Simple and open service platform.intelligence at the edge, not in the network (as
with IN).more service providers, not network operators only.
Impact on Society:
Since the introduction of mobile phones, concerns (both scientific and public) have been raised
about the potential health impacts from regular use.But by 2008, American mobile phones
transmitted and received more text messages than phone calls.Numerous studies have reported
no significant relationship between mobile phone use and health, but the effect of mobile phone
usage on health continues to be an area of public concern.
For example, at the request of some of their customers, Verizon created usage controls that meter
service and can switch phones off, so that children could get some sleep.There have also been
attempts to limit use by persons operating moving trains or automobiles, coaches when writing to
potential players on their teams, and movie theater audiences. By one measure, near.
Write a C++ program to do the followingProject Name Computer Sho.pdfrishabjain5053
Write a C++ program to do the following:
Project Name: Computer Shop Management System
Project Description: sells various types of hardware and software accessories such as Laptop,
Antivirus and Keyboard etc. This system enables its user’s keep their customers
report secure, so that next time these customers when arrive to their shop, do not have to enter
their details again.
Solution.
More Related Content
Similar to Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Please complete all the code as per instructions in Java programming.docxcgraciela1
Please complete all the code as per instructions in Java programming import org.w3c.dom.Node; import javax.xml.crypto.NodeSetData; import java.awt.*; import java.util.Iterator; import java.util.NoSuchElementException; /** * This class implements an acyclic (non-cyclic), doubly-linked list. * @param */ public class CiscDoublyLinkedList implements CiscList { /** * A reference to the first node in the list (or null if list is empty). */ private Node head; /** * A reference to the last node int the list (or null if list is empty). */ private Node tail; /** * Number of elements in the list. */ private int size; /** * Returns the number of elements in this list. * * * @return the number of elements in this list */ @Override public int size() { return size; } /** * Returns {@code true} if this list contains no elements. * * * @return {@code true} if this list contains no elements */ @Override public boolean isEmpty() { if (size == 0){ return true; } return false; } /** * Returns {@code true} if this list contains the specified element (compared using the {@code equals} method). * * * @param o element whose presence in this list is to be tested * @return {@code true} if this list contains the specified element * @throws NullPointerException if the specified element is null */ @Override public boolean contains(Object o) { if(o == null) { throw new NullPointerException(); } Node node = head; while(node != null) { if(node.data.equals(o)){ return true; } node = node.next; } return false; } /** * Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not * contain the element (compared using the {@code equals} method). * * * @param o element to search for * @return the index of the first occurrence of the specified element in this list, or -1 if this list does not * contain the element * @throws NullPointerException if the specified element is null */ @Override public int indexOf(Object o) { if (o == null){ throw new NullPointerException(); } for(int i =0; i = size){ throw new IndexOutOfBoundsException(); } return null; } /** * Appends the specified element to the end of this list. * * *
Lists may place the specified element at arbitrary locations if desired. In particular, an ordered list will * insert the specified element at its sorted location. List classes should clearly specify in their documentation * how elements will be added to the list if different from the default behavior (end of this list). * * @param e element to be appended to this list * @return {@code true} * @throws NullPointerException if the specified element is null */ @Override public boolean add(E e) { if(e == null){ throw new NullPointerException(); } return false; } /** * Replaces the element at the specified position in this list with the specified element. * * * @param index index of the element to replace * @param element element to be stored at the specified position * @return the element previously at the specified position *.
Note- Can someone help me with the public boolean isEmpty()- public bo.pdfAugstore
Note: Can someone help me with the public boolean isEmpty(), public boolean contains(Object
o), public int indexOf(Object o) and public E get(int index)methods using abstract List. package
edu.ust.cisc; import java.util.Iterator; public abstract class CiscAbstractList implements CiscList
{ /** * Returns the number of elements in this list. * * @return the number of elements in this
list */ @Override public int size() { int size = 0; Iterator itr = iterator(); while(itr.hasNext()) {
itr.next(); size++; } return size; } /** * Returns {@code true} if this list contains no elements. *
* @return {@code true} if this list contains no elements */ @Override public boolean isEmpty()
{ return false; } /** * Returns {@code true} if this list contains the specified element (compared
using the {@code equals} method). * * @param o element whose presence in this list is to be
tested * @return {@code true} if this list contains the specified element * @throws
NullPointerException if the specified element is null */ @Override public boolean
contains(Object o) { return false; } /** * Returns the index of the first occurrence of the specified
element in this list, or -1 if this list does not * contain the element (compared using the {@code
equals} method). * * @param o element to search for * @return the index of the first occurrence
of the specified element in this list, or -1 if this list does not * contain the element * @throws
NullPointerException if the specified element is null */ @Override public int indexOf(Object o)
{ return 0; } /** * Removes all of the elements from this list. The list will be empty after this call
returns. */ @Override public abstract void clear(); /** * Returns the element at the specified
position in this list. * * @param index index of the element to return * @return the element at
the specified position in this list * @throws IndexOutOfBoundsException if the index is out of
range */ @Override public E get(int index) { return null; } /** * Appends the specified element
to the end of this list. * *
Lists may place the specified element at arbitrary locations if desired. In particular, an ordered
list will * insert the specified element at its sorted location. List classes should clearly specify in
their documentation * how elements will be added to the list if different from the default
behavior (end of this list). * * @param e element to be appended to this list * @return {@code
true} * @throws NullPointerException if the specified element is null */ @Override public
boolean add(E e) { return false; } /** * Replaces the element at the specified position in this list
with the specified element (optional operation). * * @param index index of the element to
replace * @param element element to be stored at the specified position * @return the element
previously at the specified position * @throws UnsupportedOperationException if the {@code
set} operation is not supported by this list * @throws NullPointerException if the specified
el.
please i need help Im writing a program to test the merge sort alg.pdfezonesolutions
please i need help I\'m writing a program to test the merge sort algorithm for linked lists.
I need to Print the list before being sorted and the list after sorting the elements
here is my code only help in test program the four classes are ok except the test program.
TEST PROGRAM
import java.io.*;
import java.util.*;
public class Ch9_ProgExercise7 {
Scanner input = new Scanner(System.in);
public static void main(String[] args) throws IOException {
OrderedLinkedList list
= new OrderedLinkedList(); //Line 1
IntElement num = new IntElement(); //Line 2
// Prompt the user to enter some integers
System.out.println(\"Enter integers numbers \");
String temp = input.hasnextLine();
String[] split = temp.split(\" \");
for (int i = 0; i < split.length; i++) {
Integer a = Integer.parseInt(split[i]);
// insert the intgers into the list you created above
num.setNum(a);
list.insertNode(num);
}
System.out.println();
// Print the list before being sorted
// call the mergesort method
System.out.println();
// print the list after sorting the elements
}
}
ORDEREDLICKEDLIST CLASS
public class OrderedLinkedList extends LinkedListClass
{
//default constructor
public OrderedLinkedList()
{
super();
}
//copy constructor
public OrderedLinkedList(OrderedLinkedList otherList)
{
super(otherList);
}
public void linkedInsertionSort()
{
LinkedListNode lastInOrder;
LinkedListNode firstOutOfOrder;
LinkedListNode current;
LinkedListNode trailCurrent;
lastInOrder = first;
if(first == null)
System.out.println(\"Cannot sort an empty list\");
else
if(first.link == null)
System.out.println(\"The list is of length 1. \"
+ \"Already in order\");
else
while(lastInOrder.link != null)
{
firstOutOfOrder = lastInOrder.link;
if(firstOutOfOrder.info.compareTo(first.info) < 0)
{
lastInOrder.link = firstOutOfOrder.link;
firstOutOfOrder.link = first;
first = firstOutOfOrder;
}
else
{
trailCurrent = first;
current = first.link;
while(current.info.compareTo(firstOutOfOrder.info) < 0)
{
trailCurrent = current;
current = current.link;
}
if(current != firstOutOfOrder)
{
lastInOrder.link = firstOutOfOrder.link;
firstOutOfOrder.link = current;
trailCurrent.link = firstOutOfOrder;
}
else
lastInOrder = lastInOrder.link;
}
}
}//end linkedInsertionSort
//Method to determine whether searchItem is in
//the list.
//Postcondition: Returns true if searchItem is found
// in the list; otherwise, it returns
// false.
public boolean search(DataElement searchItem)
{
LinkedListNode current; //variable to traverse the list
boolean found;
current = first; //set current to point to the first
//node in the list
found = false; //set found to false
while(current != null && !found ) //search the list
if(current.info.compareTo(searchItem) >= 0)
found = true;
else
current = current.link; //make current point to
//the next node
if(found)
found = current.info.equals(searchItem);
return found;
}
//Method to insert insertItem in the list
//Postcondition: first points to the new list,
// newItem is inserted at the proper place
//.
Class DiagramIn the Assignment #10, you are given three files Ass.pdfxlynettalampleyxc
Class Diagram:
In the Assignment #10, you are given three files Assignment10.java, LinkedList.java, and
ListIterator.java. You will need to add additional methods in the LinkedList class in the
LinkedList.java file. The LinkedList will be tested using strings only.
Specifically, the following methods must be implemented in the LinkedList class:
(You should utilize listIterator() method already defined in the LinkedList class to obtain its
LinkedListIterator object, and use the methods in the LinkedListIterator class to traverse from
the first element to the last element of the linked list to define the following methods.)
1.
public String toString()
The toString method should concatenate strings in the linked list, and return a string of the
following format:
{ Apple Banana Melon Orange }
Thus it starts with \"{\" and ends with \"}\", and there is a space between strings and \"{\" or
\"}\". If the list is empty, it returns \"{ }\" with a space in between.
2.
public boolean isEmpty()
The isEmpty method returns true of the linked list is empty, false otherwise.
3.
public void addElement(Object element)
The addElement adds the parameter element at the parameter in the linked list in alphabetical
order. For instance, if the linked list contains {Apple, Banana, Grape}, and a user tries to add
\"Carrot\", then it should be added as:
{Apple, Banana, Carrot, Grape}.
4.
public Object removeElement(int index)
The removeElement removes the string (Object) at the parameter index and returns it. Note that
this index starts with 0 just like array indices. For instance, if the linked list contains {Apple,
Banana, Carrot, Grape} and the parameter index is 3, then \"Grape\" should be remove. If the
parameter index is larger or smaller than the existing indices, it should throw an object of the
IndexOutOfBoundsException class (and the content of the linked list should remain unchanged).
5.
public Object getElement(int index)
The getElement searches the string (Object) at the parameter index and returns it. Note that this
index starts with 0 just like array indices. For instance, if the linked list contains {Apple, Banana,
Carrot, Grape} and the parameter index is 3, then \"Grape\" will be returned. If the parameter
index is larger or smaller than the existing indices, it should throw an object of the
IndexOutOfBoundsException class (and the content of the linked list should remain unchanged).
6.
public void searchAndReplace(Object oldString, Object newString)
The searchAndReplace method searches all occurrences of the first parameter string (object) in
the list, and replaces them with the second parameter string (object). If the parameter string does
not exist in the linked list, then the linked list content will not change.
7.
public int indexOfLast(Object searchString)
The indexOfLast searches the parameter string (object) with the largest index, and returns its
index. If the parameter string does not exist in the linked list, then it should return -1.
For i.
package ADTs public interface CollectionADTltTgt .pdfsyedabdul78662
package ADTs;
public interface CollectionADT<T> {
public boolean isEmpty();
public int size();
@Override
public String toString();
}
**********************************************************
package ADTs;
import Exceptions.*;
/**
* An interface for an ordered (NOT SORTED) List
* Elements stay in the order they are put in to the list
* For use in Data Structures & Algorithms
*
*
* @author
*/
public interface ListADT<T> extends CollectionADT<T> {
/**
* Adds the specified element to the list at the front
*
* @param element: the element to be added
*
*/
public void addFirst(T element);
/**
* Adds the specified element to the end of the list
*
* @param element: the element to be added
*/
public void addLast(T element);
/**
* Adds the specified element to the list after the existing element
*
* @param existing: the element that is in the list already
* @param element: the element to be added
* @throws ElementNotFoundException if existing isn't in the list
*/
public void addAfter(T existing, T element) throws ElementNotFoundException,
EmptyCollectionException;
/**
* Removes and returns the specified element
*
* @return the element specified
* @throws EmptyCollectionException
* @throws ElementNotFoundException
*/
public T remove(T element) throws EmptyCollectionException, ElementNotFoundException;
/**
* Removes and returns the first element
*
* @return the first element in the list
* @throws EmptyCollectionException
*/
public T removeFirst() throws EmptyCollectionException;
/**
* Removes and returns the last element
*
* @return the last element in the list
* @throws EmptyCollectionException
*/
public T removeLast() throws EmptyCollectionException;
/**
* Returns (without removing) the first element in the list
*
* @return element at the beginning of the list
* @throws EmptyCollectionException
*/
public T first() throws EmptyCollectionException;
/**
* Returns (without removing) the last element in the list
*
* @return element at the end of the list
* @throws EmptyCollectionException
*/
public T last() throws EmptyCollectionException;
/**
* Return whether the list contains the given element.
*
* @param element
* @return
* @throws EmptyCollectionException
*/
public boolean contains(T element) throws EmptyCollectionException;
/**
* Returns the index of the given element.
*
* @param element
* @return the index of the element, or -1 if not found
*/
public int indexOf(T element);
/**
* Return the element at the given index of a list.
*
* @param element
* @return
* @throws EmptyCollectionException
*/
public T get(int index) throws EmptyCollectionException, InvalidArgumentException;
/**
* Set the at the given index of a list.
*
* @param element
* @return
* @throws EmptyCollectionException
*/
public void set(int index, T element) throws EmptyCollectionException, InvalidArgumentException;
}
**********************************************
package ADTs;
import Exceptions.EmptyCollectionException;
import Exceptions.QueueOverflowException;
public interface QueueADT<.
2.(Sorted list array implementation)This sorted list ADT discussed .pdfarshin9
2.(Sorted list: array implementation)This sorted list ADT discussed in class should be extended
by the addition of two new methods:
//Interface: ArrayListADT
//works for int
public interface ArrayListADT {
public boolean isEmpty(); //Method to determine whether the list is empty.
public boolean isFull(); //Method to determine whether the list is full.
public int listSize(); //Method to return the number of elements in the list.
public int maxListSize(); //Method to return the maximum size of the list.
public void print(); //Method to output the elements of the list.
public boolean isItemAtEqual(int location, int item); //Method to determine whether item is
the same as the item in the list at location.
public void insertAt(int location, int insertItem); //Method to insert insertItem in the list at
the position
public void insertEnd(int insertItem); //Method to insert insertItem at the end of the list.
public void removeAt(int location); //Method to remove the item from the list at location.
public int retrieveAt(int location); //Method to retrieve the element from the list at location.
public void replaceAt(int location, int repItem); //Method to replace the element in the list at
location with repItem.
public void clearList(); //Method to remove all the elements from the list.
public int search(int searchItem); //Method to determine whether searchItem is in the list.
public void remove(int removeItem); //Method to remove an item from the list.
}
//Class: ArrayListClass implements
//Interface: ArrayListADT
public abstract class ArrayListClass implements ArrayListADT {
protected int length; //to store the length of the list
protected int maxSize; //to store the maximum size of the list
protected int[] list; //array to hold the list elements
//Default constructor
public ArrayListClass() {
maxSize = 100;
length = 0;
list = new int[maxSize];
}
//Alternate Constructor
public ArrayListClass(int size) {
if(size <= 0) {
System.err.println(\"The array size must be positive. Creating an array of size 100.\");
maxSize = 100;
}
else
maxSize = size;
length = 0;
list = new int[maxSize];
}
public boolean isEmpty() {
return (length == 0);
}
public boolean isFull() {
return (length == maxSize);
}
public int listSize() {
return length;
}
public int maxListSize() {
return maxSize;
}
public void print() {
for (int i = 0; i < length; i++)
System.out.print(list[i] + \" \");
System.out.println();
}
public boolean isItemAtEqual(int location, int item) {
if (location < 0 || location >= length) {
System.err.println(\"The location of the item to be compared is out of range.\");
return false;
}
return list[location]== item;
}
public void clearList() {
for (int i = 0; i < length; i++)
list[i] = 0;
length = 0;
System.gc(); //invoke the Java garbage collector
}
public void removeAt(int location) {
if (location < 0 || location >= length)
System.err.println(\"The location of the item to be removed is out of range.\");
else {
for(int i = location; i < length - 1; i++)
list[i] .
The LinkedList1 class implements a Linked list. class.pdfmalavshah9013
/**
The LinkedList1 class implements a Linked list.
*/
class LinkedList1
{
/**
The Node class stores a list element
and a reference to the next node.
*/
private class Node
{
String value;
Node next;
/**
Constructor.
@param val The element to store in the node.
@param n The reference to the successor node.
*/
Node(String val, Node n)
{
value = val;
next = n;
}
/**
Constructor.
@param val The element to store in the node.
*/
Node(String val)
{
// Call the other (sister) constructor.
this(val, null);
}
}
private Node first; // list head
private Node last; // last element in list
/**
Constructor.
*/
public LinkedList1()
{
first = null;
last = null;
}
/**
The isEmpty method checks to see
if the list is empty.
@return true if list is empty,
false otherwise.
*/
public boolean isEmpty()
{
return first == null;
}
/**
The size method returns the length of the list.
@return The number of elements in the list.
*/
public int size()
{
int count = 0;
Node p = first;
while (p != null)
{
// There is an element at p
count ++;
p = p.next;
}
return count;
}
/**
The add method adds an element to
the end of the list.
@param e The value to add to the
end of the list.
*/
public void add(String e)
{
if (isEmpty())
{
first = new Node(e);
last = first;
}
else
{
// Add to end of existing list
last.next = new Node(e);
last = last.next;
}
}
/**
The add method adds an element at a position.
@param e The element to add to the list.
@param index The position at which to add
the element.
@exception IndexOutOfBoundsException When
index is out of bounds.
*/
public void add(int index, String e)
{
if (index < 0 || index > size())
{
String message = String.valueOf(index);
throw new IndexOutOfBoundsException(message);
}
// Index is at least 0
if (index == 0)
{
// New element goes at beginning
first = new Node(e, first);
if (last == null)
last = first;
return;
}
// Set a reference pred to point to the node that
// will be the predecessor of the new node
Node pred = first;
for (int k = 1; k <= index - 1; k++)
{
pred = pred.next;
}
// Splice in a node containing the new element
pred.next = new Node(e, pred.next);
// Is there a new last element ?
if (pred.next.next == null)
last = pred.next;
}
/**
The toString method computes the string
representation of the list.
@return The string form of the list.
*/
public String toString()
{
StringBuilder strBuilder = new StringBuilder();
// Use p to walk down the linked list
Node p = first;
while (p != null)
{
strBuilder.append(p.value + \"\ \");
p = p.next;
}
return strBuilder.toString();
}
/**
The remove method removes the element at an index.
@param index The index of the element to remove.
@return The element removed.
@exception IndexOutOfBoundsException When index is
out of bounds.
*/
public String remove(int index)
{
if (index < 0 || index >= size())
{
String message = String.valueOf(index);
throw new IndexOutOfBoundsException(message);
}
String element; // The element to return
if (index == 0)
{
// Removal of first item in the list
element.
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfclimatecontrolsv
PROBLEM STATEMENT:
In this assignment, you will complete DoubleEndedList.java that implements the ListInterface as
well as an interface called DoubleEndedInterface which represents the list's entries by using a
chain of nodes that has both a head reference and a tail reference. Be sure to read through the
code and understand the implementation.
WHAT IS PROVIDED:
- A driver class to test your code. You should not modify this file!
- A list interface (ListInterface.java)
- A double ended interface (DoubleEndedInterface.java)
- An incomplete DoubleEndedList class (DoubleEndedList.java)
WHAT YOU NEED TO DO:
4. Complete the DoubleEndedList class
4. Run the driver and make sure your output is exactly the same as mine (at the bottom of
Driver.java)
\} // end else numberofEntries--; else throw new IndexOut0fBoundsException("Illegal position
given to remove operation."); return result; // Return removed entry }//endreturnreve public T
replace(int givenPosition, T newEntry) \{ T replace(int givenPosition, T newEntry) \{ if
((givenPosition >=1)&& (givenPosition <= numberOfEntries)) \{ // Assertion: The list is not
empty Node desiredNode = getNodeAt (givenPosition); ToriginalEntry = desiredNode.getData();
desiredNode.setData(newEntry); return originalEntry; f // end if else throw new
IndexOut0fBoundsException("Illegal position given to replace operation."); replace if ((
givenPosition >=1)&& (givenPosition <= number0fEntries)) \{ // Assertion: The list is not
empty Node desiredNode = getNodeAt ( givenPosition); T originalEntry = desiredNode.
getData( ); desiredNode.setData(newEntry); return originalentry; \} // end if throw new
Index0ut0fBoundsException("Illegal position given to replace operation."); \} // end replace
public T getEntry(int givenPosition) \{ if ((givenPosition >=1) \&\& (givenPosition < =
number0fEntries ) ) \{ // Assertion: The list is not empty return getNodeAt (givenPosition).
getData(); else // end if throw new IndexOut0fBoundsException("Illegal position given to
getEntry operation."); \} // end getEntry public boolean contains ( T anEntry) \{ boolean found =
false; Node currentNode = firstNode; while (!found && (currentNode != null)) \{ if
(anEntry.equals (currentNode.getData())) else found = true; \} // end while currentNode =
currentNode. getNextNode () ; return found; \} // end contains public int getLength() \{ return
numberofEntries; \} // end getLength public boolean isEmpty() \{ return number0fEntries ==0;
\} // end isEmpty public T[] toArray() \{ // The cast is safe because the new array contains null
entries aSuppressWarnings ("unchecked") T[] result =(T[]) new 0bject [numberofEntries]; //
Unchecked cast int index =0; Node currentNode = firstNode; while ((index < numberOfEntries)
\&\& (currentNode != null)) \& result [ index ]= currentNode. getData () ; currentNode =
currentNode.getNextNode ( ); index++; 3 // end while return result; 3 // end toArray // Returns a
reference to the node at a given position. // Precondition: L.
public class MyLinkedListltE extends ComparableltEgtg.pdfaccostinternational
public class MyLinkedList<E extends Comparable<E>> {
private Node<E> head, tail;
private int size = 0; // Number of elements in the list
public MyLinkedList() {
head=tail=null;
size=0;
}
/** Return the head element in the list */
public E getFirst() {
if (size == 0) {
return null;
}
else {
return head.element;
}
}
/** Return the last element in the list */
public E getLast() {
if (size == 0) {
return null;
}
else {
return tail.element;
}
}
/** Add an element to the beginning of the list */
public void addFirst(E e) {
Node<E> newNode = new Node<>(e); // Create a new node
newNode.next = head; // link the new node with the head
head = newNode; // head points to the new node
size++; // Increase list size
if (tail == null) // the new node is the only node in list
tail = head;
}
/** Add an element to the end of the list */
public void addLast(E e) {
Node<E> newNode = new Node<>(e); // Create a new for element e
if (tail == null) {
head = tail = newNode; // The new node is the only node in list
}
else {
tail.next = newNode; // Link the new with the last node
tail = newNode; // tail now points to the last node
}
size++; // Increase size
}
public void add(int index, E e) {
if (index == 0) {
addFirst(e);
}
else if (index >= size) {
addLast(e);
}
else {
Node<E> current = head;
for (int i = 1; i < index; i++) {
current = current.next;
}
Node<E> temp = current.next;
current.next = new Node<>(e);
(current.next).next = temp;
size++;
}
}
//Add e to the end of this linkedlist
public void add(E e) {
// Left as Exercise
}
/** Remove the head node and
* return the object that is contained in the removed node. */
public E removeFirst() {
if (size == 0) {
return null;
}
else {
E temp = head.element;
head = head.next;
size--;
if (head == null) {
tail = null;
}
return temp;
}
}
/** Remove the last node and
* return the object that is contained in the removed node. */
public E removeLast() {
if (size == 0) {
return null;
}
else if (size == 1) {
E temp = head.element;
head = tail = null;
size = 0;
return temp;
}
else {
Node<E> current = head;
for (int i = 0; i < size - 2; i++) {
current = current.next;
}
E temp = tail.element;
tail = current;
tail.next = null;
size--;
return temp;
}
}
/** Remove the element at the specified position in this
* list. Return the element that was removed from the list. */
public E remove(int index) {
if (index < 0 || index >= size) {
return null;
}
else if (index == 0) {
return removeFirst();
}
else if (index == size - 1) {
return removeLast();
}
else {
Node<E> previous = head;
for (int i = 1; i < index; i++) {
previous = previous.next;
}
Node<E> current = previous.next;
previous.next = current.next;
size--;
return current.element;
}
}
/** Clear the list */
public void clear() {
size = 0;
head = tail = null;
}
/** Override toString() to return elements in the list in [] separated by , */
public String toString() {
StringBuilder result = new StringBuilder("[");
Node<E> current = head;
for (int i = 0; i < size; i++) {
result.append(current..
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdfezzi97
Homework 05 - Linked Lists (C++)
(1) Implement the concepts of a union, and difference as defined noted in Chapter 1 questions 6,
and 8 using a linked list. You should not use arrays, dynamic arrays or the STL vector or STL
list classes.
You will be linking a series of nodes together to implement a single linked list class. Define a
Node as a struct that holds a character (like they did in the book) and a pointer to another Node:
struct Node {
char data;
Node* next;
};
Then define a LinkedList class which has (at a minimum) these member functions:
LinkedList();
~LinkedList();
bool insertAtFront();
bool insertBeforePosition(int index);
bool insertAtBack();
bool deleteAtFront();
bool deleteBeforePosition(int index);
bool deleteAtBack();
Implement each of these functions to provide the correct functionality. These functions return
true if successful in inserting or deleting, otherwise they return false (indicating the operation
was not successful).
Finally, create an overloaded + operator to handle the Union of two linked lists and an
overloaded - operator to handle the Difference of two linked lists.
Because we are dealing with pointers you should have both a LinkedList Constructor and
Destructor. Remember that you do not directly call a Constructor or Destructor Function. The
Destructor is automatically called when the variable loses scope or the program ends.
Remember, that we are dealing with not just one dynamically allocated Node (with the new
operator), but many, so you will have to start at the head of the list and go until the Node points
to nullptr. Then keep deleting the previous Node pointer until there are no Nodes left to delete.
(2) To verify your set class, write a main function that takes two lines of characters from the
input file input.txt and store each line of characters into two separate linked lists. Then using
these two lists, perform the Union and set Difference of the characters from the file, and print the
results to the console.
(3) Please also complete an asymptotic (Big O) analysis of your insertAtFront() and
insertAtBack() member functions. Place this in a file called analysis.txt.
Solution
Here is the complete code for your question. Please do rate the aswer if you are happy with
program. Please read comments in the program. Also pay special attention to comments in + and
- operators. You WILL NEED to comment out if condition in + if you want all elements in both
lists irrespective of if they duplicates or no. For now implemented to have true behaviour of no
duplicates in union.
check the functions by creating some lists and playing around different fucntions like its done in
main and commented out.
As far as complexity:
for insertAtFront() its O(1) since it does not depend on the size of the list. It just replaces the start
of the list. Hence it is O(1) and independent of the size of list.
for insertAtBack(), its O(n) since it depends on the number of elements in the list. It should
traverse till end of list and .
package linkedLists- import java-util-Iterator- --- A class representi.pdfarcellzone
package linkedLists;
import java.util.Iterator;
/** A class representing a singly linked list from scratch. Fill in code.
*
* Note: you may NOT use any of Java's built in classes that store a collection of elements
* such as ArrayList, LinkedList (Java's built in), HashMap, HashTree, HashSet etc. */
public class LinkedList {
private Node head, tail;
/** Constructor */
public LinkedList() {
head = null;
tail = null;
}
/**
* Creates a new node with the given element and adds it to the back of the
* list. No need to change this method.
*/
public void append(int elem) {
Node newNode = new Node(elem);
if (tail != null) {
tail.setNext(newNode);
tail = newNode;
} else {
head = tail = newNode;
}
}
/** Prints all the nodes in the link list. No need to change this method. */
public void printNodes() {
Node current = head;
while (current != null) {
System.out.print(current.elem() + " ");
current = current.next();
}
}
/**
* Return a sublist of this list where the values of elements are in the range
* from value1 to value2, inclusive.
* Your method should not destroy the original list and its nodes should *not* reference
* the nodes in the input list (you need to create new nodes instead).
* Example:
* If the list is 6->40->3->17->1 and value1 is 3 and value2 is 20,
* then the result should be 6->3->17.
* @param value1 value 1
* @param value2 value 2
* @return a sublist of this list where the values of elements are in the range
* * from value1 to value2, inclusive.
*/
public LinkedList sublist(int value1, int value2) {
LinkedList res = new LinkedList();
// FILL IN CODE
return res;
}
/**
* Insert a new node with the given element into the sorted linked list.
* Insert it in the right place based on the value in the node. Assume the
* list is sorted by the elem, from smallest to largest. The
* list should remain sorted after this insert operation.
* Example: If this list is 5->10->18 and we insert 15, then after that the operation,
* the list will become 5->10->15->18.
*/
public void insertInSortedList(int elem) {
// insert a node into the sorted list
// FILL IN CODE
}
/**
* Assume this linked list is sorted in ascending order, and we do not know the
* * number of elements.
* * Return a LinkedList that contains k largest elements in the list.
* * Use slow & fast pointers to find the k-th node from the end (required). Note: This method
* * should be linear and should not count the number of nodes. Do NOT use reverse().
* @param k index from the end
* @return linked list that contains k largest elements (k elements from the end of the list)
*/
public LinkedList getKLargest(int k) {
LinkedList result = new LinkedList();
// FILL IN CODE
return result;
}
/**
* Merge two sorted linked lists into a single sorted linked list.
*
* @param list1
* @param list2
* Your method should not destroy the original list and its nodes should *not* reference
* the nodes in the input list (you need to create new nodes instead).
*/
public static LinkedList mergeSortedLists(LinkedLis.
Given below is the completed implementation of MyLinkedList class. O.pdfinfo430661
Given below is the completed implementation of MyLinkedList class. Other classes are not
modified and remain same as in question - MyList, MyAbstractList, TestMyLinkedList.
The output of TestMyLinkedList is shown below. Please don\'t forget to rate the answer if it
helped. Thank you very much.
Since the MyList is not completely pasted in the question ... giving the complete class file below
MyList.java
public interface MyList> extends java.lang.Iterable
{
// Add a new element at the end of this list
public void add (E e);
// Add a new element at specified index in this list
public void add (int index, E e);
// Return true if this list contains the element
public boolean contains (E e);
// Return the element at the specified index
public E get (int index);
// Return the index of the first matching element
// Return -1 if no match.
public int indexOf (E e);
// Return the index of the last matching element
// Return -1 if no match.
public int lastIndexOf (E e);
E remove(int index);
void clear();
E set(int index, E e);
}
MyLinkedList.java
public class MyLinkedList> extends MyAbstractList
implements Comparable>
{
private Node head, tail; // head and tail pointers
// Create a default list
public MyLinkedList()
{
}
public int size()
{
return size;
}
// Need this for implementing Comparable
public int compareTo (MyLinkedList e)
{
return(size() - e.size());
}
// Create a list from an array of objects
public MyLinkedList (E[] objects)
{
super(objects); // Passes the array up to abstract parent
}
// Return the head element in the list
public E getFirst()
{
if (size == 0)
{
return null;
}
else
{
return head.element;
}
}
// Return the last element in the list
public E getLast()
{
if (size == 0)
{
return null;
}
else
{
return tail.element;
}
}
// Add an element to the beginning of the list
public void addFirst (E e)
{
// Create a new node for element e
Node newNode = new Node(e);
newNode.next = head; // link the new node with the head
head = newNode; // head points to the new node
size++; // Increase list size
if (tail == null) // new node is only node
{
tail = head;
}
}
// Add an element to the end of the list
public void addLast (E e)
{
// Create a new node for element e
Node newNode = new Node(e);
if (tail == null)
{
head = tail = newNode; // new node is only node
}
else
{
tail.next = newNode; // Link the new with the last node
tail = tail.next; // tail now points to the last node
}
size++; // Increase size
}
// Remove the head node and
// return the object from the removed node
public E removeFirst()
{
if (size == 0)
{
return null;
}
else
{
Node temp = head;
head = head.next;
size--;
if (head == null)
{
tail = null;
}
return temp.element;
}
}
// Remove the last node and return the object from it
public E removeLast()
{
if (size == 0)
{
return null;
}
else if (size == 1)
{
Node temp = head;
head = tail = null;
size = 0;
return temp.element;
}
else
{
Node current = head;
for (int i = 0; i < size - 2; i++)
{
current = current.next;
}
Node temp = tail;
tai.
import java.util.Iterator; import java.util.NoSuchElementException; /** * An implementation
of MyList with a linked list (a longer exercise would be to * implement the List interface as is
done in the class java.util.LinkedList: * the source of the LinkedList class is available from Sun.
Check it out). */ public class MyLinkedList implements MyList { // A private class to
represent a Node in the linked list private class Node { public E item;
public Node next; // a convenient constructor public Node(E o) {
this.item = o; this.next = null; } } // The start of the linked
list private Node head; // The last Node in the linked list private Node tail;
// Number of elements in the list private int size; /** * Creates an empty list (this
constructor is not necessary) */ public MyLinkedList() { } /** *
Returns the number of elements in this list. */ public int size() { return size;
} /** * Returns true if this list contains no elements. */ public boolean
isEmpty() { return size == 0; } /** * Appends the specified element to
the end of this list */ public boolean add(E o) { Node n = new Node(o);
// If this is the first element in the list if (head == null) { head = n;
} else { // If the list is not empty, use tail tail.next = n;
} // update tail tail = n; // update size size++;
return true; } /** * Empties this List */ public void clear() {
// update head, tail and size head = tail = null; size = 0; } /**
* Returns the element at the specified position in this list. */ public E get(int index) {
if (index < 0 || index >= size) { throw new
IndexOutOfBoundsException(\"index = \" + index); } // Find it
Node n = head; for (int i = 0; i < index; i++) { n = n.next; }
return n.item; } /** * Returns the index of the specified element (-1 if
there is no match) */ public int indexOf(Object o) { // If o is null
int index = 0; Node p = head; if (o == null) // look for a null element in the
list { while (p != null) { if (p.item == null) {
return index; } index++;
p = p.next; } } else // o is an object (use equals) {
while (p != null) { if (o.equals(p.item)) { return
index; } index++; p = p.next;
} } // if we get here, o is not in the list return -1; }
/** * Returns true if this list contains the specified element. */ public boolean
contains(Object o) { // easy with indexOf return indexOf(o) != -1; }
/** * Removes the element in the List at position index */ public boolean
remove(int index) { if (index < 0 || index >= size) { throw new
IndexOutOfBoundsException(\"index = \" + index); } // Find the
corresponding node Node prev = null, p = head; for (int i = 0; i < index; i++)
{ prev = p; p = p.next; } // Remove it
// Special case for the first node if (p == head) { head = head.next;
} else { prev.next = p.next; } // If the last node has been
removed, update tail if (p == tail) { tail = prev; } //
update size size--; return true; } /** * Removes the element
in the List at position index */ public boolean remove(Object o) { // easy
with indexOf and remove int index = i.
Describe an algorithm for concatenating two singly linked lists L and.pdfdeepak596396
Dataset:
https://docs.google.com/spreadsheets/d/1NxuGt4LJ3ofi2PaWLWpAl90JmfqMKcGV/edit?usp=sharing&ouid=111109979069524025260&rtpof=true&sd=true
Q1) What is the average tenure of those customers of the telecom operator who are still with the
company as a customer and also those who have stopped using the services provided by the
company? (1 mark)
Here, churn = 'No' means that the customer is currently associated with the company, and churn
= 'Yes' means that the customer has stopped using the services provided by the company.
Q2)What is the monthly average revenue generated by the customers who are with the company
and also those who have left? (1 mark)
Q3) Find the percentage of churn and non-churn customers for each category of the following
services: (4 marks)
-MultipleLines
-PaperlessBilling
-OnlineSecurity
-OnlineBackup
-DeviceProtection
-TechSupport
-StreamingTV
-StreamingMovies.
A popular implementation of List is ArrayList- Look up how to instanti.pdfarsarees
A popular implementation of List is ArrayList. Look up how to instantiate one.
*
* @return a List<Integer> object.
*/
public List<Integer> createList(){
}
return null;
}
/**
* Get the size of a list.
*
* @param list a List<Integer> object.
* @return the size of List (number of items it holds.)
*/
return 0;
}
/**
* Add an item to a list.
* When we add a value to a list, it gets appended to the end.
*
* @param list a List<Integer> object that we would like to modify.
* @param value an integer that we would like to add to list.
* @return nothing, pass by reference will cause changes to the list object to be reflected across
the program.
*/
public void addToList(List<Integer> list, int value){
}
/**
* Get a particular index of a list.
* Lists, like arrays, are zero-indexed, so they start counting at zero. For instance,
* index 0 of {0,2,4,6} is 0.
* index 1 of {0,2,4,6} is 2.
* Index is the same as saying the position, number, etc of a value.
* Let's get the element from a list at a certain index.
*
* @param list a List<Integer> object that we would like to examine.
* @param index represents the index of the element we would like to retrieve.
* @return the int at the location in 'list' represented by 'index'.
*/
public int get(List<Integer> list, int index){
return 0;
}
/**
* Remove an index from a list.
* We can remove an item from the list, which will cause all items after it to reduce their index by
1 (they are
* all still ordered, without any empty spaces in the list.)
*
* @param list a List<Integer> object that we would like to modify.
* @param position represents the index of the element we would like to remove.
* @return nothing, pass by reference will cause changes to the list object to be reflected across
the program.
*/
public void removeFromList(List<Integer> list, int position){
}
/**
* Update an index of a list.
* We can update a value in the list, which will overwrite a value at a certain position.
*
* @param list a List<Integer> object that we would like to modify.
* @param position represents the index of the element we would like to change.
* @param value the new value which we would like to assign to the item at position in list
* @return nothing, pass by reference will cause changes to the list object to be reflected across
the program.
*/
public void updateAtPosition(List<Integer> list, int position, int value){
}
.
Please help me to make a programming project I have to sue them today- (1).pdfseoagam1
Please help me to make a programming project I have to sue them today. Please help me make a
UnsortedList and SortedList classes. The instructor give me The code of the List and AbstracList
Classes that 2 pages we do not modify them. Do not modify this pages!!! List.java import
java.util.Iterator; /** * Represents List interface. * * @author Varik Hoang * @version Sep 26,
2016 * @param is of any object type. */ public interface List { /** * The method returns the
current number of elements in the list. * * @return the current number of elements in the list
greater than or equal 0 */ public int getSize(); /** * The method returns whether the list is empty.
* * @return true if list is empty, false otherwise. */ public boolean isEmpty(); /** * The method
returns whether value is in the list. * * @param value the value is assigned * @return true if
value in the list, false otherwise. */ public boolean contains(Type value); /** * The method
inserts an element into the list. * * @param value the value is assigned */ public void insert(Type
value); /** * The method clears the list. */ public void clear(); /** * The method returns a string
representation of list contents. * * @return a string representation of list contents. * @see
Object#toString() */ @Override public String toString(); /** * /** * The method removes first
element occurrence from the list. * * @param value the value is assigned * @return the removed
value */ public Type remove(Type value); /** * The method returns the index of value. * *
@param value the value is assigned. * @return the index of value if in the list, -1 otherwise. */
public int getIndex(Type value); /** * The method removes value at the given index. * *
@param index the index must be in range of 0 and size * @return the removed value * @throws
IndexOutOfBoundsException if index less than 0 or index greater than * or equal size */ public
Type removeAtIndex(int index); /** * The method replaces the value at the given index with the
given value. * * @param index the index must be in range of 0 and size * @param value the
value is assigned * @throws IndexOutOfBoundsException if index less 0 or index greater than
size */ public void set(int index, Type value); /** * Returns the value at the given index in the
list. * * @param index the index must be in range of 0 and size * @throws
IndexOutOfBoundsException if index less than 0 or greater size * @return the value at the given
index in the list. */ public Type get(int index); /** * The method returns an iterator for this list. *
* @return an iterator for the list. */ public Iterator iterator(); } Do not modify this pages public
abstract class AbstractList implements List { /** * The reference to the last element */ protected
ListNode tail; /** * The size of the list */ protected int size; /** * The constructor that initiate the
tail and size references */ public AbstractList() { tail = null; size = 0; } @Override public int
getSize() { return size; } @Override public bool.
File LinkedList.java Defines a doubly-l.pdfConint29
File: LinkedList.java
/**
* Defines a doubly-linked list class
*/
import java.util.NoSuchElementException;
public class LinkedList {
private class Node {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
private int length;
private Node first;
private Node last;
private Node iterator;
/**** CONSTRUCTORS ****/
/**
* Instantiates a new LinkedList with default values
* @postcondition
*/
public LinkedList() {
}
/**
* Converts the given array into a LinkedList
* @param array the array of values to insert into this LinkedList
* @postcondition
*/
public LinkedList(T[] array) {
}
/**
* Instantiates a new LinkedList by copying another List
* @param original the LinkedList to copy
* @postcondition a new List object, which is an identical,
* but separate, copy of the LinkedList original
*/
public LinkedList(LinkedList original) {
}
/**** ACCESSORS ****/
/**
* Returns the value stored in the first node
* @precondition
* @return the value stored at node first
* @throws NoSuchElementException
*/
public T getFirst() throws NoSuchElementException {
return null;
}
/**
* Returns the value stored in the last node
* @precondition
* @return the value stored in the node last
* @throws NoSuchElementException
*/
public T getLast() throws NoSuchElementException {
return null;
}
/**
* Returns the data stored in the iterator node
* @precondition
* @return the data stored in the iterator node
* @throw NullPointerException
*/
public T getIterator() throws NullPointerException {
return null;
}
/**
* Returns the current length of the LinkedList
* @return the length of the LinkedList from 0 to n
*/
public int getLength() {
return -1;
}
/**
* Returns whether the LinkedList is currently empty
* @return whether the LinkedList is empty
*/
public boolean isEmpty() {
return false;
}
/**
* Returns whether the iterator is offEnd, i.e. null
* @return whether the iterator is null
*/
public boolean offEnd() {
return false;
}
/**** MUTATORS ****/
/**
* Creates a new first element
* @param data the data to insert at the front of the LinkedList
* @postcondition
*/
public void addFirst(T data) {
return;
}
/**
* Creates a new last element
* @param data the data to insert at the end of the LinkedList
* @postcondition
*/
public void addLast(T data) {
return;
}
/**
* Inserts a new element after the iterator
* @param data the data to insert
* @precondition
* @throws NullPointerException
*/
public void addIterator(T data) throws NullPointerException{
return;
}
/**
* removes the element at the front of the LinkedList
* @precondition
* @postcondition
* @throws NoSuchElementException
*/
public void removeFirst() throws NoSuchElementException {
return;
}
/**
* removes the element at the end of the LinkedList
* @precondition
* @postcondition
* @throws NoSuchElementException
*/
public void removeLast() throws NoSuchElementException {
return;
}
/**
* removes the element referenced by the iterator
* @precondition
* @pos.
Problem- Describe an algorithm for concatenating two singly linked lis.pdfJamesPXNNewmanp
Problem: Describe an algorithm for concatenating two singly linked lists L and M, into a single
list L that contains all the nodes of L followed by all the nodes of M.
Modify the SinglyLinkedList class to contain the method:
public void concatenate(SinglyLinkedList other) { ... }
---------------Below is the code--------------------
public class SinglyLinkedList<E> implements Cloneable {
//---------------- nested Node class ----------------
/**
* Node of a singly linked list, which stores a reference to its
* element and to the subsequent node in the list (or null if this
* is the last node).
*/
private static class Node<E> {
/** The element stored at this node */
private E element; // reference to the element stored at this node
/** A reference to the subsequent node in the list */
private Node<E> next; // reference to the subsequent node in the list
/**
* Creates a node with the given element and next node.
*
* @param e the element to be stored
* @param n reference to a node that should follow the new node
*/
public Node(E e, Node<E> n) {
element = e;
next = n;
}
// Accessor methods
/**
* Returns the element stored at the node.
* @return the element stored at the node
*/
public E getElement() { return element; }
/**
* Returns the node that follows this one (or null if no such node).
* @return the following node
*/
public Node<E> getNext() { return next; }
// Modifier methods
/**
* Sets the node's next reference to point to Node n.
* @param n the node that should follow this one
*/
public void setNext(Node<E> n) { next = n; }
} //----------- end of nested Node class -----------
// instance variables of the SinglyLinkedList
/** The head node of the list */
private Node<E> head = null; // head node of the list (or null if empty)
/** The last node of the list */
private Node<E> tail = null; // last node of the list (or null if empty)
/** Number of nodes in the list */
private int size = 0; // number of nodes in the list
/** Constructs an initially empty list. */
public SinglyLinkedList() { } // constructs an initially empty list
// access methods
/**
* Returns the number of elements in the linked list.
* @return number of elements in the linked list
*/
public int size() { return size; }
/**
* Tests whether the linked list is empty.
* @return true if the linked list is empty, false otherwise
*/
public boolean isEmpty() { return size == 0; }
/**
* Returns (but does not remove) the first element of the list
* @return element at the front of the list (or null if empty)
*/
public E first() { // returns (but does not remove) the first element
if (isEmpty()) return null;
return head.getElement();
}
/**
* Returns (but does not remove) the last element of the list.
* @return element at the end of the list (or null if empty)
*/
public E last() { // returns (but does not remove) the last element
if (isEmpty()) return null;
return tail.getElement();
}
// update methods
/**
* Adds an element to the front of the list.
* @param e the new element to add
*/
publ.
Similar to Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf (20)
write a short essay report to describe a topic of your interest rela.pdfrishabjain5053
write a short essay report to describe a topic of your interest related to the past, or current, or
future technologies of cellular communications, bandwidths, antennas or their impact to the
human society
Solution
past, or current, or future technologies of cellular communications:
Mobile computing is to describe technologies thatenable people to access network services
anyplace, anytime, and anywhere.
past,present technologies of cellular communications:
1896 Guglielmo Marconi,First demonstration of wireless telegraphy.Based on long wave,
requiring very large transmitters
1907 Commercial Trans-Atlantic Wireless Service.Huge ground stations: 30 x 100m antenna
masts
1920 Discovery of short waves by Marconi.Cheaper, smaller, better quality transmitters by
vacuum tube
1982 Start of GSM in Europe (1G analog)
1983 Start of AMPS in America (1G analog)
1992 Start of GSM (2G digital)
1997 Wireless LAN - IEEE802.11
1998 Iridium satellite system.
1999 Standardization of additional wireless LANs
2000 GSM with higher data rates (2.5G digital).HSCSD offers up to 57,6kbit/s.First GPRS trials
with up to 50 kbit/s
2001 Start of 3G systems.IMT - 2000, several “members” of a “family”, CDMA2000 in Korea,
UMTS tests in Europe.
GPRS: General Packet Radio Service
It is a mobile data service available to users of GSM mobile phones. It is often described as
\"2.5G“.
GPRS is packet-switched which means that multiple users share the same transmission channel,
only transmitting when they have data to send.
GPRS provides moderate speed data transfer, by allocating unused cell bandwidth to transmit
data.Poor bit rate in busy cells.Usually, GPRS data is billed per kilobytes of information
transceived.
future technologies of cellular communications:
Improved radio technology and antennas.smart antennas, beam forming, multiple-input multiple-
output (MIMO) 802.11N.dynamic spectrum allocation.Core network convergence.IP-based,
quality of service, mobile IP.Ad-hoc technologies.spontaneous communication, power saving,
redundancy.Simple and open service platform.intelligence at the edge, not in the network (as
with IN).more service providers, not network operators only.
Impact on Society:
Since the introduction of mobile phones, concerns (both scientific and public) have been raised
about the potential health impacts from regular use.But by 2008, American mobile phones
transmitted and received more text messages than phone calls.Numerous studies have reported
no significant relationship between mobile phone use and health, but the effect of mobile phone
usage on health continues to be an area of public concern.
For example, at the request of some of their customers, Verizon created usage controls that meter
service and can switch phones off, so that children could get some sleep.There have also been
attempts to limit use by persons operating moving trains or automobiles, coaches when writing to
potential players on their teams, and movie theater audiences. By one measure, near.
Write a C++ program to do the followingProject Name Computer Sho.pdfrishabjain5053
Write a C++ program to do the following:
Project Name: Computer Shop Management System
Project Description: sells various types of hardware and software accessories such as Laptop,
Antivirus and Keyboard etc. This system enables its user’s keep their customers
report secure, so that next time these customers when arrive to their shop, do not have to enter
their details again.
Solution.
Which statement pertaining to Port Scanning is FALSEA technique use.pdfrishabjain5053
Which statement pertaining to Port Scanning is FALSE?A technique used by IT system
administrators to locate vulnerabilities before the hackers find them.
Solution
solution)
ensure that
port scanning is a process to check the security policies security policies of their networks and by
attackers to identify network services running on a host and exploit vulnerabilities.this port
scanning is often done by administrators.Ensures that the principles of Net Neutrality are
safeguarded.
net neutrality means the internet service providers and the govternments regulating the internet
should treat the users same that means the data on the internet the same ,not different user by
user,content ,website,platform,application,type of attachment,or mode of communicatiion.
port scanning is a process to check the security policies security policies of their networks and
by attackers to identify network services running on a host and exploit vulnerabilities.this port
scanning is often done by administrators..
When did almost all animal phyla divergeSolutionAccording to .pdfrishabjain5053
When did almost all animal phyla diverge?
Solution
According to theory of cambrian explosion, beginning some 545 million years ago, an explosion
of diversity led to the appearance over a relatively short period of 5 million to 10 million years of
a huge number of complex, multi-celled organisms. Moreover, this burst of animal forms led to
most of the major animal groups we know today, that is, every extant Phylum. It is also
postulated that many forms that would rightfully deserve the rank of Phylum both appeared in
the Cambrian only to rapidly disappear..
What is the nipah virus Describe mechanism of infection How is it .pdfrishabjain5053
What is the nipah virus? Describe mechanism of infection? How is it transmitted? Why can\'t it
be an arbovirus?
Solution
What is Nipah Virus?
Nipah virus is a recently-identified, zoonotic (meaning a disease that can transmitted from
animals to human) paramyxovirus that causes severe disease in both animals and humans.The
natural host of this virus are fruit bats of the Pteropodidae Family, Pteropus genus. Outbreaks of
this viral disease have occurred in Malaysia, Singapore, India and Bangladesh, and a putative
Nipah virus was also recently associated with human disease in the Philippines. Nipah virus
causes febrile encephalitis with respiratory syndrome that has a high mortality rate.
Mechanism of infection:
The reservoir for Nipah virus is believed to be fruit bats, and humans are infected by contact with
infected bats or by contact with an intermediate animal host such as pigs. Pteropus species fruit
bats are the natural reservoir of Nipah virus.
Zoonotic transmission cycles of Nipah virus in Malaysia and Bangladesh: In Malaysia (left side
of panel), Nipah virus was transmitted from bats on fruit trees on pig farms to pigs.
Subsequently, pigs transmitted Nipah virus to people in close contact with the pigs. In
Bangladesh (right side of panel), Nipah virus is thought to be transmitted via the consumption of
raw date palm sap. While date palm sap is collected, bats drink from the sap stream or collection
pots and contaminate the sap with Nipah virus through their saliva or urine. People become
infected with Nipah virus after drinking this contaminated date palm sap. Subsequently, these
infected people can transmit Nipah virus to others via close contact.
Arbovirus are the virus that are transmitted from one human to the other by arthropod vectors ie.,
mosquitoes, ticks etc., example of a arboviral disease is yellow fever. Nipah virus is not an
arbovirus because it transmitted from bats to humans or from pigs to humans..
What is organizational inertia List some sources of inertia in a co.pdfrishabjain5053
What is organizational inertia? List some sources of inertia in a company like IBM or GM.
Solution
Organizational inertia refers to the phenomenon where the organization continues to move along
the path or trajectory, upon that the organization has been for quite some time. Here, the
organization does not want to change from that path and it acts as a negative point in the face of
changing business environment scenario.
There are following sources that can create the organizational inertia:
1. The rigid organizational structure where people show strong resistance to change.
2. The organizational policy
3. Benefits and perks offered to the employees and it is not changed due to the conflicting views.
4. Centralized decision making process
5. High cost of recruitment and employee welfare
6. Collective bargaining between the union and organization (if any).
Use fundamental identities to write tan t sec2t in terms of sint only.pdfrishabjain5053
Use fundamental identities to write tan t sec2t in terms of sint only.
Solution
tan^2 t sec^2 t
tan t = sin t / cos t
sec t = 1/ cos t
so , we can write
tan^2 t sec^2 t = sin^2 t / cos^2 t * 1/ cos^2 t
= sin^2 t / cos^4 t
cos^4 t = cos^2 t * cos^2 t
cos^2 t = ( 1- sin^2 t )
cos^4 t = ( 1 - sin^2 t )^2
= 1 - 2sin^2 t + sin^4 t
hence, we can write
tan^2 t sec^2 t = (sin^2 t )/ ( sin^4 t - 2sin^2 t + 1 ).
Twenty-five people responded to a questionnaire about what types of p.pdfrishabjain5053
Twenty-five people responded to a questionnaire about what types of pets they had. Construct a
frequency distribution for the data (D = dogs only, C = cats only, B = both, N = neither).
Solution
Frequency of any particular value ,X is just the number of times X occurs in this table.
For example, B occurs 14 times.
Here is the frequency tableVALUEFREQUENCYD5C4B14N2.
The universe began 13 7 billion years ago, is most directly an exa.pdfrishabjain5053
The universe began 13 7 billion years ago, \' is most directly an example of a __ claim
Epistemological Phenomenological Ethical Metaphysical Logical
Solution
Metaphysical
The big bang theory is an effort to explain what happened during and after that moment.
According to the standard theory, our universe sprang into existence as \"singularity\"
around13.7 billion years ago..
The Stevens Company provided $57000 of services on acco.pdfrishabjain5053
The Stevens Company provided $57000 of services on account during 2014, its first year in ope
estimates that it will be unable to collect 2% of its revenues on account. The amount of
uncollectible accounts expense recognized on the 2014 income statement was o $285 O $10.000
O $1140 O $4.250 type here to search e???
Solution
Uncollectible expense = 2% of service on account
= 57000*2%
= $1,140 answer
Uncollectible expense = 2% of service on account
= 57000*2%
= $1,140 answer.
The papillae on the tongue that do not contain any taste buds are the.pdfrishabjain5053
The papillae on the tongue that do not contain any taste buds are the _ papillae. filiform
fungiform foliate valuate
Solution
Answer:
a). Filiform
Explanation:
The tongue contains 4 types of papillae, the most common type is filiform, thin and wire shaped
and do not contain taste buds. Dorsal and anterior border of the tongue are mushroom shaped
papillae, fungiform, these have taste buds located near the middle or in the cleft of the papillae..
QUESTION 13 Which of the following benefits is a component of Social .pdfrishabjain5053
QUESTION 13 Which of the following benefits is a component of Social Security? A. workers\'
compensation B. disability benefits C.unemployment compensation D. legal assistance
Solution
answer ) option B Disability benefits
the U.S. Social Security system has three major components: retirement benefits, survivors\'
benefits and disability insurance.
answer ) option B Disability benefits
the U.S. Social Security system has three major components: retirement benefits, survivors\'
benefits and disability insurance..
Padre, Inc., buys 80 percent of the outstanding common stock of Sier.pdfrishabjain5053
Padre, Inc., buys 80 percent of the outstanding common stock of Sierra Corporation on January
1, 2015, for $796,960 cash. At the acquisition date, Sierra’s total fair value, including the
noncontrolling interest, was assessed at $996,200 although Sierra’s book value was only
$623,000. Also, several individual items on Sierra’s financial records had fair values that
differed from their book values as follows:
Buildings and equipment
(10-year remaining life)
For internal reporting purposes, Padre, Inc., employs the equity method to account for this
investment. The following account balances are for the year ending December 31, 2015, for both
companies.
Padre, Inc., buys 80 percent of the outstanding common stock of Sierra Corporation on January
1, 2015, for $796,960 cash. At the acquisition date, Sierra’s total fair value, including the
noncontrolling interest, was assessed at $996,200 although Sierra’s book value was only
$623,000. Also, several individual items on Sierra’s financial records had fair values that
differed from their book values as follows:
Solution
Ans:
Determination of consolidate Balances:
Acquisition-date subsidiary fair value (given) $996,200
Book value of subsidiary (given) $623,000
Fair value in excess of book value $373,200
Allocations to specific accounts based on difference between fair value and book value
Land $226,000
Buildings and equipment $18,000
Copyright $150,000
Notes payable $15,200
Total $373,200
Annual excess amortizations:
Buildings and equipment ($18,000 / 10) $1,800
Copyright ($150,000 / 20) $7,500
Notes payable ($15,200 / 8) $1,900
Total $7,600
Acquisition Method:
Consolidation Entries
Accounts
Padre
Sierra
Debit
Credit
No controlling Interest
Consolidates Total
Revenues
(1,396,980)
(657,250)
(2,054,230)
Cost of goods sold
736,000
399,000
1,135,000
Depreciation Expense
298,000
15,100
E
1,800
311,300
Amortization Expense
-
8,600
E
7,500
16,100
Interest Expense
50,100
5,550
E
1,900
57,550
Equity in Income of Sierra
(177,120)
-
I
177,120
-
Separate Company Net Income
(490,000)
(229,000)
consolidate Net Income
(534,280)
No controlling Interest in Sierra\'s Income
(44,280)
44,280
Controlling Interest in CNI
(490,000)
Retained Earnings 1 / 1
(1,380,000)
(463,000)
S
(463,000)
(1,380,000)
Net Income (above)
(490,000)
(229,000)
(490,000)
Dividend Paid
260,000
65,000
D
52,000
13,000
260,000
Retained Earnings 12/31
(1,610,000)
(627,000)
(1,610,000)
Current Assets
854,920
569,100
1,424,020
Investments in Sierra
922,080
-
D
52,000
S
I
A
-
Land
369,000
60,600
A
226,000
655,600
Buildings and Equipment
955,000
324,900
E
1,800
A
18,000
1,263,700
Copyright
-
163,400
A
150,000
E
7,500
305,900
Total Assets
3,101,000
1,118,000
3,649,220
Accounts Payable
(220,000)
(199,000)
(419,000)
Notes Payable
(521,000)
(132,000)
A
15,200
E
1,900
(639,700)
NCI in Sierra 1/1
NCI in Sierra 12/ 31
(199,240)
(230,520)
(230,520)
Common Stock
(300,000)
(100,000)
S
100,000
(300,000)
Additional paid-in capital
(450,000)
(60,000)
S
60,000
(450,00.
Operating Systems Structure1- Explain briefly why the objectives o.pdfrishabjain5053
Operating Systems Structure
1- Explain briefly why the objectives of a purely batch multiprogramming operating system
conflict with those of an interactive system.
2- What features from the Mainframe operating system Multics do we see in modern operating
systems?
Solution
Answer 2..
The various features of Multics are :
-Segmented memory
-Virtual memory
-High-level language implementation
-Shared memory multiprocessor
-Multi-language support
-Relational database
-Security
-On-line reconfiguration
-Software engineering
Out of the above features, the feature that are present in modern operating system are:
1) security
Each user has to be authenticated with an username and password (network and multi-user
operating system).
Their data and files will be kept private from other users, unless they choose to make some
shareable with others.
The operating system will only allow administrators (\'super users\') to change parts of the
operating system and install applications.
2)Segmented memory
To use shared memory, we have to perform 2 basic steps:
Request to the operating system a memory segment that can be shared between processes. The
user can create/destroy/open this memory
using a shared memory object: An object that represents memory that can be mapped
concurrently into the address space of more than one process..
Associate a part of that memory or the whole memory with the address space of the calling
process. The operating system looks for
a big enough memory address range in the calling process\' address space and marks that
address range as an special range. Changes in that address
range are automatically seen by other process that also have mapped the same shared memory
object.
3)Virtual memory
Virtual memory is a memory management capability of an OS that uses hardware and software
to allow a computer to compensate for physical memory
shortages by temporarily transferring data from random access memory (RAM) to disk storage.
Virtual address space is increased using active memory
in RAM and inactive memory in hard disk drives (HDDs) to form contiguous addresses that
hold both the application and its data.
4)Shared memory multiprocessor
Shared memory is the fastest interprocess communication mechanism. The operating system
maps a memory segment in
the address space of several processes, so that several processes can read and write in that
memory segment without
calling operating system functions. However, we need some kind of synchronization between
processes that read and write shared memory.
Consider what happens when a server process wants to send an HTML file to a client process
that resides in the same machine using network mechanisms:
The server must read the file to memory and pass it to the network functions, that copy that
memory to the OS\'s internal memory.
The client uses the network functions to copy the data from the OS\'s internal memory to its own
memory.
As we can see, there are two copies, one from memory to the network an.
Need help with this java code. fill in lines where needed. Also, not.pdfrishabjain5053
Need help with this java code. fill in lines where needed. Also, not sure how to make the text
files and load them into program. Thanks!!
Create a package named \"reading_with_exceptions\". Write a class named:
Reading_With_Exceptions with the following method:
void process(String inputFilename)
Your program will encounter errors, and we want you to gracefully handle them in such a way
that you print out informative information and continue executing.
Your process routine will try to open a file with the name of inputFilename for input. If there is
any problem (i.e. the file doesn\'t exist), then you should catch the exception, give an appropriate
error and then return. Otherwise, your program reads the file for instructions.
Your process routine will read the first line of the file looking for an outputFilename String
followed by an integer. i.e.:
outputFilename number_to_read
Your program will want to write output to a file having the name outputFilename. Your program
will try to read from \"inputFilename\" the number of integers found in \"number_to_read\".
Your process method will copy the integers read from inputFilename and write them to your
output file(i.e. outputFilename). There should contain 10 numbers per line of output in your
output file.
If you encounter bad input, your program should not die with an exception. For example:
If the count of the numbers to be read is bad or < 0 you will print out a complaint message and
then read as many integers as you find.
If any of the other numbers are bad, print a complaint message and skip over the data
If you don\'t have enough input numbers, complain but do not abort
After you have processed inputFilename, I would like your program to then close the output file
and tell the user that the file is created. Then Open up the output file and copy it to the Screen.
For example, if inputFilename contained:
We would expect the output of your program to be (Note that after 23 numbers we stop printing
numbers):
The main program will access the command line to obtain the list of filenames to call your
process routine with.
For those of you who benefit from a Template, your program might look like:
To prove that your program works, I want you to run your program with the following command
line parameters:
file1.txt non-existent-file file2.txt file3.txt
Where non-existent-file does not exist.
file1.txt contains:
file2.txt contains:
file3.txt contains:
Solution
// Reading_With_Exceptions.java
import java.io.File; // required imports for the code
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Scanner;
public class Reading_With_Exceptions
{ // class that runs the code
// 1.) Create a Scanner from the inputFilename. Catch exceptions from errors.
// 2.) Read the first String from the file and use it to create a PrintStream
// catching appropriate exceptions
// 3.) Using hasNextInt and nextInt, carefully re.
IP has no mechanism for error reporting or error-correcting. ICMPv4 .pdfrishabjain5053
IP has no mechanism for error reporting or error-correcting. ICMPv4 was created to overcome
this.
a) What is ICMPv4?
b) How do we use ICMPv4 with the TCP/IP Suite?
c) How does it overcome the limitations in IP?
Solution
What is ICMP?
ICMP stands for Internet Control Message Protocol. It is an error reporting protocol network
device like routers used to generate error messages to the source IP addresses when network
problem prevent delivery of IP Packets. ICMP creates and sends messages to the source IP
address indicating that a gateway to the router, host and service cannot be reached for packet
delivery. Any Network IP device has the capability to send, receive or process ICMP messages.
How do we use ICMPv4 with the TCP/IP Suite?
Various message types are defined in ICMP that allow different types of information to be
exchanged. These are usually either generated for the purpose of reporting errors, or for
exchanging important information of different sorts that is needed to keep IP operating smoothly.
ICMP itself doesn\'t define how all the different ICMP messages are used; this is done by the
protocols that use the messages. In this manner, ICMP describes a simple message-passing
service to other protocols.
ICMP is not like most other TCP/IP protocols in that it does not perform a specific task. It
defines a mechanism by which various control messages can be transmitted and received to
implement a variety of functions.
ICMP is considered an integral part of IP, even though it uses IP to sends its messages. The
operation of ICMP involves some portion of the TCP/IP protocol software on a machine
detecting a condition that causes it to generate an ICMP message. This is often the IP layer itself,
though it may be some other part of the software. The message is then encapsulated and
transmitted like any other TCP/IP message, and is given no special treatment compared to other
IP datagrams. The message is sent over the internetwork to the IP layer at the receiving device.
Again, since many of the ICMP messages are actually intended to convey information to a
device\'s IP software, the IP layer itself may be the “ultimate destination” of an ICMP message
once a recipient gets it. In other cases, the ultimate destination may be some other part of the
TCP/IP protocol software, which is determined by the type of message received. ICMP does not
use ports like UDP or TCP to direct its messages to different applications on a host; the software
recognizes the message type and directs it accordingly within the software
How does it overcome the limitation in IP?
IP is an unreliable method for the delivery of network data. It is known as a best effort delivery
mechanism. It has no built-in process to ensure that data is delivered.
If an intermediary device such as a router fails, data cannot be delivered. Additionally, nothing in
its basic design allows IP to notify the sender that a data transmission has failed. ICMP is the
component of the TCP/IP protocol.
Informed Consent is a significant requirement for all provider types.pdfrishabjain5053
Informed Consent is a significant requirement for all provider types. How does a health entity
need to ensure that all staff have an understanding of the aspects of informed consent?
Solution
Informal consent refers to the processnof getting permission before doing any sort of healthcare
intervention or trial.the consent plays very vital role in all sort of research or test using a
particular person. Thus it can be a legal.offense is any test or research conducted without taking
any informal consent from the patient. Healthcare industry to be on their business ethics side
should communicate all.the employees about the importance of having informal consent from the
patients.The proper consent will avoind further complication or any sort of conflicts. Incase if the
patient hasn\'t provided prowpr informal consent or in partial it can be assessed by review
committee or institutional review board..
In the MVC Architecture, why is it important to keep the model, view.pdfrishabjain5053
In the MVC Architecture, why is it important to keep the model, view, and controller
independent of each other?
Solution
In the MVC Architecture, it is important to keep the model, view, and controller independent of
each other.
Because...
In view layer, programmers will prepare user interface for collecting different types of inputs.
Then user interface program is responsible for storing all values as a single group should send to
the controller application. Then for storing multiple values as one group user interface
application internally should use either array or collection object.
The controller layer receives all values as a single object using array or collection reads input
values from the array or collection object perform calculations and generate results then input
and output values will send to the model application.
The model layer will receive array or collection object reads all input and output values stores in
the database..
in roughly 400 words please describe3 affective outcomes of diver.pdfrishabjain5053
in roughly 400 words please describe:
3 affective outcomes of diversity and 3 cognitive outcomes of diversity.
refer to ... Working in teams: moving from high potential to high performance.. BA Griffith and
EB Dunham.. Ch.7
Solution
if a firm is operating with cross culturals work force, it can be called as diverified team, which
may include the members from various backgrounds, nations, with different cultures, education
qualifications, religious and other aspects too. when people works with others, there is a great
chance to upgrade their knowledge levels by interacting with others, they can explore to new
techniques, and so on.
when people work in teams, they discuss, interact, and expose their talent. others may extract
those and the acceptable practices are followed by others. the effective outcomes of diversity are
as follows:
1. people have habituated to openness and share everthing with others
2. they trust each other and exchange what they have and what others need, similarly seek helps
from others in the limitations
3. it encourages team spirity, where all the people works on focused tasks.
4. stands with each other in the times of difficulties and in the times of success also.
the cognitive outcomes of diversity:
1. during the times of problems and difficulties, all these members tries to recollect the prior
experience related to this.
2. if there are any relevant experiences to this, they share with others, and drwn an acceptable
solution to the present problem.
3. when people works and thinks to get a solution while they are in teams, the success of getting
a correct solution is more..
Im having issues with two homework questions. I get the gist of th.pdfrishabjain5053
I\'m having issues with two homework questions. I get the gist of the mechanisms involved with
transcription and translation, but the question itself is really throwing me off.
4. What kinds of mutations might result in transcriptional errors? What kinds of mutations might
result in translational errors?
What I\'m thinking for this one is that transcriptional errors are having to do with radiation-type
mutations as well as incidences where the RNA polymerase or other polymerases make a
mistake when creating that RNA template and the mistake does not get fixed. As far as the
translational side, I\'m kind of clueless. Part of this homework is in the realm of CFTR and the
delF508 gene and the W1282X gene, as well as nonsense and missense mutations. I do not know
where they fall into this stuff.
6. Which part of the central dogma is represented by CFTRdel508 and by W1282X? Where is
the information flow interrupted (transcription or translation)? Justify your answer.
Again, I get the gist, but not really how these actually fit into the question. I BELIEVE the
answer to be that the problem / informational flow interruption occurs during translation, but I\'m
not sure that\'s correct, nor can I justify it. THANKS FOR THE HELP! :)
Solution
4. Mutation like point mutations, framshift mutations, chromosomal disjunction etc causes
incorrect base pairing at the DNA level, hence the RNA polymerase incorporates incorrect
nucleotides and thereby creating incorrect mRNA sequences. Also, any mutations in RNA
polymerase, and other transcriptional factors lead to transxccriptional errors
Similarly the mRNA is incorrect then the ribosome and the tRNA also incorporates incorrect
amino acids thereby forming a defective protein which leads to translational errors. Also, any
mutation of the tRNA/ ribosome\'s sub units (50 S and 30 S) can also lead to translational errors
thereby leading to a defective protein.
6. DNA ----> RNA ----> Protein
The deletions inthe 2 genes fall in the DNA to RNA part of central dogma.
Any mutations of the CFTRdel508 and W1282X gene causes the protein folding to be disrupted.
The protein in question for these 2 genes is Cystic Fibrosis transmembrane conductance
regulator (CFTR). Since the protein is unable to fold properly (the missense mutation in
CFTRdel508 causing the Phenylalanine not to get coded) hence the protein is unable to move out
of the Endoplasmic Reticulum.
Hence, the probelm is not at the translation level but mainly at the transcription level, since the
deletion had occured in the DNA which resulted in the coding of an incorrect mRNA thereby
forming a defective protein.
So the major problem is at the transcriptional level..
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
The Indian economy is classified into different sectors to simplify the analysis and understanding of economic activities. For Class 10, it's essential to grasp the sectors of the Indian economy, understand their characteristics, and recognize their importance. This guide will provide detailed notes on the Sectors of the Indian Economy Class 10, using specific long-tail keywords to enhance comprehension.
For more information, visit-www.vavaclasses.com
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
1. Implement the interface you wrote for Lab B (EntryWayListInterface). As a reminder,
EntryWayListInterface allows the user to access to list elements only through the beginning and
end of the list.
Your implementation can use either an expandable array or linked nodes- it is your choice. You
can decide what instance variables are needed. You must implement every method from the
interface. Make sure to account for special conditions such as empty lists and singleton lists.
Note: your instance data variable should be either a) an array or b) one or more nodes. It should
not be an AList or LList object or an ArrayList object.
Your implementation must:
compile
contain these implemented methods:
insertHead
insertTail
deleteHead
deleteTail
display
contains
isEmpty
isFull
Also create a driver program to test your implementation. The driver program will operate from
the client perspective. Your driver program should:
display an empty list
add five entries to the list- some at the head and some at the tail
display the list
remove the first entry
remove the last entry
display the list
test to see if elements are in the list (test one element that is in the list and one that is not)
remove the last three elements in the list
try to remove an element from the empty list
Write a second class to implement EntryWayListInterface. Instead of using an array or linked
nodes, use either an AList or LList object as your instance data variable. In this way, you are
using an existing data type (AList or LList) to implement a new data type
(EntryWayListInterface). Inside the methods of this class, invoke methods on the AList or LList
object to accomplish the task.
2. /** An interface for the ADT list.
Entries in a list have positions that begin with 1.
* Accesses only entries that are the head or tail of the list.
*/
public interface EntryWayInterface {
/** Adds a new entry to this list T.
* @param newEntry The object to be added as a new entry.
* @return True if the addition is successful, or false if not. */
public boolean insertHead(T newEntry);
/** Deletes a new entry to this list T.
* @param newEntry The object to be added as a new entry.
* @return True if the addition is successful, or false if not. */
public boolean insertTail(T newEntry);
/** Deletes the object that is at the head of list T.
* @return the object that has been deleted and returns
* null if no object was deleted.
*/
public T deleteHead();
/** Deletes the object that is at the tail of list T.
* @return the object that has been deleted or else return null
* if no object was deleted.
*/
public T deleteTail();
/** Displays the contents of the list T.
*/
public void display();
/** See whether this list T contains a given entry.
* @param anEntry The object that is the desired entry.
* @return the position of the entry that was found.
* else returns false if the object is not in the list.
*/
public int contains(T anEntry);
/** Sees whether this list is empty.
* @return True if the list is empty, or false if not. */
public boolean isEmpty();
3. /** Sees whether this list is full.
* @return True if the list is full, or false if not. */
public boolean isFull();
}//end EntryWayInterface
Solution
public class LEntryWayList implements EntryWayListInterface {
private Node firstNode;
private Node lastNode;
private int length;
public LEntryWayList() {
clear();
}
public final void clear() {
firstNode = null;
lastNode = null;
length = 0;
}
/**
* Task: Places a new object at beginning of list
*
* @param newEntry is a valid object
* @return true if insert is successful; false otherwise
*/
public boolean insertHead(T newEntry) {
Node newNode = new Node(newEntry);
if (isEmpty()) {
firstNode = newNode;
lastNode = newNode;
} else {
newNode.next = firstNode;
firstNode = newNode;
}
length++;
4. return true;
}
/**
* Task: Places a new object at the end of the list
*
* @param newEntry is a valid object
* @return true if insertion successful; false otherwise
*/
public boolean insertTail(T newEntry) {
Node newNode = new Node(newEntry);
if (isEmpty()) {
firstNode = newNode;
} else {
lastNode.next = newNode;
}
lastNode = newNode;
length++;
return true;
}
/**
* Task: delete the object at the beginning of the list
*
* @return the object that has been deleted
*/
public T deleteHead() {
T result = null;
if (length >= 1) {
assert !isEmpty();
if (length == 1) {
result = firstNode.data;
firstNode = null;
lastNode = null;
} else {
result = firstNode.data;
firstNode = firstNode.next;
}
5. length--;
}
return result;
}
/**
* Task: delete the object at the end of the list
*
* @return the object that has been deleted, or null if the list was empty
*/
public T deleteTail() {
T result = null;
if (length >= 1) {
assert !isEmpty();
if (length == 1) {
result = firstNode.data;
firstNode = null;
lastNode = null;
} else {
Node nodeBefore = getNodeAt(length - 1);
Node nodeToRemove = nodeBefore.next;
nodeBefore.next = null;
result = nodeToRemove.data;
lastNode = nodeBefore;
}
length--;
}
return result;
}
/**
* Task: display the contents of the list on the console, in order, one per
* line
*/
public void display() {
Node currentNode = firstNode;
while (currentNode != null) {
System.out.println(currentNode.getData());
6. currentNode = currentNode.getNext();
}
}
/**
* Task: search the list for the given object and return its position in the
* list, or -1 if it's not found
*
* @param anEntry is a valid object to find in the list
* @return the position of the entry that was found, or -1 if it's not found
*/
public int contains(T anEntry) {
int found = 0;
Node currentNode = firstNode;
while (currentNode != null) {
found++;
if (anEntry.equals(currentNode.getData())) {
return found;
} else {
currentNode = currentNode.getNext();
}
}
return -1;
}
/**
* Task: check to see if list is empty
*
* @return true if list is empty, false if list contains one or more
* objects.
*/
public boolean isEmpty() {
boolean result;
if (length == 0) {
assert firstNode == null;
result = true;
} else {
assert firstNode != null;
7. result = false;
}
return result;
}
/**
* Task: check if list is full
*
* @return true if list is full, false if list has space for more objects
*/
public boolean isFull() {
return false; // Linked lists always return false
}
private Node getNodeAt(int givenPosition) {
assert !isEmpty()
&& ((1 <= givenPosition) && (givenPosition <= length));
Node currentNode = firstNode;
for (int counter = 1; counter < givenPosition; counter++) {
currentNode = currentNode.getNext();
}
assert currentNode != null;
return currentNode;
}
private class Node {
private T data;
private Node next;
private Node(T dataPortion) {
data = dataPortion;
next = null;
}
private Node(T dataPortion, Node nextNode) {
data = dataPortion;
next = nextNode;
}
public T getData() {
return data;
}
8. public void setData(T data) {
this.data = data;
}
public Node getNext() {
return next;
}
public void setNext(Node next) {
this.next = next;
}
}
public static void main(String []args){
LEntryWayList l = new LEntryWayList();
l.display();
}
}