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).
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.
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 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 *.
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.
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.
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.
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.
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;
...
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.
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 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 *.
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.
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.
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.
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.
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 =.
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdfrishabjain5053
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.
/** 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.
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){
}
.
week4_src/ArrayMethods.javaweek4_src/ArrayMethods.javapackage edu.drexel.ct290;
publicclassArrayMethods{
/**
* Pass and array to a method that will search through it for a given value.
*
* @param elementToFind: This is the item we want to find in the array.
* @param stringArray: This is the array to search through.
* @return Returns: The index of the element, or -1 if not found.
*/
publicint findElement(String elementToFind,String[] stringArray ){
int index =-1;
for(int i=0; i<stringArray.length; i++){
if( elementToFind.equals(stringArray[i])){
// If the element is found, set index
index = i;
}
}
return index;
}
/**
* Replace a value in an array.
*
* @param indexToReplace: The index where the new value should be written.
* @param newValue: The new value.
* @param stringArray: Change a value in this array.
* @return True if the given index is valid
*/
publicboolean replace(int indexToReplace,String newValue,String[] stringArray ){
boolean replaced =false;
// Use the if condition to make sure the given index is valid
if( indexToReplace >0&& indexToReplace < stringArray.length ){
stringArray[indexToReplace]= newValue;
replaced =true;
}
return replaced;
}
/**
* Insert a value into the array. From the insertion point on, the
* data needs to be copied down one space to make room for the new
* element indices .
*
* @param index: The index where the new element should be inserted
* @param element: The element to insert in the array
* @param array: The array to insert into
* @param indicesUsed: the number of elements in the array already used
* @return the array with the new value inserted
*/
publicString[] insert(int index,String element,String[] array,int indicesUsed){
// First, check that there is enough room in the array for
// another element. The parameter indicesUsed indicates how
// many elements of the array are already filled.
String[] newArray = array;
if( indicesUsed == array.length ){
newArray = makeBiggerArray(array);
}
// Now that we know there is enough room, move the
// elements down one spot in the array until we get to the
// insertion point. Make sure the element at the insertion
// point gets moved too.
int indexToMove = indicesUsed;
while( indexToMove >= index ){
newArray[indexToMove+1]= newArray[indexToMove];
indexToMove--;
}
// Set the given index to the new element
newArray[index]= element;
// Return the new array
return newArray;
}
/**
* Since arrays are fixed size, if you run out of room, the
* only options is to create a new bigger array, then copy
* the old data over.
* @param oldArray: The old data to copy into the new array
* @return The new bigger array
*/
publicString[] makeBiggerArray(String[] oldArray){
// Make the new array twice the size of the old one.
int newArraySize .
Everything needs to be according to the instructions- thank you! SUPPO.pdffirstchoiceajmer
Everything needs to be according to the instructions, thank you!
SUPPORTING CODE:
MyList.java
/**
This interface specifies the basic operations of any list-like object.
This interface contains a variation of the methods of the
standard java.util.List interface.
*/
public interface MyList {
/**
Adds an element at the end of the list.
*/
public void addToEnd(Object o);
/**
Inserts an element at the specified index
Throws NoSuchElementException if index is out of bounds.
*/
public void insertAt(int index, Object o);
/**
Removes the element at the specified index
Throws NoSuchElementException if index is out of bounds.
*/
public void removeAt(int index);
/**
Returns the element at the specified index
Throws NoSuchElementException if index is out of bounds.
*/
public Object getAt(int index);
/**
Returns the size of the list.
@return the number of elements in the list
*/
public int getSize();
/**
Returns a list iterator for this list.
@return a list iterator for this list
*/
public MyListIterator getIterator();
}
MyListIterator.java
/**
A list iterator allows access of a position in a list.
This interface contains a subset of the methods of the
standard java.util.ListIterator interface. The methods for
backward traversal are not included.
*/
public interface MyListIterator
{
/**
Moves the iterator past the next element.
@return the traversed element
*/
Object next();
/**
Tests if there is an element after the iterator
position.
@return true if there is an element after the iterator
position
*/
boolean hasNext();
}
Main.java
// you may use this file to write and run code to test your MyArrayList class
public class Main {
public static void main(String[] args) {
}
}
FILE THAT NEEDS THAT NEEDS CODE:
MyArrayList.java
// Complete the implementation of your MyArrayList class in this file
public class MyArrayList implements MyList {
// Implement the required fields and methods here
private int capacity = 8;
private Object[ ] array = new Object [capacity];
private int size = 0;
@Override
public void add(Object o) {
if (size >= capacity){
Object[] temp = new Object[2*array.length];
for(int i=0;i<size;++i){
temp[i] = array[i];
}
this.capacity = 2*array.length;
array = temp;
array[size++] = o;
return;
}
else
{
array[size++] = o;
}
}
@Override
public int size() {
return size;
}
@Override
public Object at(int index) {
if (index >= capacity)
return null;
else
return array[index];
}
@Override
public void insertAt(int index, Object o) {
if (index >= capacity)
return;
else
{
size++;
for (int x = size - 1; x > index; x--) {
array[x] = array[x - 1];
}
array[index] = o;
}
}
@Override
public void removeAt(int index) {
if (index >= size || size == 0)
return;
else {
Object e = array[index];
for (int x = index; x < this.array.length - 1; x++) {
array[x] = array[x + 1];
}
size--;
}
}
public void ensureCapacity(int minCapacity) {
}
public void trimToSize() {
ensureCapacity(size);
}
// Do not alter the code below
@Override
public MyListIterator getIterator() {
return new MyA.
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.
In this homework- you will write a program modify program you wrote in.pdfEvanpZjSandersony
In this homework, you will write a program modify program you wrote in Homework3.
2) Modify the MyList class that you wrote for Programming challenge 1 so the type parameter T
should accept any type that implements the Comparable interface. Test the class in a program
that creates one instance of MyList to store Integers, and another instance to store Strings. Input
two numbers from the user and insert them into the first instance of Modified MyList.
Input name and City and insert the two strings into the second instance of modified MyList class.
Then display the contents of the the two instances.
here is the program to modify
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// part 1 code.
// creating a Number list
MyList<Number> intList = new MyList<>();
// adding the numbers mentioned in the question
intList.add(2);
intList.add(5);
intList.add(-13);
intList.add(11);
intList.add(12);
// creating a Double list, adding double values to it
MyList<Double> doubleList = new MyList<>();
doubleList.add(27.3);
doubleList.add(5.7);
doubleList.add(-23.9);
doubleList.add(1.11);
doubleList.add(5.12);
System.out.println("PART 1");
// printing largest and smallest of both lists
System.out.println("The Integer largest: \n" + intList.largest());
System.out.println("The Integer smallest: \n" + intList.smallest());
System.out.println("The Double largest: \n" + doubleList.largest());
System.out.println("The Double smallest: \n" + doubleList.smallest());
}
}
//MyList class, which is defined outside Generics1 class BUT still within Generics1.java file.
class MyList<T extends Number> {
// defining an array list as storage
ArrayList<T> list;
// constructor initializing list
public MyList() {
// initializing array list
list = new ArrayList<>();
}
// method to add a value to the list
public void add(T value) {
list.add(value);
}
// method to return the largest element on the list
public T largest() {
// assuming list is not empty, taking first value as largest
T max = list.get(0);
for (int i = 1; i < list.size(); i++) {
// comparing element at i with max using doubleValue() of Number class
if (list.get(i).doubleValue() > max.doubleValue()) {
max = list.get(i);
}
}
return max;
}
// method to return the smallest element on the list
public T smallest() {
// assuming list is not empty, taking first value as smallest
T min = list.get(0);
for (int i = 1; i < list.size(); i++) {
// comparing element at i with min using doubleValue() of Number class
if (list.get(i).doubleValue() < min.doubleValue()) {
min = list.get(i);
}
}
return min;
}
// returns the elemnt at a given position
public T get(int index) {
return list.get(index);
}
}
Here is the sample input/outPut
TestCase1:
PART 2
Please enter a number:
30
Please another number:
20
Please enter your name:
John
Please enter your City:
Los Angeles
First number is 30
Second number is 20
Name is: John
City is: Los Angeles
TestCase2:
PART 2
Please enter a number:
.
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.
1 The goal is to implement DataStructuresArrayStack accor.pdfsaradashata
(1) The goal is to implement DataStructures.ArrayStack according to the interface ADTs.StackADT
********************************************
package DataStructures;
import ADTs.StackADT;
import Exceptions.EmptyCollectionException;
import Exceptions.StackOverflowException;
public class ArrayStack<T> implements StackADT<T> {
/** The index of where the top of the stack is */
int top;
/** The array that holds the stack */
T[] buffer;
public ArrayStack() {
}
public ArrayStack(int initialCapacity) {
}
}
*******************************************************
package ADTs;
import Exceptions.EmptyCollectionException;
import Exceptions.StackOverflowException;
/**
* An interface for a Stack
* Specific stack implementations will implement this interface
* For use Data Structures & Algorithms
*
*
* author unknown
*/
public interface StackADT<T> extends CollectionADT<T> {
/**
* Adds the specified element to the top of the stack
*
* @param element element to be pushed onto the stack
*/
public void push(T element) throws StackOverflowException;
/**
* Removes and returns the element that is on top of the stack
*
* @return the element removed from the stack
* @throws EmptyCollectionException
*/
public T pop() throws EmptyCollectionException;
/**
* Returns (without removing) the element that is on top of the stack
*
* @return the element on top of the stack
* @throws EmptyCollectionException
*/
public T peek() throws EmptyCollectionException;
}
*****************************************
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 unknown
*/
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 (wit.
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.
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] .
BackgroundIn many applications, the composition of a collection o.pdfmayorothenguyenhob69
Background:
In many applications, the composition of a collection of data items changes over time. Not only
are new data items added and existing ones removed, but data items may be duplicated. A list
data structure is a member of the general category of abstract data types called containers, whose
purpose is to hold other objects. In C++, lists are provided in the Standard Template Library.
However, for this assignment you will design and write your own linked list implementation to
support the ADT operations specified below.
Objective:
Design and implement the specifications for a List Abstract Data Type where the items in the list
are unsorted.
Requirements:
Define a list and develop a set of operations for creating and manipulating a list that satisfies the
list ADT specification.
List ADT Specification
Structure: The list elements are of ItemType. The list has a property called the current position
which designates the position of the last element accessed by GetNextItem during an iteration
through the list. Only ResetList and GetNextItem alter the current position.
Definitions (provided by the user):
MAX_ITEMS: A constant specifying the maximum capacity of items allowed on the list
Item Type: Class encapsulating the type of items in the list
RelationType: An enumeration type that consists of LESS, GREATER, EQUAL
Member function of ItemType that must be included:
RelationType ComparedTo(ItemType Item)
Function: Determines the ordering of two ItemType objects based on their keys
Precondition: Self and item have their key members initialized
Postcondition:
Function value = LESS if the key of self is less than the key of item
= GREATER if the key of self is greater than the key of item
= EQUAL if the keys are equal
Operations (provided by Unsorted List ADT)
Make Empty
Function: Initializes list to empty state
Preconditions: None
Postcondition: List is empty
Boolean IsFull
Function: Determines whether list is full
Preconditions: List has been initialized
Postcondition: Function value = (list is full)
int GetLength
Function: Determines the number of elements in list
Preconditions: List has been initialized
Postcondition: Function value = number of elements in list
ItemType GetItem(Item Typeitem, Boolean& found)
Function: Get list element whose key matches item’s key (if present)
Preconditions: List has been initialized
Key member of item is initialized
Postcondition: If there is an element someItem whose keymatches item’s key, then found =
true and copy of someItemis returned; otherwise found = false and item is returned
List is unchanged
PutItem(ItemType item)
Function: Puts item into list
Preconditions: List has been initialized
List is not full
Item is not in list
Postcondition: Item is in the list
DeleteItem(ItemType item)
Function: Deletes the element whose key matches item’s key
Preconditions: List has been initialized
Postcondition: One and only one element in list has a key matching item’s key
ResetList
Function: Initializes current p.
we using java code DynamicArrayjava Replace all .pdfgudduraza28
we using java code /** * DynamicArray.java * * Replace all //TODO tags with your code * * Note
that below the "//TODO" tag there may be * something like "return null;", "return 0;", etc. * That line
is just "stubbed in" so the class * will compile. When you add your code (one or many *
statements), you will want to delete the "stubbed" line. * By "stubbed in" we mean "mocked" or
"faked in" temporarily. * * When testing, construct using the static factory methods:
DynamicList.newEmpty() DynamicList.fromGrowthFactor(growthFactor)
DynamicList.from(arrayElements) */ package model.list; import java.lang.reflect.Array; import
java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiFunction; import
java.util.function.Consumer; import java.util.function.Function; import
model.linearpub.DynamicList; import model.linearpub.StructureIterator; public class
DynamicArray<E> implements DynamicList<E> { //--------------------------------- // Instance Variables
//TODO - declare instance variable(s) //--------------------------------- // Private Constructors /**
Constructs and returns new DynamicArray (no args constructor) */ private DynamicArray() {
this(defaultGrowthFactor()); } /** Constructs and returns new DynamicArray with "aGrowthFactor"
*/ private DynamicArray(double aGrowthFactor) { //TODO -- this is the constructor that should
//initialize the dynamic array as needed } //------------------------------------------------ public static double
defaultGrowthFactor() { //TODO - replace 0 with a good growth factor return 0; } protected static int
defaultInitialCapacity() { //TODO - replace 0 with a good initial capacity return 0; } //--------------------
List Statistics --------------------- /** * Return number of elements in this list. */ @Override public int
size() { //TODO return 0; } /** * Return true is this list contains no elements. */ @Override public
boolean isEmpty() { //TODO return false; } //------------------ Accessing Elements -------------------- /**
* Return element at given index. * Throws IndexOutOfBoundsException if passed index is invalid.
*/ @Override public E get(int index) { //TODO return null; } /** * Return first element * Throws
RuntimeException if list is empty */ @Override public E first() { //TODO return null; } /** * Return
last element * Throws RuntimeException if list is empty */ @Override public E last() { //TODO
return null; } /** * Return a new list containing the elements of this list * between the given index
"start" (inclusive) and * the given index "stop" (exclusive). * Throws IndexOutOfBoundsException if
either passed index is invalid. */ @Override public DynamicList<E> subList(int start, int stop) {
//TODO return null; } /** * Return index of first matching element (where searchFct outputs true) *
Return -1 if no match * Example usage (first list of integers, then employees): * index =
list.find(eaInteger -> eaInteger == 10); * index = employeeList.find(employee -> employee
.getFirstName().equals("Kofi.
Engineering lecture ppt by venay magenvenaymagen19
Venay Magen likes the shading red, particularly on Tuesdays. He cherishes to drink bourbon (on all days). He figured out how to drink whisky from his youth companion Zippo, when they went to class together at Mount Temple Comprehensive School. He is best known as the lead vocalist for the band MN3.
import java.util.ArrayList; import java.util.List;public class S.pdfanupamele
import java.util.ArrayList;
import java.util.List;
public class SearchList {
/**
* param args
*/
public static void main(String[] args) {
List list = new ArrayList();
list.add(3);
list.add(3);
list.add(1);
System.out.println(\"Search element 3 in list [3,3,1] :\"
+ search(list, 3));
System.out.println(\"Search element 5 in list [3,3,1] :\"
+ search(list, 5));
}
/**
* method to find the index of element in the list
* param list
* param element
* return
*/
public static int search(List list, Object element) {
int index = -1;
if (list == null || element == null)
throw new NullPointerException();
else {
int searchElement = (int) element;
for (int i = 0; i < list.size(); i++) {
int number = (int) list.get(i);
if (number == searchElement) {
index = i;
}
}
}
return index;
}
}
OUTPUT:
Search element 3 in list [3,3,1] :1
Search element 5 in list [3,3,1] :-1
Solution
import java.util.ArrayList;
import java.util.List;
public class SearchList {
/**
* param args
*/
public static void main(String[] args) {
List list = new ArrayList();
list.add(3);
list.add(3);
list.add(1);
System.out.println(\"Search element 3 in list [3,3,1] :\"
+ search(list, 3));
System.out.println(\"Search element 5 in list [3,3,1] :\"
+ search(list, 5));
}
/**
* method to find the index of element in the list
* param list
* param element
* return
*/
public static int search(List list, Object element) {
int index = -1;
if (list == null || element == null)
throw new NullPointerException();
else {
int searchElement = (int) element;
for (int i = 0; i < list.size(); i++) {
int number = (int) list.get(i);
if (number == searchElement) {
index = i;
}
}
}
return index;
}
}
OUTPUT:
Search element 3 in list [3,3,1] :1
Search element 5 in list [3,3,1] :-1.
please read the steps below and it will tell you what we usi.pdfaggarwalopticalsco
please read the steps below and it will tell you what we using
/**
* DynamicArray.java
*
* Replace all //TODO tags with your code
*
* Note that below the "//TODO" tag there may be
* something like "return null;", "return 0;", etc.
* That line is just "stubbed in" so the class
* will compile. When you add your code (one or many
* statements), you will want to delete the "stubbed" line.
* By "stubbed in" we mean "mocked" or "faked in" temporarily.
*
* When testing, construct using the static factory methods:
DynamicList.newEmpty()
DynamicList.fromGrowthFactor(growthFactor)
DynamicList.from(arrayElements)
*/
package model.list;
import java.lang.reflect.Array;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import model.linearpub.DynamicList;
import model.linearpub.StructureIterator;
public class DynamicArray<E> implements DynamicList<E> {
//---------------------------------
// Instance Variables
//TODO - declare instance variable(s)
//---------------------------------
// Private Constructors
/** Constructs and returns new DynamicArray (no args constructor) */
private DynamicArray() {
this(defaultGrowthFactor());
}
/** Constructs and returns new DynamicArray with "aGrowthFactor" */
private DynamicArray(double aGrowthFactor) {
//TODO -- this is the constructor that should
//initialize the dynamic array as needed
}
//------------------------------------------------
public static double defaultGrowthFactor() {
//TODO - replace 0 with a good growth factor
return 0;
}
protected static int defaultInitialCapacity() {
//TODO - replace 0 with a good initial capacity
return 0;
}
//-------------------- List Statistics ---------------------
/**
* Return number of elements in this list.
*/
@Override
public int size() {
//TODO
return 0;
}
/**
* Return true is this list contains no elements.
*/
@Override
public boolean isEmpty() {
//TODO
return false;
}
//------------------ Accessing Elements --------------------
/**
* Return element at given index.
* Throws IndexOutOfBoundsException if passed index is invalid.
*/
@Override
public E get(int index) {
//TODO
return null;
}
/**
* Return first element
* Throws RuntimeException if list is empty
*/
@Override
public E first() {
//TODO
return null;
}
/**
* Return last element
* Throws RuntimeException if list is empty
*/
@Override
public E last() {
//TODO
return null;
}
/**
* Return a new list containing the elements of this list
* between the given index "start" (inclusive) and
* the given index "stop" (exclusive).
* Throws IndexOutOfBoundsException if either passed index is invalid.
*/
@Override
public DynamicList<E> subList(int start, int stop) {
//TODO
return null;
}
/**
* Return index of first matching element (where searchFct outputs true)
* Return -1 if no match
* Example usage (first list of integers, then employees):
* index = list.find(eaInteger -> eaInteger == 10);
* index = employeeList.find(emplo.
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<.
Discuss the character and impact of the economic and legal revouluti.pdffashiongallery1
Discuss the character and impact of the economic and legal revoulutions on the American
economy between 1815 and 1840. Did this market revolution have to be so antagonistic toward
laborers? Explain your answer.
Solution
Market revolution refers to the changes in market structure from local to national markets.
Revolution impacted highly in agricultural sector. It has changed agricultural sector positively.
Textile and manufacturing industries drastically boom and strengthened the economy. Roadways
and canal system expanded, coin was made from precious metal, and there was huge financial
growth. During market revolution Americans began to experience the forces of supply and
demand. Transportation network highly changed during revolution and play a vital role in
commerce and new market.
Due to revolution there was drastic changes occurred in manual labor process. It has changed the
schedules, wages and working environment for laborers. Artisanal trades started to give way to
best efficient system of production, instead of using skilled labor and thus skilled labor were not
required for the production. There was no job security and laborer was paid low wages..
Discrete Math -Use induction to prove. The city of Inductionapolis.pdffashiongallery1
Discrete Math -
Use induction to prove. The city of Inductionapolis has multiple police districts. Any two
districts are connected by a one-way street. Show that there is a route that passes through every
district of the city.
Solution
Base case: 2 districts
Since there are one-way streets between any two districts. So there is a route passing through the
two districts
Hence base case is true
Inductive hypothesis: Assume it is true for some n number of districts, n>=2
Inductive step: We show it is true for n+1
COnsider any arbitrary district , say, D
Remaining n district have a route,R, passing through them because of inductive hypothesis
So, the C be a district which is the end point . Since there is a one way street from C to D call it ,
S
So the route, R+S is the route passing through all n+1 districst
Hence true for n+1
And hence for all n>=2.
More Related Content
Similar to For this lab you will complete the class MyArrayList by implementing.pdf
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 =.
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdfrishabjain5053
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.
/** 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.
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){
}
.
week4_src/ArrayMethods.javaweek4_src/ArrayMethods.javapackage edu.drexel.ct290;
publicclassArrayMethods{
/**
* Pass and array to a method that will search through it for a given value.
*
* @param elementToFind: This is the item we want to find in the array.
* @param stringArray: This is the array to search through.
* @return Returns: The index of the element, or -1 if not found.
*/
publicint findElement(String elementToFind,String[] stringArray ){
int index =-1;
for(int i=0; i<stringArray.length; i++){
if( elementToFind.equals(stringArray[i])){
// If the element is found, set index
index = i;
}
}
return index;
}
/**
* Replace a value in an array.
*
* @param indexToReplace: The index where the new value should be written.
* @param newValue: The new value.
* @param stringArray: Change a value in this array.
* @return True if the given index is valid
*/
publicboolean replace(int indexToReplace,String newValue,String[] stringArray ){
boolean replaced =false;
// Use the if condition to make sure the given index is valid
if( indexToReplace >0&& indexToReplace < stringArray.length ){
stringArray[indexToReplace]= newValue;
replaced =true;
}
return replaced;
}
/**
* Insert a value into the array. From the insertion point on, the
* data needs to be copied down one space to make room for the new
* element indices .
*
* @param index: The index where the new element should be inserted
* @param element: The element to insert in the array
* @param array: The array to insert into
* @param indicesUsed: the number of elements in the array already used
* @return the array with the new value inserted
*/
publicString[] insert(int index,String element,String[] array,int indicesUsed){
// First, check that there is enough room in the array for
// another element. The parameter indicesUsed indicates how
// many elements of the array are already filled.
String[] newArray = array;
if( indicesUsed == array.length ){
newArray = makeBiggerArray(array);
}
// Now that we know there is enough room, move the
// elements down one spot in the array until we get to the
// insertion point. Make sure the element at the insertion
// point gets moved too.
int indexToMove = indicesUsed;
while( indexToMove >= index ){
newArray[indexToMove+1]= newArray[indexToMove];
indexToMove--;
}
// Set the given index to the new element
newArray[index]= element;
// Return the new array
return newArray;
}
/**
* Since arrays are fixed size, if you run out of room, the
* only options is to create a new bigger array, then copy
* the old data over.
* @param oldArray: The old data to copy into the new array
* @return The new bigger array
*/
publicString[] makeBiggerArray(String[] oldArray){
// Make the new array twice the size of the old one.
int newArraySize .
Everything needs to be according to the instructions- thank you! SUPPO.pdffirstchoiceajmer
Everything needs to be according to the instructions, thank you!
SUPPORTING CODE:
MyList.java
/**
This interface specifies the basic operations of any list-like object.
This interface contains a variation of the methods of the
standard java.util.List interface.
*/
public interface MyList {
/**
Adds an element at the end of the list.
*/
public void addToEnd(Object o);
/**
Inserts an element at the specified index
Throws NoSuchElementException if index is out of bounds.
*/
public void insertAt(int index, Object o);
/**
Removes the element at the specified index
Throws NoSuchElementException if index is out of bounds.
*/
public void removeAt(int index);
/**
Returns the element at the specified index
Throws NoSuchElementException if index is out of bounds.
*/
public Object getAt(int index);
/**
Returns the size of the list.
@return the number of elements in the list
*/
public int getSize();
/**
Returns a list iterator for this list.
@return a list iterator for this list
*/
public MyListIterator getIterator();
}
MyListIterator.java
/**
A list iterator allows access of a position in a list.
This interface contains a subset of the methods of the
standard java.util.ListIterator interface. The methods for
backward traversal are not included.
*/
public interface MyListIterator
{
/**
Moves the iterator past the next element.
@return the traversed element
*/
Object next();
/**
Tests if there is an element after the iterator
position.
@return true if there is an element after the iterator
position
*/
boolean hasNext();
}
Main.java
// you may use this file to write and run code to test your MyArrayList class
public class Main {
public static void main(String[] args) {
}
}
FILE THAT NEEDS THAT NEEDS CODE:
MyArrayList.java
// Complete the implementation of your MyArrayList class in this file
public class MyArrayList implements MyList {
// Implement the required fields and methods here
private int capacity = 8;
private Object[ ] array = new Object [capacity];
private int size = 0;
@Override
public void add(Object o) {
if (size >= capacity){
Object[] temp = new Object[2*array.length];
for(int i=0;i<size;++i){
temp[i] = array[i];
}
this.capacity = 2*array.length;
array = temp;
array[size++] = o;
return;
}
else
{
array[size++] = o;
}
}
@Override
public int size() {
return size;
}
@Override
public Object at(int index) {
if (index >= capacity)
return null;
else
return array[index];
}
@Override
public void insertAt(int index, Object o) {
if (index >= capacity)
return;
else
{
size++;
for (int x = size - 1; x > index; x--) {
array[x] = array[x - 1];
}
array[index] = o;
}
}
@Override
public void removeAt(int index) {
if (index >= size || size == 0)
return;
else {
Object e = array[index];
for (int x = index; x < this.array.length - 1; x++) {
array[x] = array[x + 1];
}
size--;
}
}
public void ensureCapacity(int minCapacity) {
}
public void trimToSize() {
ensureCapacity(size);
}
// Do not alter the code below
@Override
public MyListIterator getIterator() {
return new MyA.
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.
In this homework- you will write a program modify program you wrote in.pdfEvanpZjSandersony
In this homework, you will write a program modify program you wrote in Homework3.
2) Modify the MyList class that you wrote for Programming challenge 1 so the type parameter T
should accept any type that implements the Comparable interface. Test the class in a program
that creates one instance of MyList to store Integers, and another instance to store Strings. Input
two numbers from the user and insert them into the first instance of Modified MyList.
Input name and City and insert the two strings into the second instance of modified MyList class.
Then display the contents of the the two instances.
here is the program to modify
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// part 1 code.
// creating a Number list
MyList<Number> intList = new MyList<>();
// adding the numbers mentioned in the question
intList.add(2);
intList.add(5);
intList.add(-13);
intList.add(11);
intList.add(12);
// creating a Double list, adding double values to it
MyList<Double> doubleList = new MyList<>();
doubleList.add(27.3);
doubleList.add(5.7);
doubleList.add(-23.9);
doubleList.add(1.11);
doubleList.add(5.12);
System.out.println("PART 1");
// printing largest and smallest of both lists
System.out.println("The Integer largest: \n" + intList.largest());
System.out.println("The Integer smallest: \n" + intList.smallest());
System.out.println("The Double largest: \n" + doubleList.largest());
System.out.println("The Double smallest: \n" + doubleList.smallest());
}
}
//MyList class, which is defined outside Generics1 class BUT still within Generics1.java file.
class MyList<T extends Number> {
// defining an array list as storage
ArrayList<T> list;
// constructor initializing list
public MyList() {
// initializing array list
list = new ArrayList<>();
}
// method to add a value to the list
public void add(T value) {
list.add(value);
}
// method to return the largest element on the list
public T largest() {
// assuming list is not empty, taking first value as largest
T max = list.get(0);
for (int i = 1; i < list.size(); i++) {
// comparing element at i with max using doubleValue() of Number class
if (list.get(i).doubleValue() > max.doubleValue()) {
max = list.get(i);
}
}
return max;
}
// method to return the smallest element on the list
public T smallest() {
// assuming list is not empty, taking first value as smallest
T min = list.get(0);
for (int i = 1; i < list.size(); i++) {
// comparing element at i with min using doubleValue() of Number class
if (list.get(i).doubleValue() < min.doubleValue()) {
min = list.get(i);
}
}
return min;
}
// returns the elemnt at a given position
public T get(int index) {
return list.get(index);
}
}
Here is the sample input/outPut
TestCase1:
PART 2
Please enter a number:
30
Please another number:
20
Please enter your name:
John
Please enter your City:
Los Angeles
First number is 30
Second number is 20
Name is: John
City is: Los Angeles
TestCase2:
PART 2
Please enter a number:
.
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.
1 The goal is to implement DataStructuresArrayStack accor.pdfsaradashata
(1) The goal is to implement DataStructures.ArrayStack according to the interface ADTs.StackADT
********************************************
package DataStructures;
import ADTs.StackADT;
import Exceptions.EmptyCollectionException;
import Exceptions.StackOverflowException;
public class ArrayStack<T> implements StackADT<T> {
/** The index of where the top of the stack is */
int top;
/** The array that holds the stack */
T[] buffer;
public ArrayStack() {
}
public ArrayStack(int initialCapacity) {
}
}
*******************************************************
package ADTs;
import Exceptions.EmptyCollectionException;
import Exceptions.StackOverflowException;
/**
* An interface for a Stack
* Specific stack implementations will implement this interface
* For use Data Structures & Algorithms
*
*
* author unknown
*/
public interface StackADT<T> extends CollectionADT<T> {
/**
* Adds the specified element to the top of the stack
*
* @param element element to be pushed onto the stack
*/
public void push(T element) throws StackOverflowException;
/**
* Removes and returns the element that is on top of the stack
*
* @return the element removed from the stack
* @throws EmptyCollectionException
*/
public T pop() throws EmptyCollectionException;
/**
* Returns (without removing) the element that is on top of the stack
*
* @return the element on top of the stack
* @throws EmptyCollectionException
*/
public T peek() throws EmptyCollectionException;
}
*****************************************
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 unknown
*/
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 (wit.
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.
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] .
BackgroundIn many applications, the composition of a collection o.pdfmayorothenguyenhob69
Background:
In many applications, the composition of a collection of data items changes over time. Not only
are new data items added and existing ones removed, but data items may be duplicated. A list
data structure is a member of the general category of abstract data types called containers, whose
purpose is to hold other objects. In C++, lists are provided in the Standard Template Library.
However, for this assignment you will design and write your own linked list implementation to
support the ADT operations specified below.
Objective:
Design and implement the specifications for a List Abstract Data Type where the items in the list
are unsorted.
Requirements:
Define a list and develop a set of operations for creating and manipulating a list that satisfies the
list ADT specification.
List ADT Specification
Structure: The list elements are of ItemType. The list has a property called the current position
which designates the position of the last element accessed by GetNextItem during an iteration
through the list. Only ResetList and GetNextItem alter the current position.
Definitions (provided by the user):
MAX_ITEMS: A constant specifying the maximum capacity of items allowed on the list
Item Type: Class encapsulating the type of items in the list
RelationType: An enumeration type that consists of LESS, GREATER, EQUAL
Member function of ItemType that must be included:
RelationType ComparedTo(ItemType Item)
Function: Determines the ordering of two ItemType objects based on their keys
Precondition: Self and item have their key members initialized
Postcondition:
Function value = LESS if the key of self is less than the key of item
= GREATER if the key of self is greater than the key of item
= EQUAL if the keys are equal
Operations (provided by Unsorted List ADT)
Make Empty
Function: Initializes list to empty state
Preconditions: None
Postcondition: List is empty
Boolean IsFull
Function: Determines whether list is full
Preconditions: List has been initialized
Postcondition: Function value = (list is full)
int GetLength
Function: Determines the number of elements in list
Preconditions: List has been initialized
Postcondition: Function value = number of elements in list
ItemType GetItem(Item Typeitem, Boolean& found)
Function: Get list element whose key matches item’s key (if present)
Preconditions: List has been initialized
Key member of item is initialized
Postcondition: If there is an element someItem whose keymatches item’s key, then found =
true and copy of someItemis returned; otherwise found = false and item is returned
List is unchanged
PutItem(ItemType item)
Function: Puts item into list
Preconditions: List has been initialized
List is not full
Item is not in list
Postcondition: Item is in the list
DeleteItem(ItemType item)
Function: Deletes the element whose key matches item’s key
Preconditions: List has been initialized
Postcondition: One and only one element in list has a key matching item’s key
ResetList
Function: Initializes current p.
we using java code DynamicArrayjava Replace all .pdfgudduraza28
we using java code /** * DynamicArray.java * * Replace all //TODO tags with your code * * Note
that below the "//TODO" tag there may be * something like "return null;", "return 0;", etc. * That line
is just "stubbed in" so the class * will compile. When you add your code (one or many *
statements), you will want to delete the "stubbed" line. * By "stubbed in" we mean "mocked" or
"faked in" temporarily. * * When testing, construct using the static factory methods:
DynamicList.newEmpty() DynamicList.fromGrowthFactor(growthFactor)
DynamicList.from(arrayElements) */ package model.list; import java.lang.reflect.Array; import
java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiFunction; import
java.util.function.Consumer; import java.util.function.Function; import
model.linearpub.DynamicList; import model.linearpub.StructureIterator; public class
DynamicArray<E> implements DynamicList<E> { //--------------------------------- // Instance Variables
//TODO - declare instance variable(s) //--------------------------------- // Private Constructors /**
Constructs and returns new DynamicArray (no args constructor) */ private DynamicArray() {
this(defaultGrowthFactor()); } /** Constructs and returns new DynamicArray with "aGrowthFactor"
*/ private DynamicArray(double aGrowthFactor) { //TODO -- this is the constructor that should
//initialize the dynamic array as needed } //------------------------------------------------ public static double
defaultGrowthFactor() { //TODO - replace 0 with a good growth factor return 0; } protected static int
defaultInitialCapacity() { //TODO - replace 0 with a good initial capacity return 0; } //--------------------
List Statistics --------------------- /** * Return number of elements in this list. */ @Override public int
size() { //TODO return 0; } /** * Return true is this list contains no elements. */ @Override public
boolean isEmpty() { //TODO return false; } //------------------ Accessing Elements -------------------- /**
* Return element at given index. * Throws IndexOutOfBoundsException if passed index is invalid.
*/ @Override public E get(int index) { //TODO return null; } /** * Return first element * Throws
RuntimeException if list is empty */ @Override public E first() { //TODO return null; } /** * Return
last element * Throws RuntimeException if list is empty */ @Override public E last() { //TODO
return null; } /** * Return a new list containing the elements of this list * between the given index
"start" (inclusive) and * the given index "stop" (exclusive). * Throws IndexOutOfBoundsException if
either passed index is invalid. */ @Override public DynamicList<E> subList(int start, int stop) {
//TODO return null; } /** * Return index of first matching element (where searchFct outputs true) *
Return -1 if no match * Example usage (first list of integers, then employees): * index =
list.find(eaInteger -> eaInteger == 10); * index = employeeList.find(employee -> employee
.getFirstName().equals("Kofi.
Engineering lecture ppt by venay magenvenaymagen19
Venay Magen likes the shading red, particularly on Tuesdays. He cherishes to drink bourbon (on all days). He figured out how to drink whisky from his youth companion Zippo, when they went to class together at Mount Temple Comprehensive School. He is best known as the lead vocalist for the band MN3.
import java.util.ArrayList; import java.util.List;public class S.pdfanupamele
import java.util.ArrayList;
import java.util.List;
public class SearchList {
/**
* param args
*/
public static void main(String[] args) {
List list = new ArrayList();
list.add(3);
list.add(3);
list.add(1);
System.out.println(\"Search element 3 in list [3,3,1] :\"
+ search(list, 3));
System.out.println(\"Search element 5 in list [3,3,1] :\"
+ search(list, 5));
}
/**
* method to find the index of element in the list
* param list
* param element
* return
*/
public static int search(List list, Object element) {
int index = -1;
if (list == null || element == null)
throw new NullPointerException();
else {
int searchElement = (int) element;
for (int i = 0; i < list.size(); i++) {
int number = (int) list.get(i);
if (number == searchElement) {
index = i;
}
}
}
return index;
}
}
OUTPUT:
Search element 3 in list [3,3,1] :1
Search element 5 in list [3,3,1] :-1
Solution
import java.util.ArrayList;
import java.util.List;
public class SearchList {
/**
* param args
*/
public static void main(String[] args) {
List list = new ArrayList();
list.add(3);
list.add(3);
list.add(1);
System.out.println(\"Search element 3 in list [3,3,1] :\"
+ search(list, 3));
System.out.println(\"Search element 5 in list [3,3,1] :\"
+ search(list, 5));
}
/**
* method to find the index of element in the list
* param list
* param element
* return
*/
public static int search(List list, Object element) {
int index = -1;
if (list == null || element == null)
throw new NullPointerException();
else {
int searchElement = (int) element;
for (int i = 0; i < list.size(); i++) {
int number = (int) list.get(i);
if (number == searchElement) {
index = i;
}
}
}
return index;
}
}
OUTPUT:
Search element 3 in list [3,3,1] :1
Search element 5 in list [3,3,1] :-1.
please read the steps below and it will tell you what we usi.pdfaggarwalopticalsco
please read the steps below and it will tell you what we using
/**
* DynamicArray.java
*
* Replace all //TODO tags with your code
*
* Note that below the "//TODO" tag there may be
* something like "return null;", "return 0;", etc.
* That line is just "stubbed in" so the class
* will compile. When you add your code (one or many
* statements), you will want to delete the "stubbed" line.
* By "stubbed in" we mean "mocked" or "faked in" temporarily.
*
* When testing, construct using the static factory methods:
DynamicList.newEmpty()
DynamicList.fromGrowthFactor(growthFactor)
DynamicList.from(arrayElements)
*/
package model.list;
import java.lang.reflect.Array;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import model.linearpub.DynamicList;
import model.linearpub.StructureIterator;
public class DynamicArray<E> implements DynamicList<E> {
//---------------------------------
// Instance Variables
//TODO - declare instance variable(s)
//---------------------------------
// Private Constructors
/** Constructs and returns new DynamicArray (no args constructor) */
private DynamicArray() {
this(defaultGrowthFactor());
}
/** Constructs and returns new DynamicArray with "aGrowthFactor" */
private DynamicArray(double aGrowthFactor) {
//TODO -- this is the constructor that should
//initialize the dynamic array as needed
}
//------------------------------------------------
public static double defaultGrowthFactor() {
//TODO - replace 0 with a good growth factor
return 0;
}
protected static int defaultInitialCapacity() {
//TODO - replace 0 with a good initial capacity
return 0;
}
//-------------------- List Statistics ---------------------
/**
* Return number of elements in this list.
*/
@Override
public int size() {
//TODO
return 0;
}
/**
* Return true is this list contains no elements.
*/
@Override
public boolean isEmpty() {
//TODO
return false;
}
//------------------ Accessing Elements --------------------
/**
* Return element at given index.
* Throws IndexOutOfBoundsException if passed index is invalid.
*/
@Override
public E get(int index) {
//TODO
return null;
}
/**
* Return first element
* Throws RuntimeException if list is empty
*/
@Override
public E first() {
//TODO
return null;
}
/**
* Return last element
* Throws RuntimeException if list is empty
*/
@Override
public E last() {
//TODO
return null;
}
/**
* Return a new list containing the elements of this list
* between the given index "start" (inclusive) and
* the given index "stop" (exclusive).
* Throws IndexOutOfBoundsException if either passed index is invalid.
*/
@Override
public DynamicList<E> subList(int start, int stop) {
//TODO
return null;
}
/**
* Return index of first matching element (where searchFct outputs true)
* Return -1 if no match
* Example usage (first list of integers, then employees):
* index = list.find(eaInteger -> eaInteger == 10);
* index = employeeList.find(emplo.
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<.
Similar to For this lab you will complete the class MyArrayList by implementing.pdf (20)
Discuss the character and impact of the economic and legal revouluti.pdffashiongallery1
Discuss the character and impact of the economic and legal revoulutions on the American
economy between 1815 and 1840. Did this market revolution have to be so antagonistic toward
laborers? Explain your answer.
Solution
Market revolution refers to the changes in market structure from local to national markets.
Revolution impacted highly in agricultural sector. It has changed agricultural sector positively.
Textile and manufacturing industries drastically boom and strengthened the economy. Roadways
and canal system expanded, coin was made from precious metal, and there was huge financial
growth. During market revolution Americans began to experience the forces of supply and
demand. Transportation network highly changed during revolution and play a vital role in
commerce and new market.
Due to revolution there was drastic changes occurred in manual labor process. It has changed the
schedules, wages and working environment for laborers. Artisanal trades started to give way to
best efficient system of production, instead of using skilled labor and thus skilled labor were not
required for the production. There was no job security and laborer was paid low wages..
Discrete Math -Use induction to prove. The city of Inductionapolis.pdffashiongallery1
Discrete Math -
Use induction to prove. The city of Inductionapolis has multiple police districts. Any two
districts are connected by a one-way street. Show that there is a route that passes through every
district of the city.
Solution
Base case: 2 districts
Since there are one-way streets between any two districts. So there is a route passing through the
two districts
Hence base case is true
Inductive hypothesis: Assume it is true for some n number of districts, n>=2
Inductive step: We show it is true for n+1
COnsider any arbitrary district , say, D
Remaining n district have a route,R, passing through them because of inductive hypothesis
So, the C be a district which is the end point . Since there is a one way street from C to D call it ,
S
So the route, R+S is the route passing through all n+1 districst
Hence true for n+1
And hence for all n>=2.
Describe polarization and why it is important to WLANs.Solution.pdffashiongallery1
Describe polarization and why it is important to WLANs.
Solution
Polarization, likewise called wave polarization, is a declaration of the introduction of the lines of
electric flux in an electromagnetic field ( EM field ). Polarization can be consistent - that is,
existing in a specific introduction at all circumstances, or it can turn with each wave cycle.
Polarization is essential in remote correspondences frameworks. The physical introduction of a
remote reception apparatus relates to the polarization of the radio waves got or transmitted by
that recieving wire. In this way, a vertical reception apparatus gets and transmits vertically
captivated waves, and an even radio wire gets or emanates on a level plane spellbound waves.
The best short-run correspondences is acquired when the transmitting and accepting (source and
goal) reception apparatuses have a similar polarization. The slightest proficient short-run
interchanges for the most part happens when the two reception apparatuses are at right edges (for
instance, one even and one vertical). Over long separations, the environment can bring about the
polarization of a radio wave to change, so the refinement amongst flat and vertical turns out to be
less noteworthy.
Some remote radio wires transmit and get EM waves whose polarization turns 360 degrees with
each total wave cycle. This kind of polarization, called curved or roundabout polarization, can be
either clockwise or counterclockwise. The best interchanges results are gotten when the
transmitting and getting reception apparatuses have a similar feeling of polarization (both
clockwise or both counterclockwise). The most noticeably bad correspondences for the most part
happens when the two radio wires emanate and get in the inverse sense (one clockwise and the
other counterclockwise).
Polarization influences the proliferation of EM fields at infrared ( IR ), noticeable, bright ( UV ),
and even X-beam wavelength s. In conventional noticeable light, there are various wave parts
aimlessly polarization points. At the point when such light is gone through an uncommon
channel, the channel hinders all light aside from that having a specific polarization. At the point
when two polarizing channels are put so a beam of light goes through them both, the measure of
light transmitted relies on upon the edge of the polarizing channels regarding each other. The
most light is transmitted when the two channels are arranged so they spellbind light in a similar
bearing. The slightest light is transmitted when the channels are arranged at right points to each
other.One of the minimum comprehended properties of a remote flag is its polarization,
particularly in the event that you are introducing a considerable measure of WiFi Antennas in
one area, as on a tower. Polarization is dictated by the way a radio wire is mounted, and can
normally just be either level or vertical. This is imperative, particularly in indicate point remote
correspondence, in light of .
Describe the four basic elements of most communication systems.So.pdffashiongallery1
Describe the four basic elements of most communication systems.
Solution
A communication (message) system transmits, receives, and processes information in order
between two or more locations by means of electronic circuits.
Source or else Information
1.Analog [analog voice, video signal]
2. Digital [data]
Transmitter
A group of electronic workings and circuits intended to convert the in order into a signal suitable
for transmission over a known communication intermediate.
Receiver
Another set of electronic mechanism and circuits that accept the transmit communication from
the channel and change it back into a form comprehensible by humans.
Noise
Any random, unwanted energy that enters the connections system via the association’s medium
and interfere with the transmitted signal.
Channel
Provides means of transporting signals from a transmitter to a receiver.
Can someone please help me figure out how to do this Required Resou.pdffashiongallery1
Can someone please help me figure out how to do this? Required Resources Device with
Internet access Optional: IPv4 address calculator Identify IPv4 Addresses In Part 1, you will be
given several examples of IPv4 addresses and will complete tables with appropriate information.
Analyze the table shown below and identify the network portion and host portion of the given
IPv4 addresses. The first two rows show examples of how the table should be completed. Key
for table: N = all 8 bits for an octet are in the network portion of the address n = a bit in the
network portion of the address H = all 8 bits for an octet are in the host portion of the address h
= a bit in the host portion of the address
Solution
Ip address/prefix
Network/host N,n=network H,h=host
Subnet mask
Network address
192.168.10.10/24
N.N.N.H
255.255.255.0
192.168.10.0
10.101.99.17/23
N.N.nnnnnnnh.H
255.255.254.0
10.101.98.0
209.165.200.227/27
N.N.N.nnnhhhhh
255.255.255.224
209.165.200.224
172.31.45.252/24
N.N.N.H
255.255.255.0
172.31.45.255
10.1.8.200/26
N.N.N.nnhhhhhh
255.255.255.192
10.1.8.192
172.16.117.77/20
N.N.nnnnhhhh.H
255.255.240.0
172.16.112.0
10.1.1.101/25
N.N.N.nhhhhhhh
255.255.255.128
10.1.1.0
209.165.202.140/27
N.N.N.nnnhhhhh
255.255.255.224
209.165.202.128
192.168.28.45/28
N.N.N.nnnnhhhh
255.255.255.240
192.168.28.32
Ip address/prefix
Network/host N,n=network H,h=host
Subnet mask
Network address
192.168.10.10/24
N.N.N.H
255.255.255.0
192.168.10.0
10.101.99.17/23
N.N.nnnnnnnh.H
255.255.254.0
10.101.98.0
209.165.200.227/27
N.N.N.nnnhhhhh
255.255.255.224
209.165.200.224
172.31.45.252/24
N.N.N.H
255.255.255.0
172.31.45.255
10.1.8.200/26
N.N.N.nnhhhhhh
255.255.255.192
10.1.8.192
172.16.117.77/20
N.N.nnnnhhhh.H
255.255.240.0
172.16.112.0
10.1.1.101/25
N.N.N.nhhhhhhh
255.255.255.128
10.1.1.0
209.165.202.140/27
N.N.N.nnnhhhhh
255.255.255.224
209.165.202.128
192.168.28.45/28
N.N.N.nnnnhhhh
255.255.255.240
192.168.28.32.
Assume that the Current Assets for Shine Co. as of Decebmer 31, 2011.pdffashiongallery1
Assume that the Current Assets for Shine Co. as of Decebmer 31, 2011, are listed below.
Assume further that the total Current Liabilites on the same date are $150,000. What is the
current ratio for Shine Co. on December 31, 2011?
ASSETS
Current assets:
Cash $90,000
Temporary Investments 30,000
Accounts Receivable 78,000
Inventories 99,000
Prepaid Expenses 20,700
Total current assets $317,700
.3
1.0
1.3
2.1
Solution.
4. At what temperature will a solution of 8.27 g CaCl2 in 45.0 g H2.pdffashiongallery1
4. At what temperature will a solution of 8.27 g CaCl2 in 45.0 g H2O begin to freeze? Assume
complete dissociation
of CaCl2. (The freezing point depression constant for water is
Solution
molality = (8.27/111)*(1000/45) = 1.655
vant hoff factor = 3
so deltaT= K*M*i = 1.86 * 1.655 *3 = 9.24
so Tsolvent - Tsolution = deltaT........ => Tsolution = Tsolvent - deltaT.... =>Tsolution = 1-9.24
= 8.24\'C.
Briefly Explain all these points belowA. Marketing channels VS cha.pdffashiongallery1
Briefly Explain all these points below
A. Marketing channels VS changes in technology (online marketing)
B. Vertical marketing system (VMS) VS Conventional marketing system
C. Role of marketing intermediaries
D. Distribution strategies
E. Levels of service that retailers can offer
F. Types of retailers
Solution
c) Role of marketing intermediaries:
Marketing Intermediaries can be defined as the individuals or organizations the link the producer
to ultimate customer.The marketing intermediaries play a very important role in the development
of business by selling and promoting the products and services.The marketing intermediaries can
also be termed as agents of organizations.The different marketing intermediariers are agents,
wholesalers and retailers.They get the product at a certain price from organization and then they
sell it at somewhat higher price to the customer.The link the retail chain and are a part of supply
chain.Their exists different levels of channels in supply chain.
1) One level channel:
Producer---retiler----customer
2) two level channel:
producer---wholesaler---retailer---customer
3)Three level channel
Producer---distibutor---wholesaler---retailer---customer
4) Four level channel
Producer---agent-----distibutor---wholesaler---retailer---customer.
The detailed role of the marketing intermediaries is :
1) They facilitate or improve the salesby physically available to or close to customers.
2) They act as a sub distribution channel
3)They divide the bulk according to the minimum requirements of customers.
4) they provide according to suitability of customers.
5) They give presale and post sale service to customers.
6) They also bare risk of organization
7) They act as chain and chane agents of both technology and products.
D) Distribution strategies:The distribution startegies are ainly decided by the top
management.They are generally decided by keeping in view the 4Psof marketing i.e.,
product,price,place and promotion.There are different types of distribution strategies:
1) Exclusive distribution:It includes few intermediaries and usage of less retail outlets.
2)Selective distribution : It is one in which the manufacturer uses few selected intermediariers to
pass the product.
3)Intensive distribution: It is the one in which a firm sells through more number of outlets or
intermediaries.
F) Types of retilers:Retailers are individuals who direcly sell to the ultimate customer the
products.They mainly reach the customers who require less amont of goods.
The different types of retaiilers are:
1) spetiality stores: such retailers carry very narrow product line and offer high level of service.
2)Department stores:these type of retailers provide high range of producta and services.They
offer different levels of service at diffrent pricing.
3)Supermarkets: such type of retailers sell food and bevarage products and services.
4)Convienece retailers: These retailers sell few products at higher prices and are usually located
at the housin.
Write a class that implements the BagInterface. BagInterface should .pdffashiongallery1
Which one is NOT a duty of MySQL Administration? (Points : 2) Server startup and
shutdown
User account maintenance
Log maintenance
Running SQL statementsQuestion 2.2. (TCO A) How do you display the current system
variable values? (Points : 2) SHOW SYSTEM;
SHOW VARIABLES;
SHOW VALUES;
SHOW SYSTEM VARIABLES;Question 3.3. (TCO A) How do you display the global
variable values? (Points : 2) SHOW SYSTEM;
SHOW VARIABLES;
SHOW VALUES;
SHOW GLOBAL VARIABLES;Question 4.4. (TCO A) Which statement enables you to
rename tables or modify their structure? (Points : 2) MODIFY TABLE
ALTER TABLE
CHANGE TABLE
CREATE TABLEQuestion 5.5. (TCO A) Which is the statement that will rename the
instructor table to a new name? (Points : 2) ALTER TABLE instructor RENAME TO instr;
RENAME instructor instr;
This task is not available in MySQL.
ALTER TABLE instructor TO instr;Question 6.6. (TCO A) Review the following SQL
statement:
CHECKSUM TABLE instructor;
What is going to be the result if there is no table named instructor? (Points : 2)
CHECKSUM value is zero.
CHECKSUM value is negative.
CHECKSUM value is NULL.
An error occurs.Which one is NOT a duty of MySQL Administration? (Points : 2)
Server startup and shutdown
User account maintenance
Log maintenance
Running SQL statements
Solution
1.1 Which one is NOT a duty of MySQL Administration?
a) log maintainance
2.2 How do you display the current system variable values?
show variables
3.3 How do you display the global variable values?
SHOW GLOBAL VARIABLES;
4.4 Which statement enables you to rename tables or modify their structure?
ALTER TABLE
5.5 Which is the statement that will rename the instructor table to a new name?
This task is not available in MySQL.
6.6. CHECKSUM TABLE instructor;
CHECKSUM value is NULL..
write an equation for the transformation of the graph of y =f(x) tra.pdffashiongallery1
Write a C program in Linux to implement the following functionalities
Declare a global variable usr_interrupt=1
Write a signal handler function
voidreset_signalvaluezero ()
When a SIGALRM signal arrives this function will be called in which variable will be set
sig_atomic_t usr_interrupt = 0;
Write a signal handler function
voidIncrement_signalvalue ()
When a SIGINT signal arrives this function will be called in which variable will be incremented
the usr_interrupt by 1.
Write a main function
intmain (void)
Handle two Signals SIGALRM and SIGINT.
Set the alarm for 10 sec
Parent process will sit in tight loop by keeping check on usr_interrupt variable once this variable
will be 5 parent process will print some ENDING message and will exit.
Solution
#include
#include
#include
#include
#include
sig_atomic_t usr_interrupt = 1;
void reset_signalvaluezero(int signo)
{
if (signo == SIGALRM)
usr_interrupt = 0;
}
void Increment_signalvalue(int signo)
{
if (signo == SIGINT)
usr_interrupt++;
}
int main(void)
{
if (signal(SIGINT, Increment_signalvalue) == SIG_ERR)
printf(\"\ can\'t catch SIGINT\ \");
if (signal(SIGALRM, reset_signalvaluezero) == SIG_ERR)
printf(\"\ can\'t catch SIGALRM\ \");
alarm(10);
while(1)
{
if (usr_interrupt >= 5)
{
printf (\"Exiting...\");
return 0;
}
}
return 0;
}.
Using c++Im also using a the ide editor called CodeLiteThe hea.pdffashiongallery1
Typed out please In a short and simple response comment on this persons answer for masonry
work Additives combined with concrete to achieve certain properties are called what? Name a
few that would benefit the Engineer and Customer.
Response - Additives to concrete are utilized to provide certain benefits when placing concrete.
These additives called \"Admixtures\" can be used to speed up the curing process, slow down the
curing process, or help in working with concrete during cold temperatures. Retarders can be
added to concrete to slow down curing. Accelerators can be used to speed up the curing. The
most advanced additive is the Air-entrainment agent which gives mason the ability to work with
concrete in colder months.
Typed out please In a short and simple response comment on this persons answer for masonry
work Additives combined with concrete to achieve certain properties are called what? Name a
few that would benefit the Engineer and Customer.
Response - Additives to concrete are utilized to provide certain benefits when placing concrete.
These additives called \"Admixtures\" can be used to speed up the curing process, slow down the
curing process, or help in working with concrete during cold temperatures. Retarders can be
added to concrete to slow down curing. Accelerators can be used to speed up the curing. The
most advanced additive is the Air-entrainment agent which gives mason the ability to work with
concrete in colder months.
Response - Additives to concrete are utilized to provide certain benefits when placing concrete.
These additives called \"Admixtures\" can be used to speed up the curing process, slow down the
curing process, or help in working with concrete during cold temperatures. Retarders can be
added to concrete to slow down curing. Accelerators can be used to speed up the curing. The
most advanced additive is the Air-entrainment agent which gives mason the ability to work with
concrete in colder months.
Solution
The response of the person is good. He/she explained the admixtures and their applications pretty
well and also explained accelators, retarders and air entertainment in a simple straight forward
fashion.Overall i would say that the answer is satisfactory.
I will like to add \"PLASTICIZERS\" in the list of admixtures that would benefit the engineer
and customer. Plasticizers are water reducing admixtures and are added to the concrete mix for
making it more plastic without any further addition of water. In other words, they reduce the
quantity of water required to make concrete mixture of better plasticity.
PLEASE HIT LIKE BUTTON IF YOU FIND MY ANSWER SATISFACTORY.
THANK YOU..
Why are helper T-cells called helper cellsThey help pathogens i.pdffashiongallery1
Which observation about the system of equations squareroot a + 2 squareroot b - c = 12 and 3
squareroot ab = 24 squareroot c is correct? The system has exactly three solution because there
are three unknowns. The system has exactly two solutions because there are two equations. The
system has infinitely many solutions because there is more than one unknown. The system has
no solution because there are more equations than unknowns. The system has no solution
because there are more unknowns than equations.
Solution
The answer is last one because inorder to solve any equations the number of equations should be
given which is equal to number of arbitrary constants we have to find
Please rate my answer thank you.
Which of the following is NOT true of the Sons of Liberty a. New Yor.pdffashiongallery1
What type of performance measurement could managerial accountants use to determine the value
and productivity of human resources?
Solution
WAYS TO MEASURE HUMAN CAPITAL OR VALUE OF HUMAN RESOURCES
Human capital is considered a resource; an asset similar to land, equipment, bonds, and stocks.
However, it is INTANGIBLE IN NATURE, just like intellectual property or patents are.
Intangible assets are no less valuable than tangible ones, it’s just that their value cannot be
discerned easily.
One method to value is human capital’s return on investment (ROI).
Steps Involved
Formula = TOTAL ORGANIZATION PROFITS / INVESTMENTS ON HUMAN CAPITAL
Where Total Organizational Profits is profit after covering all of its expen
And Investment on Human Capital refers to money that your organization has put in to develop
its human capital; i.e. recruitment and selection, training and development, compensation, etc
If your ROI is sufficient, and if it is comparable to that of other companies in the same industry.
ROIs differ from one company to the next depending on their size, strategy, and industry, but
bench-marking is always considered good practice!
Some More human capital measurement techniques:
(a). Skills Inventory- It deals with the skills, capabilities, qualifications, trainings, and
certifications of your employees. The skills inventory may also include your employees’
preferences, career goals, and other developmental information.
(b) Personality-Focus on their “other attributes” along with skills, etc.The most important and
considered is personality.
An individual’s attitudes, and innate traits defines the employee. Many recent studies have
shown that over half the organizations today believe that HR is more influential than it was five
years ago. Executives are now recognizing HR’s ability to making strategic contributions to the
organization’s overall objective..
What made the Later Roman Economy so unstable (Bennette, Medieval E.pdffashiongallery1
What forms the corpus luteum and what hormones does it secrete?
The corpus albicans becomes the corpus luteum after ovulation and secretes estrogen and
progesterone.
The cumulus oophorus becomes the corpus luteum before ovulation and secretes luteinizing
hormone and estrogen to promote oocyte development.
The follicular cells become the corpus luteum after ovulation and secrete follicle stimulating
hormone and estrogen to promote oocyte development.
The Graafian follicle becomes the corpus luteum after ovulation and secretes estrogen and
progesterone.
The corpus albicans becomes the corpus luteum after ovulation and secretes estrogen and
progesterone.
The cumulus oophorus becomes the corpus luteum before ovulation and secretes luteinizing
hormone and estrogen to promote oocyte development.
The follicular cells become the corpus luteum after ovulation and secrete follicle stimulating
hormone and estrogen to promote oocyte development.
The Graafian follicle becomes the corpus luteum after ovulation and secretes estrogen and
progesterone.
Solution
Answer: D: the graffian follicle becomes the corpus luteum after ovulation and secretes estrogen
and progesterone.
The degenerating corpus luteum is called corpus albicans.
The corpus luteum secretes large quantity of progesterone and moderrior piyate quantity of
estrogen.
Leutinizing hormone and follicle stimulating hormone are from anterior pituitary..
What data would illustrate whether these underlying problems are occ.pdffashiongallery1
//variable to store probing location
//calculating the hash code
//if the position is empty, immediately return failure...
//...but if it\'s a match, return the data straight away...
//...otherwise, probe to the next item, looping to zero if necessary
//keep probing until data is found or entire table has been visited
//if the probed element is completely empty, return failure
//if the probed element is a match, return the data...
//...otherwise, keep probing for the next item, looping back to zero if necessary
//if nothing has been returned by now, data is not present
Solution
int probe;
//assignment is a constant time operation so O(1)
//here we are checking if table[code] == null which is also a constant time operation so O(1)
//if the position is empty, immediately return failure...
//same here O(1)
//...but if it\'s a match, return the data straight away...
//...otherwise, probe to the next item, looping to zero if necessary
//The time complexity isO(n) for while loop since we are looping the elements and O(1) for if
loop, but as weconsider only the biggest term , time complexity is O(n)
//O(n) is also time complexity for whole program for the same reason that we consider only
highest term
//keep probing until data is found or entire table has been visited
//same here O(1)
//if the probed element is completely empty, return failure
//same here O(1)
//if the probed element is a match, return the data...
//same here O(1),reason mentioned above
//...otherwise, keep probing for the next item, looping back to zero if necessary
return null;
//if nothing has been returned by now, data is not present.
1. What are distinct characteristics of baby boomers, generation X, .pdffashiongallery1
1. What are distinct characteristics of baby boomers, generation X, and generation Y employees?
2. How should managers use this understanding in their leadership, motivation of, and
communication with employees?
3. How does a manager reach out to employees when there are critical differences in values and
beliefs between manager and employee?
Solution
1) Different characteristics of baby boomers, generation X and generation Y employess:
Baby Boomers: Baby boomers are typically people who are born just after world war 2 and are
mostly in their 50-55 age. This generation of employees posses below mentiones chracteristics:
Generation X: These are the people who are next generation to baby boomers are in there 30s.
Few characteristics possed by this generation are:
Generation Y: They are born in the next generation to genration X. They are typically in the age
group of 18-25
Characteristics possed by them are:
2) Managers may use the above mentioned characteristics to deal differently with different
generations. Like, they can reward gen Y for good work to boost their confidence. They can
assign good designation to gen X to use there energy to make great decisions. Baby boomers can
be assigned strategic decision as they have work ethics of high standard and also have great
experience.
3) According to different generations, managers need to take different set of decisions to reach
out to employees. Like baby boomers need more high authority assurance to deal as they are
very much experienced. Gen Y needs ethical codes to convey the message as they are resonablly
new to work place..
VERSION The cells denoted by the letter Ain the figure to.pdffashiongallery1
Use the diagram below to answer the question that follows. Aguilar Manufacturing Company
packages a product for shipping by wrapping tape around the package as shown in the diagram.
An additional 10% length of tape per package is needed for overlap. What is the total length of
tape needed per package? 40 inch inches 66 inches 77 inches 110 inches.
Solution
Original length= 2(2(5+10))+2(15+5)=100
So. Length of package =100+100×10/100=110 inch
Correct answer is E..
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdffashiongallery1
Unlike the Federal income tax, most states do not require some form of state income tax.
True
False
Solution
Correct answer is True
Unlike Federal income tax, most states do not require some form of state income tax - This
statement is true as fililng of Fedral income tax return is mandatory for almost everybody but
some US states like Alaska, Florida, Navada, South Dakota, Texas, Washington and Wayoming
do not require filing of state income tax..
The __________ is the preeminent organization for developing and pub.pdffashiongallery1
The price elasticity of demand for a normal good is 2.4 and the income elasticity of demand is
1.9. f there is an increase in price of 8 percent and a simultaneous 6 percent increase in income,
quantity demanded will change by percent. (Enter your response rounded to one decimal place
and inolude a minus sign if necessary.)
Solution
Price elasticity of demand 2.4 Income elasticity of demand 1.9 With the Increase
in Price of 8% Quantity demanded will change by (8*2.40): 19.20% Note: There
will not be any effect of change in income on Quantity demanded..
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.
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.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
What is the purpose of the Sabbath Law in the Torah. It is interesting to compare how the context of the law shifts from Exodus to Deuteronomy. Who gets to rest, and why?
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
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!
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
We all have good and bad thoughts from time to time and situation to situation. We are bombarded daily with spiraling thoughts(both negative and positive) creating all-consuming feel , making us difficult to manage with associated suffering. Good thoughts are like our Mob Signal (Positive thought) amidst noise(negative thought) in the atmosphere. Negative thoughts like noise outweigh positive thoughts. These thoughts often create unwanted confusion, trouble, stress and frustration in our mind as well as chaos in our physical world. Negative thoughts are also known as “distorted thinking”.
How to Split Bills in the Odoo 17 POS ModuleCeline George
Bills have a main role in point of sale procedure. It will help to track sales, handling payments and giving receipts to customers. Bill splitting also has an important role in POS. For example, If some friends come together for dinner and if they want to divide the bill then it is possible by POS bill splitting. This slide will show how to split bills in odoo 17 POS.
For this lab you will complete the class MyArrayList by implementing.pdf
1. For this lab you will complete the class MyArrayList by implementing the MyList interface
provided. The implementation you write must use an array of Object, declared like this:
private Object[] theList;
To successfully implement the interface you must provide a non-abstract version of all the
methods in the interface.
Add functionality that ensures only one type of reference can be added to your
list. In other words, make your list "type-safe'.
Create an overloaded constructor in MyArrayList public MyArrayList( Object type). The
constructor parameter will
be used to set the type of reference to be added to the list. Set up a private filed of the same type
as the parameter. You will also instantiate your Object[] in this constructor. Do not change the
default constructor.
In public boolean add(Object toAdd) you will first check the toAdd parameter to ensure it is the
same as
the type you set in the overloaded constructor. If it is then go ahead and add the reference to
your list. If
not then return false and display an error message indicating the method parameter was rejected
due to
incompatible type.
To check the "toAdd" parameter you will have to first have to get the type of class it is (HINT:
look at
Object methods). Next, you will need to check its type against the type you established in the
overloaded constructor (HINT: look at the Class methods).
Finally, provide a driver class that will:
1) create the an instance of MyList and then add references to it. Be sure to try incompatible
types.
2) Check to see if the list is empty.
3) Display the contents of the list.
4) Display the size of the list.
5) Display the first element in the list.
2. 6) Remove the first element in the list.
7) Display the list one final time.
Modify the classes bellow to match the information above:
/**
* MyArrayList - an imlementation of an array list based on a Java array.
*
* @author Colleen
* @version 2013.11.15
*/
public class MyArrayList
{
private Object[] theList; // array of objects
/**
* Constructor - start with an empty array
*/
public MyArrayList()
{
theList = new Object[0];
}
/**
* Adds a new element at the end of the list.
* @param the object to add
* @return true if element successfully added, false if parameter is null
*/
public boolean add(Object toAdd){
return false;
}
/**
* Gets the object at the specified index.
* @param index value of object to get
* @return object at that index
*/
public Object get(int index){
3. return null;
}
/**
* Removes specified object from list.
* @param index value of object to remove
* @return the object removed
*/
public Object remove(int index) {
return null;
}
/**
* Returns size of the list
* @return number of elements in the list
*/
public int size(){
return 0;
}
/**
* @return true if the list has no elements, false otherwise
*/
public boolean isEmpty(){
return false;
}
}
------------------------------------
/**
* Write a description of interface List here.
*
* @author (your name)
4. * @version (a version number or a date)
*/
public interface MyList
{
/**
* Adds a new element at the end of the list.
* @param the object to add
* @return true if element successfully added, otherwise false
*/
boolean add(Object toAdd);
/**
* Gets the object at the specified index.
* @param index value of object to get
* @return object at that index
*/
Object get(int index);
/**
* Removes specified object from list.
* @param index value of object to remove
* @return the object removed
*/
Object remove(int index);
/**
* Returns size of the list
* @return number of elements in the list
*/
int size();
/**
* @return true if the list has no elements, false otherwise
*/
boolean isEmpty();
5. }
Solution
/**
* Write a description of interface List here.
*
* @author (your name)
* @version (a version number or a date)
*/
public interface MyList {
/**
* Adds a new element at the end of the list.
*
* @param the
* object to add
* @return true if element successfully added, otherwise false
*/
boolean add(Object toAdd);
/**
* Gets the object at the specified index.
*
* @param index
* value of object to get
* @return object at that index
*/
Object get(int index);
/**
* Removes specified object from list.
*
* @param index
* value of object to remove
* @return the object removed
*/
Object remove(int index);
/**
6. * Returns size of the list
*
* @return number of elements in the list
*/
int size();
/**
* @return true if the list has no elements, false otherwise
*/
boolean isEmpty();
}
-----------------------------------------
import java.util.Arrays;
/**
* MyArrayList - an imlementation of an array list based on a Java array.
*
* @author Colleen
* @version 2013.11.15
*/
public class MyArrayList implements MyList {
private Object[] theList; // array of objects
Class c; //type of reference
int size = 0; //size of array
/**
* Constructor - start with an empty array
*/
public MyArrayList() {
theList = new Object[0];
}
public MyArrayList(Object type) {
c = type.getClass(); //initialize the array type
theList = new Object[1]; //initialize the array with size 1
theList[0] = type; //initialize the element in the array
size = size + 1;
}
/**
* Adds a new element at the end of the list.
7. *
* @param the
* object to add
* @return true if element successfully added, false if parameter is null
*/
public boolean add(Object toAdd) {
if (this.c != null && !(toAdd.getClass().equals(this.c))) {
System.out.println("Incompatible Argument type " + toAdd);
return false;
} else if (this.c == null) {
this.c = toAdd.getClass();
theList = new Object[1];
} else if (toAdd.getClass().equals(this.c)) {
theList = Arrays.copyOf(theList, this.size + 1);
}
this.size = this.size + 1;
theList[this.size - 1] = toAdd;
return true;
}
/**
* Gets the object at the specified index.
*
* @param index
* value of object to get
* @return object at that index
*/
public Object get(int index) {
if (!(this.isEmpty())) {
return theList[index];
} else
return null;
}
/**
* Removes specified object from list.
*
* @param index
8. * value of object to remove
* @return the object removed
*/
public Object remove(int index) {
Object item = theList[index];
for (int i = index; i < this.size - 1; i++) {
theList[i] = theList[i + 1];
}
this.size = this.size - 1;
theList = Arrays.copyOf(theList, this.size);
System.out.println("Element removed successfully.");
return item;
}
/**
* Returns size of the list
*
* @return number of elements in the list
*/
public int size() {
return size;
}
/**
* @return true if the list has no elements, false otherwise
*/
public boolean isEmpty() {
if (size == 0) {
return true;
}
return false;
}
}
----------------------------------------------------
public class TestClass {
public static void main(String[] args) {
MyList obj = new MyArrayList();
obj.add(1);
9. obj.add(5);
obj.add(7);
obj.add("test");
obj.add(9);
obj.add(4);
System.out.println("Is this List empty: "+obj.isEmpty());
System.out.println("contents of the list :");
for (int i = 0; i < obj.size(); i++) {
System.out.println(obj.get(i));
}
System.out.println("Size of the List: " + obj.size());
System.out.println("first element in the list: "+obj.get(0));
obj.remove(0);
obj.remove(3);
System.out.println("contents of the list :");
for (int i = 0; i < obj.size(); i++) {
System.out.println(obj.get(i));
}
}
}