The document provides code for a linked list class with methods to add, remove, get, and traverse nodes. It contains comments describing each method and placeholders for some methods to be implemented, including getting the last node, checking if a value is contained, getting a node by position, inserting before a key, and reversing the list. It also includes test cases to validate the linked list functionality.
please read below it will tell you what we are using L.pdfankit11134
please read below it will tell you what we are using
/**
* LinkedList.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:
LinkedList.newEmpty()
LinkedList.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;
//This class is NOT java.util.LinkedList
public class LinkedList<E> implements DynamicList<E> {
//---------------------------------
// Instance Variables
//TODO - declare instance variable(s)
//---------------------------------
// Private Constructor
/** Constructs and returns new LinkedList (no args constructor) */
private LinkedList() {
}
//-------------------- 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"));
*/
@Override
public int findFirst(Function<E, Boolean> searchFct) {
//TODO
return 0;
}
/**
* Return index of last matching element (where searchFct outputs true)
* E.g., if searching for employee with name "Kofi" and there is a match
* at index=3 and index=8, findLast will return 8 (the last matching index).
* Hint: start search at end of list and work backwards through list.
* Return -1 if no match
*/
@Override
public int findLast(Function<E, Boolean> searchFct.
Please do parts labeled TODO LinkedList.java Replace.pdfaioils
Please do parts labeled TODO
/**
* LinkedList.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:
LinkedList.newEmpty()
LinkedList.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;
//This class is NOT java.util.LinkedList
public class LinkedList implements DynamicList {
//---------------------------------
// Instance Variables
//TODO - declare instance variable(s)
//---------------------------------
// Private Constructor
/** Constructs and returns new LinkedList (no args constructor) */
private LinkedList() {
}
//-------------------- 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 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"));
*/
@Override
public int findFirst(Function searchFct) {
//TODO
return 0;
}
/**
* Return index of last matching element (where searchFct outputs true)
* E.g., if searching for employee with name "Kofi" and there is a match
* at index=3 and index=8, findLast will return 8 (the last matching index).
* Hint: start search at end of list and work backwards through list.
* Return -1 if no match
*/
@Override
public int findLast(Function searchFct) {
//TODO
return 0;
}
//------------------- Setting Elem.
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.
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.
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.
public class MyLinkedListltE extends ComparableltEgtg.pdfaccostinternational
public class MyLinkedList<E extends Comparable<E>> {
private Node<E> head, tail;
private int size = 0; // Number of elements in the list
public MyLinkedList() {
head=tail=null;
size=0;
}
/** Return the head element in the list */
public E getFirst() {
if (size == 0) {
return null;
}
else {
return head.element;
}
}
/** Return the last element in the list */
public E getLast() {
if (size == 0) {
return null;
}
else {
return tail.element;
}
}
/** Add an element to the beginning of the list */
public void addFirst(E e) {
Node<E> newNode = new Node<>(e); // Create a new node
newNode.next = head; // link the new node with the head
head = newNode; // head points to the new node
size++; // Increase list size
if (tail == null) // the new node is the only node in list
tail = head;
}
/** Add an element to the end of the list */
public void addLast(E e) {
Node<E> newNode = new Node<>(e); // Create a new for element e
if (tail == null) {
head = tail = newNode; // The new node is the only node in list
}
else {
tail.next = newNode; // Link the new with the last node
tail = newNode; // tail now points to the last node
}
size++; // Increase size
}
public void add(int index, E e) {
if (index == 0) {
addFirst(e);
}
else if (index >= size) {
addLast(e);
}
else {
Node<E> current = head;
for (int i = 1; i < index; i++) {
current = current.next;
}
Node<E> temp = current.next;
current.next = new Node<>(e);
(current.next).next = temp;
size++;
}
}
//Add e to the end of this linkedlist
public void add(E e) {
// Left as Exercise
}
/** Remove the head node and
* return the object that is contained in the removed node. */
public E removeFirst() {
if (size == 0) {
return null;
}
else {
E temp = head.element;
head = head.next;
size--;
if (head == null) {
tail = null;
}
return temp;
}
}
/** Remove the last node and
* return the object that is contained in the removed node. */
public E removeLast() {
if (size == 0) {
return null;
}
else if (size == 1) {
E temp = head.element;
head = tail = null;
size = 0;
return temp;
}
else {
Node<E> current = head;
for (int i = 0; i < size - 2; i++) {
current = current.next;
}
E temp = tail.element;
tail = current;
tail.next = null;
size--;
return temp;
}
}
/** Remove the element at the specified position in this
* list. Return the element that was removed from the list. */
public E remove(int index) {
if (index < 0 || index >= size) {
return null;
}
else if (index == 0) {
return removeFirst();
}
else if (index == size - 1) {
return removeLast();
}
else {
Node<E> previous = head;
for (int i = 1; i < index; i++) {
previous = previous.next;
}
Node<E> current = previous.next;
previous.next = current.next;
size--;
return current.element;
}
}
/** Clear the list */
public void clear() {
size = 0;
head = tail = null;
}
/** Override toString() to return elements in the list in [] separated by , */
public String toString() {
StringBuilder result = new StringBuilder("[");
Node<E> current = head;
for (int i = 0; i < size; i++) {
result.append(current..
Problem- Describe an algorithm for concatenating two singly linked lis.pdfJamesPXNNewmanp
Problem: Describe an algorithm for concatenating two singly linked lists L and M, into a single
list L that contains all the nodes of L followed by all the nodes of M.
Modify the SinglyLinkedList class to contain the method:
public void concatenate(SinglyLinkedList other) { ... }
---------------Below is the code--------------------
public class SinglyLinkedList<E> implements Cloneable {
//---------------- nested Node class ----------------
/**
* Node of a singly linked list, which stores a reference to its
* element and to the subsequent node in the list (or null if this
* is the last node).
*/
private static class Node<E> {
/** The element stored at this node */
private E element; // reference to the element stored at this node
/** A reference to the subsequent node in the list */
private Node<E> next; // reference to the subsequent node in the list
/**
* Creates a node with the given element and next node.
*
* @param e the element to be stored
* @param n reference to a node that should follow the new node
*/
public Node(E e, Node<E> n) {
element = e;
next = n;
}
// Accessor methods
/**
* Returns the element stored at the node.
* @return the element stored at the node
*/
public E getElement() { return element; }
/**
* Returns the node that follows this one (or null if no such node).
* @return the following node
*/
public Node<E> getNext() { return next; }
// Modifier methods
/**
* Sets the node's next reference to point to Node n.
* @param n the node that should follow this one
*/
public void setNext(Node<E> n) { next = n; }
} //----------- end of nested Node class -----------
// instance variables of the SinglyLinkedList
/** The head node of the list */
private Node<E> head = null; // head node of the list (or null if empty)
/** The last node of the list */
private Node<E> tail = null; // last node of the list (or null if empty)
/** Number of nodes in the list */
private int size = 0; // number of nodes in the list
/** Constructs an initially empty list. */
public SinglyLinkedList() { } // constructs an initially empty list
// access methods
/**
* Returns the number of elements in the linked list.
* @return number of elements in the linked list
*/
public int size() { return size; }
/**
* Tests whether the linked list is empty.
* @return true if the linked list is empty, false otherwise
*/
public boolean isEmpty() { return size == 0; }
/**
* Returns (but does not remove) the first element of the list
* @return element at the front of the list (or null if empty)
*/
public E first() { // returns (but does not remove) the first element
if (isEmpty()) return null;
return head.getElement();
}
/**
* Returns (but does not remove) the last element of the list.
* @return element at the end of the list (or null if empty)
*/
public E last() { // returns (but does not remove) the last element
if (isEmpty()) return null;
return tail.getElement();
}
// update methods
/**
* Adds an element to the front of the list.
* @param e the new element to add
*/
publ.
tested on eclipseDoublyLinkedList class.pdfshanki7
//tested on eclipse
/*************DoublyLinkedList class*******************/
public class DoublyLinkedList {
/*Data member variable declaration*/
private Node head;
private int count;
/**default constructor*/
public DoublyLinkedList() {
/*Initializing variable*/
head=null;
count =0;
}
/*Insert at beginning in doubly linked list*/
public void insertBeginning(String name){
/*checking head is null then we will add node at head*/
if(head==null){
head=new Node(name, null, null);
count++;
}else{
/*else create temp node and setting next to head
* and then making temp to head*/
Node temp=new Node(name,null,null);
temp.setNext(head);
head.setPrev(temp);
head=temp;
count++;
}
}
public void printList(){
Node temp=head;
/*Printing element of doubly list*/
while(temp!=null){
System.out.println(temp.getData());
temp=temp.getNext();
}
}
/*Returning count from doubly linked list*/
public int count(){
return count;
}
/*deleting specific node from doubly linked list*/
public void delete(String name){
Node current=head,previous=head;
/*if it is head node to be deleted*/
if(head.getData().equals(name)){
current=head.getNext();
current.setPrev(null);
head=current;
previous=head;
}else{
/*If node in middle of list*/
while(current.getNext()!=null){
if(current.getData().equals(name)){
current.getNext().setPrev(previous);
previous.setNext(current.getNext());
count--;
break;
}
previous=current;
current=current.getNext();
}
/*If node is at last*/
if(current.getNext()==null){
if(current.getData().equals(name)){
previous.setNext(null);
count--;
}
}
}
}
/*deleting all nodes from list by assigning head to null
* and memory releasing take care by garbage collector*/
public void clear(){
head=null;
count=0;
}
/*Inserting element in alphabetic order*/
public void insertAlpha(String name){
Node current=head,previous=head;
/*creating new node*/
Node newNode=new Node(name,null,null);
/*if head node is null*/
if(head==null){
head=newNode;
count++;
}else{
/*please read about compareTo() method about returning value*/
if(head.getData().compareTo(name)>0){
newNode.setNext(head);
head=newNode;
count++;
}else{
/*condition for getting position of node to be inserted*/
while(current!=null&¤t.getData().compareTo(name)<=0){
previous=current;
current=current.getNext();
}
/*if node need to be inserted at last*/
if(current==null){
previous=newNode;
}else{
/*If node need to inserted in middle*/
newNode.setNext(current);
previous.setNext(newNode);
current.setPrev(newNode);
newNode.setPrev(previous);
}
count++;
}
}
}
/*Main method start*/
public static void main(String args[]){
/*creating object of doubly linked list*/
DoublyLinkedList doublyLinkedList=new DoublyLinkedList();
doublyLinkedList.insertBeginning(\"sunita\");
doublyLinkedList.insertBeginning(\"lalchand\");
/*calling alphabetic order method*/
doublyLinkedList.insertAlpha(\"ramsingh\");
doublyLinkedList.insertBeginning(\"Lokesh\");
doublyLinkedList.insertBeginning(\"Pritam\");
/*****printing list********/
doublyLinkedList.printL.
please read below it will tell you what we are using L.pdfankit11134
please read below it will tell you what we are using
/**
* LinkedList.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:
LinkedList.newEmpty()
LinkedList.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;
//This class is NOT java.util.LinkedList
public class LinkedList<E> implements DynamicList<E> {
//---------------------------------
// Instance Variables
//TODO - declare instance variable(s)
//---------------------------------
// Private Constructor
/** Constructs and returns new LinkedList (no args constructor) */
private LinkedList() {
}
//-------------------- 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"));
*/
@Override
public int findFirst(Function<E, Boolean> searchFct) {
//TODO
return 0;
}
/**
* Return index of last matching element (where searchFct outputs true)
* E.g., if searching for employee with name "Kofi" and there is a match
* at index=3 and index=8, findLast will return 8 (the last matching index).
* Hint: start search at end of list and work backwards through list.
* Return -1 if no match
*/
@Override
public int findLast(Function<E, Boolean> searchFct.
Please do parts labeled TODO LinkedList.java Replace.pdfaioils
Please do parts labeled TODO
/**
* LinkedList.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:
LinkedList.newEmpty()
LinkedList.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;
//This class is NOT java.util.LinkedList
public class LinkedList implements DynamicList {
//---------------------------------
// Instance Variables
//TODO - declare instance variable(s)
//---------------------------------
// Private Constructor
/** Constructs and returns new LinkedList (no args constructor) */
private LinkedList() {
}
//-------------------- 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 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"));
*/
@Override
public int findFirst(Function searchFct) {
//TODO
return 0;
}
/**
* Return index of last matching element (where searchFct outputs true)
* E.g., if searching for employee with name "Kofi" and there is a match
* at index=3 and index=8, findLast will return 8 (the last matching index).
* Hint: start search at end of list and work backwards through list.
* Return -1 if no match
*/
@Override
public int findLast(Function searchFct) {
//TODO
return 0;
}
//------------------- Setting Elem.
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.
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.
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.
public class MyLinkedListltE extends ComparableltEgtg.pdfaccostinternational
public class MyLinkedList<E extends Comparable<E>> {
private Node<E> head, tail;
private int size = 0; // Number of elements in the list
public MyLinkedList() {
head=tail=null;
size=0;
}
/** Return the head element in the list */
public E getFirst() {
if (size == 0) {
return null;
}
else {
return head.element;
}
}
/** Return the last element in the list */
public E getLast() {
if (size == 0) {
return null;
}
else {
return tail.element;
}
}
/** Add an element to the beginning of the list */
public void addFirst(E e) {
Node<E> newNode = new Node<>(e); // Create a new node
newNode.next = head; // link the new node with the head
head = newNode; // head points to the new node
size++; // Increase list size
if (tail == null) // the new node is the only node in list
tail = head;
}
/** Add an element to the end of the list */
public void addLast(E e) {
Node<E> newNode = new Node<>(e); // Create a new for element e
if (tail == null) {
head = tail = newNode; // The new node is the only node in list
}
else {
tail.next = newNode; // Link the new with the last node
tail = newNode; // tail now points to the last node
}
size++; // Increase size
}
public void add(int index, E e) {
if (index == 0) {
addFirst(e);
}
else if (index >= size) {
addLast(e);
}
else {
Node<E> current = head;
for (int i = 1; i < index; i++) {
current = current.next;
}
Node<E> temp = current.next;
current.next = new Node<>(e);
(current.next).next = temp;
size++;
}
}
//Add e to the end of this linkedlist
public void add(E e) {
// Left as Exercise
}
/** Remove the head node and
* return the object that is contained in the removed node. */
public E removeFirst() {
if (size == 0) {
return null;
}
else {
E temp = head.element;
head = head.next;
size--;
if (head == null) {
tail = null;
}
return temp;
}
}
/** Remove the last node and
* return the object that is contained in the removed node. */
public E removeLast() {
if (size == 0) {
return null;
}
else if (size == 1) {
E temp = head.element;
head = tail = null;
size = 0;
return temp;
}
else {
Node<E> current = head;
for (int i = 0; i < size - 2; i++) {
current = current.next;
}
E temp = tail.element;
tail = current;
tail.next = null;
size--;
return temp;
}
}
/** Remove the element at the specified position in this
* list. Return the element that was removed from the list. */
public E remove(int index) {
if (index < 0 || index >= size) {
return null;
}
else if (index == 0) {
return removeFirst();
}
else if (index == size - 1) {
return removeLast();
}
else {
Node<E> previous = head;
for (int i = 1; i < index; i++) {
previous = previous.next;
}
Node<E> current = previous.next;
previous.next = current.next;
size--;
return current.element;
}
}
/** Clear the list */
public void clear() {
size = 0;
head = tail = null;
}
/** Override toString() to return elements in the list in [] separated by , */
public String toString() {
StringBuilder result = new StringBuilder("[");
Node<E> current = head;
for (int i = 0; i < size; i++) {
result.append(current..
Problem- Describe an algorithm for concatenating two singly linked lis.pdfJamesPXNNewmanp
Problem: Describe an algorithm for concatenating two singly linked lists L and M, into a single
list L that contains all the nodes of L followed by all the nodes of M.
Modify the SinglyLinkedList class to contain the method:
public void concatenate(SinglyLinkedList other) { ... }
---------------Below is the code--------------------
public class SinglyLinkedList<E> implements Cloneable {
//---------------- nested Node class ----------------
/**
* Node of a singly linked list, which stores a reference to its
* element and to the subsequent node in the list (or null if this
* is the last node).
*/
private static class Node<E> {
/** The element stored at this node */
private E element; // reference to the element stored at this node
/** A reference to the subsequent node in the list */
private Node<E> next; // reference to the subsequent node in the list
/**
* Creates a node with the given element and next node.
*
* @param e the element to be stored
* @param n reference to a node that should follow the new node
*/
public Node(E e, Node<E> n) {
element = e;
next = n;
}
// Accessor methods
/**
* Returns the element stored at the node.
* @return the element stored at the node
*/
public E getElement() { return element; }
/**
* Returns the node that follows this one (or null if no such node).
* @return the following node
*/
public Node<E> getNext() { return next; }
// Modifier methods
/**
* Sets the node's next reference to point to Node n.
* @param n the node that should follow this one
*/
public void setNext(Node<E> n) { next = n; }
} //----------- end of nested Node class -----------
// instance variables of the SinglyLinkedList
/** The head node of the list */
private Node<E> head = null; // head node of the list (or null if empty)
/** The last node of the list */
private Node<E> tail = null; // last node of the list (or null if empty)
/** Number of nodes in the list */
private int size = 0; // number of nodes in the list
/** Constructs an initially empty list. */
public SinglyLinkedList() { } // constructs an initially empty list
// access methods
/**
* Returns the number of elements in the linked list.
* @return number of elements in the linked list
*/
public int size() { return size; }
/**
* Tests whether the linked list is empty.
* @return true if the linked list is empty, false otherwise
*/
public boolean isEmpty() { return size == 0; }
/**
* Returns (but does not remove) the first element of the list
* @return element at the front of the list (or null if empty)
*/
public E first() { // returns (but does not remove) the first element
if (isEmpty()) return null;
return head.getElement();
}
/**
* Returns (but does not remove) the last element of the list.
* @return element at the end of the list (or null if empty)
*/
public E last() { // returns (but does not remove) the last element
if (isEmpty()) return null;
return tail.getElement();
}
// update methods
/**
* Adds an element to the front of the list.
* @param e the new element to add
*/
publ.
tested on eclipseDoublyLinkedList class.pdfshanki7
//tested on eclipse
/*************DoublyLinkedList class*******************/
public class DoublyLinkedList {
/*Data member variable declaration*/
private Node head;
private int count;
/**default constructor*/
public DoublyLinkedList() {
/*Initializing variable*/
head=null;
count =0;
}
/*Insert at beginning in doubly linked list*/
public void insertBeginning(String name){
/*checking head is null then we will add node at head*/
if(head==null){
head=new Node(name, null, null);
count++;
}else{
/*else create temp node and setting next to head
* and then making temp to head*/
Node temp=new Node(name,null,null);
temp.setNext(head);
head.setPrev(temp);
head=temp;
count++;
}
}
public void printList(){
Node temp=head;
/*Printing element of doubly list*/
while(temp!=null){
System.out.println(temp.getData());
temp=temp.getNext();
}
}
/*Returning count from doubly linked list*/
public int count(){
return count;
}
/*deleting specific node from doubly linked list*/
public void delete(String name){
Node current=head,previous=head;
/*if it is head node to be deleted*/
if(head.getData().equals(name)){
current=head.getNext();
current.setPrev(null);
head=current;
previous=head;
}else{
/*If node in middle of list*/
while(current.getNext()!=null){
if(current.getData().equals(name)){
current.getNext().setPrev(previous);
previous.setNext(current.getNext());
count--;
break;
}
previous=current;
current=current.getNext();
}
/*If node is at last*/
if(current.getNext()==null){
if(current.getData().equals(name)){
previous.setNext(null);
count--;
}
}
}
}
/*deleting all nodes from list by assigning head to null
* and memory releasing take care by garbage collector*/
public void clear(){
head=null;
count=0;
}
/*Inserting element in alphabetic order*/
public void insertAlpha(String name){
Node current=head,previous=head;
/*creating new node*/
Node newNode=new Node(name,null,null);
/*if head node is null*/
if(head==null){
head=newNode;
count++;
}else{
/*please read about compareTo() method about returning value*/
if(head.getData().compareTo(name)>0){
newNode.setNext(head);
head=newNode;
count++;
}else{
/*condition for getting position of node to be inserted*/
while(current!=null&¤t.getData().compareTo(name)<=0){
previous=current;
current=current.getNext();
}
/*if node need to be inserted at last*/
if(current==null){
previous=newNode;
}else{
/*If node need to inserted in middle*/
newNode.setNext(current);
previous.setNext(newNode);
current.setPrev(newNode);
newNode.setPrev(previous);
}
count++;
}
}
}
/*Main method start*/
public static void main(String args[]){
/*creating object of doubly linked list*/
DoublyLinkedList doublyLinkedList=new DoublyLinkedList();
doublyLinkedList.insertBeginning(\"sunita\");
doublyLinkedList.insertBeginning(\"lalchand\");
/*calling alphabetic order method*/
doublyLinkedList.insertAlpha(\"ramsingh\");
doublyLinkedList.insertBeginning(\"Lokesh\");
doublyLinkedList.insertBeginning(\"Pritam\");
/*****printing list********/
doublyLinkedList.printL.
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 =.
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.
Java Foundations StackADT-java --- - Defines the interface to a stack.docxVictorXUQGloverl
Java Foundations
StackADT.java
/**
* Defines the interface to a stack collection.
*
* @author Java Foundations
* @version 4.0
*/
public interface StackADT<T> {
/**
* Adds the specified element to the top of this stack.
*
* @param element element to be pushed onto the stack
*/
public void push(T element);
/**
* Removes and returns the top element from this stack.
*
* @return the element removed from the stack
* @throws EmptyCollectionException if the stack is empty
*/
public T pop();
/**
* Returns the top element of this stack without removing it from the stack.
*
* @return the element on top of the stack. It is not removed from the stack
* @throws EmptyCollectionException if the stack is empty
*/
public T peek();
/**
* Returns true if this stack contains no elements.
*
* @return true if the stack is empty, false if the stack is not empty
*/
public boolean isEmpty();
/**
* Returns the number of elements in this stack.
*
* @return the number of elements in the stack
*/
public int size();
}
QueueADT.java
/**
* QueueADT defines the interface to a queue collection.
*
* @author Java Foundation
* @version 4.0
*/
public interface QueueADT<T> {
/**
* Adds one element to the rear of this queue.
*
* @param element the element to be added to the rear of the queue
*/
public void enqueue(T element);
/**
* Removes and returns the element at the front of this queue.
*
* @return the element at the front of the queue
* @throws EmptyCollectionException if the queue is empty
*/
public T dequeue();
/**
* Returns without removing the element at the front of this queue.
*
* @return the first element in the queue
* @throws EmptyCollectionException if the queue is empty
*/
public T first();
/**
* Returns true if this queue contains no elements.
*
* @return true if the queue is empty, false if the queue is not empty
*/
public boolean isEmpty();
/**
* Returns the number of elements in this queue.
*
* @return the number of elements in the queue
*/
public int size();
}
LinkedDeque.java
public class LinkedDeque<T> implements QueueADT<T>, StackADT<T>, DequeADT<T> {
// inner class for a double linked list node
private class DNode<T> {
private T element;
private DNode<T> prev, next;
}
// data fields for the LinkedDeque class
private DNode<T> front, rear;
private int size;
// deque interface methods
@Override
public void addFirst(T element) {
// create a new node and set it up
DNode<T> newNode = new DNode<T>();
newNode.element = element; // from param to new node obj
newNode.prev = newNode.next = null;
if(this.isEmpty()) {
// we are making the only node in the deque
this.rear = this.front = newNode;
} else {
// there already exists a new node
// so, put the new node before the front node
newNode.next = this.front;
this.front.prev = newNode;
this.front = newNode;
}
this.size++;
}
@Override
public T removeFirst() {
T grabbedElt = this.getFirst(); // checks for empty for us
if.
StackInterface An interface for the ADT stack. Do not modif.pdfARCHANASTOREKOTA
StackInterface
/**
An interface for the ADT stack.
Do not modify this file
*/
package PJ2;
public interface StackInterface
{
/** Gets the current number of data in this stack.
@return the integer number of entries currently in the stack*/
public int size();
/** Adds a new data to the top of this stack.
@param aData an object to be added to the stack */
public void push(T aData);
/** Removes and returns this stack\'s top data.
@return either the object at the top of the stack or,
if the stack is empty before the operation, null */
public T pop();
/** Retrieves this stack\'s top data.
@return either the data at the top of the stack or
null if the stack is empty */
public T peek();
/** Detects whether this stack is empty.
@return true if the stack is empty */
public boolean empty();
/** Removes all data from this stack */
public void clear();
} // end StackInterface
SimpleLinkedStack.java
/**
A class of stacks whose entries are stored in a chain of nodes.
Implement all methods in SimpleLinkedStack class using
the inner Node class.
Main Reference : text book or class notes
Do not change or add data fields
Do not add new methods
You may access Node object fields directly, i.e. data and next
*/
package PJ2;
public class SimpleLinkedStack implements StackInterface
{
// Data fields
private Node topNode; // references the first node in the chain
private int count; // number of data in this stack
public SimpleLinkedStack()
{
// add stataments
} // end default constructor
public void push(T newData)
{
// add stataments
} // end push
public T peek()
{
// add stataments
return null;
} // end peek
public T pop()
{
// add stataments
return null;
} // end pop
public boolean empty()
{
// add stataments
return false;
} // end empty
public int size()
{
// add stataments
return -1;
} // end isEmpty
public void clear()
{
// add stataments
} // end clear
public String toString()
{
// add stataments
// note: data class in stack must implement toString() method
// return a list of data in Stack, separate them with \',\'
return \"\";
}
/****************************************************
private inner node class
Do not modify this class!!
you may access data and next directly
***************************************************/
private class Node
{
private T data; // entry in list
private Node next; // link to next node
private Node (T dataPortion)
{
data = dataPortion;
next = null; // set next to NULL
} // end constructor
private Node (T dataPortion, Node nextNode)
{
data = dataPortion;
next = nextNode; // set next to refer to nextNode
} // end constructor
} // end Node
/****************************************************
Do not modify: Stack test
****************************************************/
public static void main (String args[])
{
System.out.println(\"\ \"+
\"*******************************************************\ \"+
\"Sample Expected output:\ \"+
\"\ \"+
\"OK: stack is empty\ \"+
\"Push 3 data: 10, 30, 50\ \"+
\"Print stack [50,30,10,]\ \"+
\"OK: sta.
Describe an algorithm for concatenating two singly linked lists L and.pdfdeepak596396
Dataset:
https://docs.google.com/spreadsheets/d/1NxuGt4LJ3ofi2PaWLWpAl90JmfqMKcGV/edit?usp=sharing&ouid=111109979069524025260&rtpof=true&sd=true
Q1) What is the average tenure of those customers of the telecom operator who are still with the
company as a customer and also those who have stopped using the services provided by the
company? (1 mark)
Here, churn = 'No' means that the customer is currently associated with the company, and churn
= 'Yes' means that the customer has stopped using the services provided by the company.
Q2)What is the monthly average revenue generated by the customers who are with the company
and also those who have left? (1 mark)
Q3) Find the percentage of churn and non-churn customers for each category of the following
services: (4 marks)
-MultipleLines
-PaperlessBilling
-OnlineSecurity
-OnlineBackup
-DeviceProtection
-TechSupport
-StreamingTV
-StreamingMovies.
Problem- Describe an algorithm for concatenating two singly linked lis.pdfkingsandqueens3
Problem: Describe an algorithm for concatenating two singly linked lists L and M, into a single
list L that contains all the nodes of L followed by all the nodes of M. Modify the
SinglyLinkedList class to contain the method:
public void concatenate(SinglyLinkedList other) { ... }
PLEASE PLEASE USE THE CODE BELOW..... THANK YOU
public class SinglyLinkedList<E> implements Cloneable {
//---------------- nested Node class ----------------
/**
* Node of a singly linked list, which stores a reference to its
* element and to the subsequent node in the list (or null if this
* is the last node).
*/
private static class Node<E> {
/** The element stored at this node */
private E element; // reference to the element stored at this node
/** A reference to the subsequent node in the list */
private Node<E> next; // reference to the subsequent node in the list
/**
* Creates a node with the given element and next node.
*
* @param e the element to be stored
* @param n reference to a node that should follow the new node
*/
public Node(E e, Node<E> n) {
element = e;
next = n;
}
// Accessor methods
/**
* Returns the element stored at the node.
* @return the element stored at the node
*/
public E getElement() { return element; }
/**
* Returns the node that follows this one (or null if no such node).
* @return the following node
*/
public Node<E> getNext() { return next; }
// Modifier methods
/**
* Sets the node's next reference to point to Node n.
* @param n the node that should follow this one
*/
public void setNext(Node<E> n) { next = n; }
} //----------- end of nested Node class -----------
// instance variables of the SinglyLinkedList
/** The head node of the list */
private Node<E> head = null; // head node of the list (or null if empty)
/** The last node of the list */
private Node<E> tail = null; // last node of the list (or null if empty)
/** Number of nodes in the list */
private int size = 0; // number of nodes in the list
/** Constructs an initially empty list. */
public SinglyLinkedList() { } // constructs an initially empty list
// access methods
/**
* Returns the number of elements in the linked list.
* @return number of elements in the linked list
*/
public int size() { return size; }
/**
* Tests whether the linked list is empty.
* @return true if the linked list is empty, false otherwise
*/
public boolean isEmpty() { return size == 0; }
/**
* Returns (but does not remove) the first element of the list
* @return element at the front of the list (or null if empty)
*/
public E first() { // returns (but does not remove) the first element
if (isEmpty()) return null;
return head.getElement();
}
/**
* Returns (but does not remove) the last element of the list.
* @return element at the end of the list (or null if empty)
*/
public E last() { // returns (but does not remove) the last element
if (isEmpty()) return null;
return tail.getElement();
}
// update methods
/**
* Adds an element to the front of the list.
* @param e the new element to add
*/
public vo.
we using java dynamicArray package modellinearpub imp.pdfadityagupta3310
we using java dynamicArray
package model.linearpub;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
public interface DynamicList<E> {
//-------------------- List Statistics ---------------------
/**
* Return number of elements in this list.
*/
int size();
/**
* Return true is this list contains no elements.
*/
boolean isEmpty();
//------------------ Accessing Elements --------------------
/**
* Return element at given index.
* Throws IndexOutOfBoundsException if passed index is invalid.
*/
E get(int index);
/**
* Return first element
* Throws RuntimeException if list is empty
*/
E first();
/**
* Return last element
* Throws RuntimeException if list is empty
*/
E last();
/**
* 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.
*/
DynamicList<E> subList(int start, int stop);
/**
* 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"));
*/
int findFirst(Function<E, Boolean> searchFct);
/**
* Return index of last matching element (where searchFct outputs true)
* E.g., if searching for employee with name "Kofi" and there is a match
* at index=3 and index=8, findLast will return 8 (the last matching index).
* Hint: start search at end of list and work backwards through list.
* Return -1 if no match
*/
int findLast(Function<E, Boolean> searchFct);
//------------------- Setting Elements ---------------------
/**
* Insert passed arg "newElem" into position "index"
* Return previous (replaced) elem at "index"
* Valid "index" values are between 0 and "size - 1"
* If "index" is invalid, throws IndexOutOfBoundsException.
*/
E set(int index, E newElem);
//------- Inserting, Appending & Replacing Elements --------
//------------------ (Dynamic Behaviors) ------------------
/**
* Add the passed element to start of list
*/
void addFirst(E newElem);
/**
* Add the passed element to end of list
*/
void addLast(E newElem);
/**
* Alias for "addLast" (same functionality)
*/
void add(E newElem);
/**
* Add all elements from "otherDynList" into "this" list
*/
void addAll(DynamicList<E> otherDynList);
/**
* Add all elements from passed fixed array "this" list
*/
void addAll(E[] array);
/**
* Shift to the right the element currently at "insertIndex" (if any) and all elements to the right
* Insert passed arg "newElem" into position "insertIndex"
* Valid "insertIndex" values are between 0 and "size"
* If index = "size" then it becomes a simple "add" operation
* If "insertIndex" is invalid, throws IndexOutOfBoundsException
*/
void insert(int insertIndex, E newElem);
//------------------- Removing Elements --------------------
//.
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 *.
LabProgram.java
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() {
first = null;
last = null;
iterator = null;
length = 0;
}
/**
* 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 {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return first.data;
}
/**
* Returns the value stored in the last node
* @precondition <>
* @return the value stored in the node last
* @throws NoSuchElementException <>
*/
public T getLast() throws NoSuchElementException {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return last.data;
}
/**
* 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 iterator.data;
}
/**
* Returns the current length of the LinkedList
* @return the length of the LinkedList from 0 to n
*/
public int getLength() {
return length;
}
/**
* Returns whether the LinkedList is currently empty
* @return whether the LinkedList is empty
*/
public boolean isEmpty() {
return length == 0;
}
/**
* Returns whether the iterator is offEnd, i.e. null
* @return whether the iterator is null
*/
public boolean offEnd() {
return iterator == null;
}
/**** MUTATORS ****/
/**
* Creates a new first element
* @param data the data to insert at the front of the LinkedList
* @postcondition <>
*/
public void addFirst(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
newNode.next = first;
first.prev = newNode;
first = newNode;
}
length++;
}
/**
* Creates a new last element
* @param data the data to insert at the end of the LinkedList
* @postcondition <>
*/
public void addLast(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
last.next = newNode;
newNode.prev = last;
last = newNode;
}
length++;
}
/**
* Inserts a new element after the iterator
* @param data the data to insert
* @precondition
* @throws NullPointerException
*/
public void addIter.
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.
package com.java2novice.ds.linkedlist;
import java.util.NoSuchElementException;
public class DoublyLinkedListImpl {
private Node head;
private Node tail;
private int size;
public DoublyLinkedListImpl() {
size = 0;
}
/**
* this class keeps track of each element information
* @author java2novice
*
*/
private class Node {
E element;
Node next;
Node prev;
public Node(E element, Node next, Node prev) {
this.element = element;
this.next = next;
this.prev = prev;
}
}
/**
* returns the size of the linked list
* @return
*/
public int size() { return size; }
/**
* return whether the list is empty or not
* @return
*/
public boolean isEmpty() { return size == 0; }
/**
* adds element at the starting of the linked list
* @param element
*/
public void addFirst(E element) {
Node tmp = new Node(element, head, null);
if(head != null ) {head.prev = tmp;}
head = tmp;
if(tail == null) { tail = tmp;}
size++;
System.out.println(\"adding: \"+element);
}
/**
* adds element at the end of the linked list
* @param element
*/
public void addLast(E element) {
Node tmp = new Node(element, null, tail);
if(tail != null) {tail.next = tmp;}
tail = tmp;
if(head == null) { head = tmp;}
size++;
System.out.println(\"adding: \"+element);
}
/**
* this method walks forward through the linked list
*/
public void iterateForward(){
System.out.println(\"iterating forward..\");
Node tmp = head;
while(tmp != null){
System.out.println(tmp.element);
tmp = tmp.next;
}
}
/**
* this method walks backward through the linked list
*/
public void iterateBackward(){
System.out.println(\"iterating backword..\");
Node tmp = tail;
while(tmp != null){
System.out.println(tmp.element);
tmp = tmp.prev;
}
}
/**
* this method removes element from the start of the linked list
* @return
*/
public E removeFirst() {
if (size == 0) throw new NoSuchElementException();
Node tmp = head;
head = head.next;
head.prev = null;
size--;
System.out.println(\"deleted: \"+tmp.element);
return tmp.element;
}
/**
* this method removes element from the end of the linked list
* @return
*/
public E removeLast() {
if (size == 0) throw new NoSuchElementException();
Node tmp = tail;
tail = tail.prev;
tail.next = null;
size--;
System.out.println(\"deleted: \"+tmp.element);
return tmp.element;
}
public static void main(String a[]){
DoublyLinkedListImpl dll = new DoublyLinkedListImpl();
dll.addFirst(10);
dll.addFirst(34);
dll.addLast(56);
dll.addLast(364);
dll.iterateForward();
dll.removeFirst();
dll.removeLast();
dll.iterateBackward();
}
}
Solution
package com.java2novice.ds.linkedlist;
import java.util.NoSuchElementException;
public class DoublyLinkedListImpl {
private Node head;
private Node tail;
private int size;
public DoublyLinkedListImpl() {
size = 0;
}
/**
* this class keeps track of each element information
* @author java2novice
*
*/
private class Node {
E element;
Node next;
Node prev;
public Node(E element, Node next, Node prev) {
this.element = element;
this.next = next;
this.prev = prev;
}
}
/**
* returns the size of the l.
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdfEdwardw5nSlaterl
Need Help!! C++
#include<iostream>
#include"linkedlist.h"
using namespace std;
/**
* @brief Destructor to destroy all nodes and release memory
*/
LinkedList::~LinkedList() {
//TODO: Add code here. Make sure memory is released properly.
}
/**
* @brief Purpose: Checks if the list is empty
* @return true if the list is empty, false otherwise
*/
bool LinkedList::isEmpty() const {
// TODO: Add code here
return count == 0;
}
/**
* @brief Get the number of nodes in the list
* @return int The number of nodes in the list
*/
int LinkedList::length() const{
//TODO: Add code here
}
/**
* @brief Convert the list to a string
*
*/
string LinkedList::toString() {
string str = "[";
Node *ptr = front;
if (ptr != nullptr) {
// Head node is not preceded by separator
str += to_string(ptr->val);
ptr = ptr->next;
}
while (ptr != nullptr) {
str += ", " + to_string(ptr->val);
ptr = ptr->next;
}
str += "]";
return str;
}
/**
* @brief Displays the contents of the list
*/
void LinkedList::displayAll() {
cout << toString() << endl;
}
//TODO: Add comments
void LinkedList::addRear(T val) {
// TODO: Add code here
// consider the two cases of whether the list was empty
}
//TODO: Add comments
void LinkedList::addFront(T val) {
// TODO: Add code here
// consider the two cases of whether the list was empty
}
//TODO: Add comments
bool LinkedList::deleteFront(T &OldNum) {
// TODO: Add code here
// consider if the list was empty and return false if the list is empty
// consider the special case of deleting the only node in the list
}
//TODO: Add comments
bool LinkedList::deleteRear(T &OldNum) {
// TODO: Add code here
// consider if the list was empty and return false if the list is empty
// consider the special case of deleting the only node in the list
}
/* --- harder ones for test 2 and 3 -- */
/**
* @brief Delete a node at a given position from the list. The
* node at position pos is deleted and the value of the deleted node is returned in val.
* The valid range of pos is 1 to count. pos = 1 is the first node, and pos = count is the last node.
* @param pos: position of the node to be deleted
* @param val: it is set to the value of the node to be deleted
* @return true: if the node was deleted successfully
* @return false: if the node was not deleted successfully because the position was out of range
*/
bool LinkedList::deleteAt(int pos, T &val) {
//TODO: Add code here
// check if the pos is valid first, then move the ptr to the rigth positon
// consider the special case of deleting the first node and the last node
// Do not forget to set value.
}
/**
* @brief Insert a value at a specified position in the list. The valid pos is in the range of 1 to
count+1.
* The value will be inserted before the node at the specified position. if pos = 1, the value will be
inserted
* at the front of the list. if pos = count+1, the value will be inserted at the rear of the list.
* @param pos: position to insert the value at.
* @param val: value to insert.
* @return true: if the value was inserte.
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.
Program 8 C++newproblems.txt12333142013KristinBrewer1032823.docxwkyra78
Program 8 C++/newproblems.txt12333/14/2013KristinBrewer10328/23/2013MarciaStephenson12228/28/2013JeremySavage11519/4/2013AlfredReddy10919/20/2013JustinLiu11734/22/2013FrancisWheeler11114/25/2013JeremyChung11934/26/2013MonicaFuller11125/1/2013ClaraGraves10535/3/2013DorothyCox11135/8/2013BryanMcCall10215/13/2013LorraineTe107210/7/2013AndreaBraun110210/8/2013DebbieBritt124210/9/2013WandaEnnis118210/11/2013TammyGrant120310/15/2013DorothyFlowers116110/16/2013ChristineBullardrrell
Program 8 C++/orderLinkedList.h
//*********************************************
// The ListNode class creates a type used to *
// store a node of the linked list. *
// PRECONDITIONS: *
// Choice for ItemType implements 'cout' *
// as well as "==" and "<" operators *
//*********************************************
#ifndef OrderOrderLinkedList_H
#define OrderOrderLinkedList_H
template <class ItemType>
class ListNode
{
public:
ItemType info; // Node value
ListNode<ItemType> *next; // Pointer to the next node
// Constructor
ListNode (ItemType nodeValue)
{
info = nodeValue;
next = NULL;
}
};
//*********************************************
// OrderLinkedList class *
//*********************************************
template <class ItemType>
class OrderLinkedList
{
private:
ListNode<ItemType> *head; // List head pointer
ListNode<ItemType> *currentPos; // Pointer to "current" list item
int length; // Length
public:
OrderLinkedList(); // Constructor
~OrderLinkedList(); // Destructor
OrderLinkedList( const OrderLinkedList<ItemType>& anotherList ); // Copy constructor
void operator= ( const OrderLinkedList<ItemType>& ); // Assignment op
void insertNode(ItemType);
void deleteNode(ItemType);
bool searchList(ItemType& item);
int getLength();
void displayList();
void resetList();
ItemType getNextItem(); // Iterator
bool atEnd();
};
//**************************************************
// Constructor *
// Initial list head pointer and length *
//**************************************************
template <class ItemType>
OrderLinkedList<ItemType>::OrderLinkedList()
{
head = NULL;
length = 0;
}
//**************************************************
// displayList shows the value stored in each node *
// of the linked list pointed to by head. *
// Precondition: "cout" operator enabled for *
// ItemType data type. *
//**************************************************
template <class ItemType>
void OrderLinkedList<ItemType>::displayList()
{
List ...
This is problem is same problem which i submitted on 22017, I just.pdffcaindore
There is a host of sociological and cultural research that paints a robust picture of the effects of
globalization on culture. This Application focuses on the flows of culture between Western and
developing nations. As a practitioner in this global environment, you should be familiar with
these culture effects. Use newspapers, magazines, and the Internet to research cultural changes in
both Western and developing countries due to globalization. Then perform the following tasks:
Outline the cultural aspects of globalization. Take an anthropological, rather than a business,
perspective. Explain how you think understanding culture helps in doing business in today\'s
global economy. Cite resources to justify your response.
Solution
Information technology has penetrated almost every aspect of our lives, “shrinking” our world
into a global village.
Economies and cultures have come closer. People are now aware of the cultures, traditions,
lifestyle, living conditions
prevailing in almost every corner of the world. Interestingly, this is going beyond awareness and
into a state of
integration that is a result of cross-pollinated views, ideologies, products and services.
This evolution is termed as “globalization.”
Culture has many definitions. My own definition is that culture is our collective experience as a
society,
and its impact on our reaction and decision-making relative to every-day facts and
circumstances.
Why is cross-cultural competence critical to your professional future and the viability of your
company?
It’s omnipresent in every business interaction and strategic decision.It is not feasible to be an
expert on
all the world’s cultures. It is possible, however, to incorporate a cross-cultural framework that
improves
cross-cultural understanding and interactions.
Multinational firms whose operations are borderless have to consider the cultural variability of
different regions
of the world and develop cultural understanding. Major cultural constraints encountered by
businesses include local
attitudes, taste preferences, language, religion, management style, gender discrimination, skills,
personalities,
education, etc. To be successful, they need to mold their business actions in accordance with the
local cultural models,
they need to establish a global mindset.
Let’s consider an example of the food giant, McDonald’s. The company enjoys a global
presence; operating in more than
100 countries serving 70 million people every day. Their headquarters and senior management
are U.S.-based but they
entrust their local operations to local managers of the countries they operate in. Operations in
more than 50 percent of
their outlets are franchised. Furthermore, their menus are customized according to cultural
habits and local taste
preferences in every country. It is without a doubt that global thinking and cultural
understanding are both powerful
business tools which allow multinational firms to dominate the local markets and establish a
global pres.
AvlTree.h
#ifndef AVL_TREE_H
#define AVL_TREE_H
#include "dsexceptions.h"
#include <iostream> // For NULL
#include <queue> // For level order printout
#include <vector>
#include <algorithm> // For max() function
using namespace std;
// AvlTree class
//
// CONSTRUCTION: with ITEM_NOT_FOUND object used to signal failed finds
//
// ******************PUBLIC OPERATIONS*********************
// Programming Assignment Part I
// bool empty( ) --> Test for empty tree @ root
// int size( ) --> Quantity of elements in tree
// int height( ) --> Height of the tree (null == -1)
// void insert( x ) --> Insert x
// void insert( vector<T> ) --> Insert whole vector of values
// void remove( x ) --> Remove x (unimplemented)
// bool contains( x ) --> Return true if x is present
// Comparable findMin( ) --> Return smallest item
// Comparable findMax( ) --> Return largest item
// boolean isEmpty( ) --> Return true if empty; else false
// void printTree( ) --> Print tree in sorted (in) order
// void printPreOrder( ) --> Print tree in pre order
// void printPostOrder( ) --> Print tree in post order
// void printInOrder( ) --> Print tree in *in* order
// Programming Assignment Part II (microassignment)
// void makeEmpty( ) --> Remove and delete all items
// void ~AvlTree( ) --> Big Five Destructor
// AvlTree(const AvlTree &other) --> BigFive Copy Constructor
// AvlTree(const AvlTree &&other) --> BigFive Move Constructor
// AvlTree &operator= ( AvlTree & other ) --> Big Five Copy *assignment* operator
// AvlTree &operator= ( AvlTree && other ) --> Big Five Move *assignment* operator
// void printLevelOrder( ) --> Print tree in LEVEL order :-)
// ******************ERRORS********************************
// Throws UnderflowException as warranted
template <typename Comparable>
class AvlTree
{
public:
/**
* Basic constructor for an empty tree
*/
AvlTree( ) : root( NULL )
{
//cout << " [d] AvlTree constructor called. " << endl;
}
/**
* Vector of data initializer (needed for move= operator rvalue)
*/
AvlTree( vector<Comparable> vals ) : root( NULL )
{
insert(vals);
}
//*******************************************************************************************
// START AVL TREES PART II - TODO: Implement
// Other functions to look for include: clone, makeEmpty, printLevelOrder
/**
* Destroy contents of the AvlTree object - Big Five Destructor
*/
~AvlTree( )
{
//cout << " [d] AvlTree Destructor called. " << endl;
// Empty out the AVL Tree and destroy all nodes (makeEmpty?)
}
/**
* Copy other to new object - Big Five Copy Constructor
*/
AvlTree( const AvlTree &other ) : root( NULL )
{
cout << " [d] Copy Constructor Called." << endl;
// Copy contents of other to ourselves (maybe clone?)
// Get a deep copy of other's tree
}
/* ...
How to do insertion sort on a singly linked list with no header usin.pdfarihantelehyb
How to do insertion sort on a singly linked list with no header using C?
Solution
/* C program for insertion sort on a linked list */
#include
#include
/* Link list node */
struct node
{
int data;
struct node* next;
};
// Function to insert a given node in a sorted linked list
void sortedInsert(struct node**, struct node*);
// function to sort a singly linked list using insertion sort
void insertionSort(struct node **head_ref)
{
// Initialize sorted linked list
struct node *sorted = NULL;
// Traverse the given linked list and insert every
// node to sorted
struct node *current = *head_ref;
while (current != NULL)
{
// Store next for next iteration
struct node *next = current->next;
// insert current in sorted linked list
sortedInsert(&sorted, current);
// Update current
current = next;
}
// Update head_ref to point to sorted linked list
*head_ref = sorted;
}
/* function to insert a new_node in a list. Note that this
function expects a pointer to head_ref as this can modify the
head of the input linked list (similar to push())*/
void sortedInsert(struct node** head_ref, struct node* new_node)
{
struct node* current;
/* Special case for the head end */
if (*head_ref == NULL || (*head_ref)->data >= new_node->data)
{
new_node->next = *head_ref;
*head_ref = new_node;
}
else
{
/* Locate the node before the point of insertion */
current = *head_ref;
while (current->next!=NULL &&
current->next->data < new_node->data)
{
current = current->next;
}
new_node->next = current->next;
current->next = new_node;
}
}
/* BELOW FUNCTIONS ARE JUST UTILITY TO TEST sortedInsert */
/* Function to print linked list */
void printList(struct node *head)
{
struct node *temp = head;
while(temp != NULL)
{
printf(\"%d \", temp->data);
temp = temp->next;
}
}
/* A utility function to insert a node at the beginning of linked list */
void push(struct node** head_ref, int new_data)
{
/* allocate node */
struct node* new_node = new node;
/* put in the data */
new_node->data = new_data;
/* link the old list off the new node */
new_node->next = (*head_ref);
/* move the head to point to the new node */
(*head_ref) = new_node;
}
// Driver program to test above functions
int main()
{
struct node *a = NULL;
push(&a, 5);
push(&a, 20);
push(&a, 4);
push(&a, 3);
push(&a, 30);
printf(\"Linked List before sorting \ \");
printList(a);
insertionSort(&a);
printf(\"\ Linked List after sorting \ \");
printList(a);
return 0;
}
/* C program for insertion sort on a linked list */
#include
#include
/* Link list node */
struct node
{
int data;
struct node* next;
};
// Function to insert a given node in a sorted linked list
void sortedInsert(struct node**, struct node*);
// function to sort a singly linked list using insertion sort
void insertionSort(struct node **head_ref)
{
// Initialize sorted linked list
struct node *sorted = NULL;
// Traverse the given linked list and insert every
// node to sorted
struct node *current = *head_ref;
while (current != NULL)
{
// Store next for next iteration
struct.
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <iterator>
/************************************************************/
// Local includes
/************************************************************/
// Using declarations
// YOU DO NOT NECESSARILY NEED TO USE ALL OF THESE!
using std::copy;
using std::copy_backward;
using std::distance;
using std::fill;
using std::ostream;
using std::ptrdiff_t;
/************************************************************/
template<typename T>
class Array
{
public:
//*****************************************************
// DO NOT MODIFY THIS SECTION!
// Some standard Container type aliases
using value_type = T;
// Iterators are just pointers to objects of type T
using iterator = value_type*;
using const_iterator = const value_type*;
using reference = value_type&;
using const_reference = const value_type&;
using size_type = size_t;
using difference_type = ptrdiff_t;
//*****************************************************
// Default ctor.
// Initialize an empty Array.
// This method is complete, and does NOT need modification.
// Remember to use a _member initialization list_ for each ctor,
// like I have below for the default ctor.
Array ()
: m_size (0),
m_capacity (0),
m_array (nullptr)
{
}
// Size ctor.
// Initialize an Array of size "pSize", with each element
// set to "value".
explicit Array (size_t pSize, const T& value = T ())
: m_size (pSize),
m_capacity (pSize),
m_array (new T[m_capacity])
{
fill (begin (), end (), value);
}
// TODO!
// Range ctor.
// Initialize an Array from the range [first, last).
// "first" and "last" must be Array iterators or pointers
// into a primitive array.
Array (const_iterator first, const_iterator last)
:m_size(distance(first,last)),m_capacity(m_size),m_array(new T[m_capacity])
{
copy(first,last,m_array);
}
// TODO!
// Copy ctor.
// Initialize this object from "a".
Array (const Array& a)
:m_size(a.m_size),m_capacity(a.m_capacity),m_array(new T[m_capacity])
{
copy(a.begin(),a.end(),m_array);
}
// TODO!
// Destructor.
// Release allocated memory.
~Array ()
{
delete[] m_array;
}
// TODO!
// Assignment operator.
// Assign "a" to this object.
// Be careful to check for self-assignment.
Array&
operator= (const Array& a)
{
if (this != &a)
{
delete[] m_array;
m_size = a.m_size;
m_capacity = a.m_capacity;
m_array = new T[m_capacity];
copy(a.begin(),a.end(),m_array);
}
return *this;
}
// Return the size.
size_t
size () const
{
return m_size;
}
// TODO!
// Return true if this Array is empty, false o/w.
bool
empty () const
{
return m_size == 0;
}
// TODO!
// Return the capacity.
size_t
capacity () const
{
return m_capacity;
}
// TODO!
// Return the element at position "index".
T& operator[] (size_t index)
{
return m_array[index];
}
// TODO!
const T& operator[] (size_t index) const
{
return m_array[index];
}
// TODO!
// Insert an element at the back.
// If the capacity is insufficient, DOUBLE it.
// If the capacity is 0, increase it to 1.
void
push_back (const T&.
Complete in JavaCardApp.javapublic class CardApp { private.pdfMAYANKBANSAL1981
Complete in Java
CardApp.java
public class CardApp {
private LinkedList list;
/**
* User interface prompts user, reads and writes files.
*/
public static void main(String[] args) {
}
/**
* Default constructor to initialize the deck
*/
public CardApp() {
}
/**
* Inserts a new Card into the deck
* @param card a playing Card
*/
public void addCard(Card card) {
}
/**
* Shuffles cards following this algorithm:
* First swaps first and last card
* Next, swaps every even card with the card 3
* nodes away from that card. Stops when it
* reaches the 3rd to last node
* Then, swaps ALL cards with the card that is
* 2 nodes away from it, starting at the 2nd card
* and stopping stopping at the 3rd to last node
*/
public void shuffle() {
}
/**
* Implements the bubble sort algorithm
* to sort cardList into sorted order, first by suit
* (alphabetical order)
* then by rank from 2 to A
*/
public void sort() {
}
/**
* Returns the deck of cards with each card separated
* by a blank space and a new line character at the end.
* @return The deck of cards as a string.
*/
@Override public String toString() {
return "";
}
}
Card.java
public class Card implements Comparable{
private String rank;
private String suit;
/**
* Constructor for the Card class
* @param rank the rank of card from 2 to A
* @param suit the suit of card C, D, H, or S
*/
public Card(String rank, String suit) {
}
/**
* Returns the card's rank
* @return rank a rank from 2 (low) to A (high)
*/
public String getRank() {
return "";
}
/**
* Returns the card's suit
* @return C, D, H, or S
*/
public String getSuit() {
return "";
}
/**
* Updates the card's rank
* @param rank a new rank
*/
public void setRank(String rank) {
}
/**
* Updates the card's suit
* @param suit the new suit
*/
public void setSuit(String suit) {
}
/**
* Concatenates rank and suit
* @return card rank and suit
*/
@Override public String toString() {
return "";
}
/**
* Overrides the equals method for Card
* Compares rank and suit and
* follows the equals formula given in
* Lesson 4 and also in Joshua Block's text
* @param obj another Object to compare for
* equality
* @return whether obj is a Card and, if so,
* of equal rank and suit
*/
@Override public boolean equals(Object obj) {
return false;
}
/**
* Orders two cards first by suit (alphabetically)
* Next by rank. "A" is considered the high card
* Order goes 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A
* @param card another Card to compare to this Card
* @return a negative number if this comes before c
* and a positive number if c comes before this
* and 0 if this and c are equal according to the above
* equals method
*/
@Override public int compareTo(Card card) {
return -1;
}
}
}
LinkedList.Java
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 iterato.
Given BinaryNode.javapackage util;import java.util.;T.pdfConint29
Given BinaryNode.java
package util;
import java.util.*;
/*
This class implements Binary Node for Binary Trees
Methods:
I) Two constructors
II) Two toString methods
III) height and size methods
IV) preorder, postorder, and inorder traversals
V) BFS and DFS traversal
*/
public class BinaryNode {
public E element;//data
public BinaryNode left;//left child
public BinaryNode right;//right child
//constructor for leaves
public BinaryNode(E element) {
this(element, null, null);
}
//constructor for internal nodes
public BinaryNode(E element, BinaryNode left, BinaryNode right) {
this.left = left;
this.right = right;
this.element = element;
}
public String toString2() {
if (left == null && right == null)//base case
return element + "";
return element + "(" + left + ", " + right + ")";
}
public int height() {
if (left == null && right == null)
return 0;
if (left == null)
return 1 + right.height();
if (right == null)
return 1 + left.height();
return 1 + Math.max(left.height(), right.height());
}
public int size() {
int size = 1;//counting root
if (left != null)//counting left subtree nodes
size += left.size();
if (right != null)//counting right subtree nodes
size += right.size();
return size;
}
public void printPreOrder() {
System.out.print(element + " ");
if (left != null)
left.printPreOrder();
if (right != null)
right.printPreOrder();
}
public void printPostOrder() {
if (left != null)
left.printPostOrder();
if (right != null)
right.printPostOrder();
System.out.print(element + " ");
}
public void printInOrder() {
if (left != null)
left.printInOrder();
System.out.print(element + " ");
if (right != null)
right.printInOrder();
}
public void printBFS() {//breadth first search traversal - non-recursive method
Queue q = new LinkedList<>();
q.add(this);
while (!q.isEmpty()) {
BinaryNode cur = q.remove();
System.out.print(cur.element + " ");
if (cur.left != null)
q.add(cur.left);
if (cur.right != null)
q.add(cur.right);
}
}
public void printDFS() {//depth first search traversal - equivalent to pre-order traversal
Stack stack = new Stack<>();
stack.add(this);
while (!stack.empty()) {
BinaryNode cur = stack.pop();
System.out.print(cur.element + " ");
if (cur.right != null)
stack.push(cur.right);
if (cur.left != null)
stack.push(cur.left);
}
}
public String toString() {
if (left == null && right == null && element == null)
return "";
Queue list = new LinkedList<>();
String result = "";
list.add(this);
list.add(null);
int level = (int) Math.pow(2, height());
BinaryNode dummy = new BinaryNode(null);
while (!list.isEmpty()) {
boolean allDummies = true;
for (BinaryNode b : list)
if (b != dummy && b != null) {
allDummies = false;
break;
}
BinaryNode cur = list.remove();
if (cur == null || allDummies)
break;
for (int i = 0; i < level - 1; i++)
result += '\t';
if (cur != dummy)
result += cur.element;
for (int i = 0; i < level + 1; i++)
result += '\t';
if (cur.left != null)
list.add(cur.left);
else
list.add(dummy);
if (cur.right != null)
list.add(cur.right);
else
list.add.
Domain Description for the Lunar Rover Back in July 30th 1971, the c.pdfConint29
Domain Description for the Lunar Rover: Back in July 30th 1971, the crew of Apollo 15
reached the moon surface. The first American astronaut reached the moon along with his team.
But they needed a mean of transportation. Their solution: A lunar buggy called Lunar Rover that
could travel speeds up to 12 km/h. This was an awesome opportunity for astronauts to travel long
distances outside Earth, but there were some technological constraints 45 years ago. The Lunar
Roving Vehicle could had only two pedals and two buttons to control the vehicles systems.
Moon Roover Movement Control: Engineers had to be creative in order to add all the
functionality need for a lunar cruise, so they came up with the following ideas: When the left
pedal was pressed once it accelerates the buggy forward. If accelerating forward and you press
right pedal once, it deaccelerates. To achieve constant forward speed press the right pedal for
more than 3 seconds. If the buggy is at rest and the left pedal is pressed for more than 3 seconds,
it will accelerate backwards. Part 1 Design a state machine to model the Movement Control as
described above. Note: The description above is not complete. Your task includes filling in these
missing details. Make sure to write down any assumptions you make as you develop the state
machine model. Part 2- Camera & Drill (Bonus 4 points): The coolest feature of the buggy
was not its speed but rather the color television camera, the 16-mm camera, and the drill. The
control was packed inside a television control unit. The only problem was that the cameras, and
the lunar rover drill were also controlled by the same control unit. So again engineers used the
two button controller to manipulate all devices: Press the button 1 for five seconds to interact
with the color camera. Press the button 1 for ten seconds to interact with the 16-mm camera.
Press button 1 twice to interact with the drill. Pressing button 2 at any of these modes return to
idle state. In any of the two camera modes, pressing button 1 takes a picture, while if pressed for
5 seconds activates the temporizer (moon selfies). Last inside the drill mode button 1 only acted
as an on off switch. Design a state machine to model the Camera and Drill. Extend the model
you developed for the movement control (2 points). Provide an implementation for this extended
state machine in Java (2 points). Every state should implement an entry action that prints on the
console the current state..
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 =.
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.
Java Foundations StackADT-java --- - Defines the interface to a stack.docxVictorXUQGloverl
Java Foundations
StackADT.java
/**
* Defines the interface to a stack collection.
*
* @author Java Foundations
* @version 4.0
*/
public interface StackADT<T> {
/**
* Adds the specified element to the top of this stack.
*
* @param element element to be pushed onto the stack
*/
public void push(T element);
/**
* Removes and returns the top element from this stack.
*
* @return the element removed from the stack
* @throws EmptyCollectionException if the stack is empty
*/
public T pop();
/**
* Returns the top element of this stack without removing it from the stack.
*
* @return the element on top of the stack. It is not removed from the stack
* @throws EmptyCollectionException if the stack is empty
*/
public T peek();
/**
* Returns true if this stack contains no elements.
*
* @return true if the stack is empty, false if the stack is not empty
*/
public boolean isEmpty();
/**
* Returns the number of elements in this stack.
*
* @return the number of elements in the stack
*/
public int size();
}
QueueADT.java
/**
* QueueADT defines the interface to a queue collection.
*
* @author Java Foundation
* @version 4.0
*/
public interface QueueADT<T> {
/**
* Adds one element to the rear of this queue.
*
* @param element the element to be added to the rear of the queue
*/
public void enqueue(T element);
/**
* Removes and returns the element at the front of this queue.
*
* @return the element at the front of the queue
* @throws EmptyCollectionException if the queue is empty
*/
public T dequeue();
/**
* Returns without removing the element at the front of this queue.
*
* @return the first element in the queue
* @throws EmptyCollectionException if the queue is empty
*/
public T first();
/**
* Returns true if this queue contains no elements.
*
* @return true if the queue is empty, false if the queue is not empty
*/
public boolean isEmpty();
/**
* Returns the number of elements in this queue.
*
* @return the number of elements in the queue
*/
public int size();
}
LinkedDeque.java
public class LinkedDeque<T> implements QueueADT<T>, StackADT<T>, DequeADT<T> {
// inner class for a double linked list node
private class DNode<T> {
private T element;
private DNode<T> prev, next;
}
// data fields for the LinkedDeque class
private DNode<T> front, rear;
private int size;
// deque interface methods
@Override
public void addFirst(T element) {
// create a new node and set it up
DNode<T> newNode = new DNode<T>();
newNode.element = element; // from param to new node obj
newNode.prev = newNode.next = null;
if(this.isEmpty()) {
// we are making the only node in the deque
this.rear = this.front = newNode;
} else {
// there already exists a new node
// so, put the new node before the front node
newNode.next = this.front;
this.front.prev = newNode;
this.front = newNode;
}
this.size++;
}
@Override
public T removeFirst() {
T grabbedElt = this.getFirst(); // checks for empty for us
if.
StackInterface An interface for the ADT stack. Do not modif.pdfARCHANASTOREKOTA
StackInterface
/**
An interface for the ADT stack.
Do not modify this file
*/
package PJ2;
public interface StackInterface
{
/** Gets the current number of data in this stack.
@return the integer number of entries currently in the stack*/
public int size();
/** Adds a new data to the top of this stack.
@param aData an object to be added to the stack */
public void push(T aData);
/** Removes and returns this stack\'s top data.
@return either the object at the top of the stack or,
if the stack is empty before the operation, null */
public T pop();
/** Retrieves this stack\'s top data.
@return either the data at the top of the stack or
null if the stack is empty */
public T peek();
/** Detects whether this stack is empty.
@return true if the stack is empty */
public boolean empty();
/** Removes all data from this stack */
public void clear();
} // end StackInterface
SimpleLinkedStack.java
/**
A class of stacks whose entries are stored in a chain of nodes.
Implement all methods in SimpleLinkedStack class using
the inner Node class.
Main Reference : text book or class notes
Do not change or add data fields
Do not add new methods
You may access Node object fields directly, i.e. data and next
*/
package PJ2;
public class SimpleLinkedStack implements StackInterface
{
// Data fields
private Node topNode; // references the first node in the chain
private int count; // number of data in this stack
public SimpleLinkedStack()
{
// add stataments
} // end default constructor
public void push(T newData)
{
// add stataments
} // end push
public T peek()
{
// add stataments
return null;
} // end peek
public T pop()
{
// add stataments
return null;
} // end pop
public boolean empty()
{
// add stataments
return false;
} // end empty
public int size()
{
// add stataments
return -1;
} // end isEmpty
public void clear()
{
// add stataments
} // end clear
public String toString()
{
// add stataments
// note: data class in stack must implement toString() method
// return a list of data in Stack, separate them with \',\'
return \"\";
}
/****************************************************
private inner node class
Do not modify this class!!
you may access data and next directly
***************************************************/
private class Node
{
private T data; // entry in list
private Node next; // link to next node
private Node (T dataPortion)
{
data = dataPortion;
next = null; // set next to NULL
} // end constructor
private Node (T dataPortion, Node nextNode)
{
data = dataPortion;
next = nextNode; // set next to refer to nextNode
} // end constructor
} // end Node
/****************************************************
Do not modify: Stack test
****************************************************/
public static void main (String args[])
{
System.out.println(\"\ \"+
\"*******************************************************\ \"+
\"Sample Expected output:\ \"+
\"\ \"+
\"OK: stack is empty\ \"+
\"Push 3 data: 10, 30, 50\ \"+
\"Print stack [50,30,10,]\ \"+
\"OK: sta.
Describe an algorithm for concatenating two singly linked lists L and.pdfdeepak596396
Dataset:
https://docs.google.com/spreadsheets/d/1NxuGt4LJ3ofi2PaWLWpAl90JmfqMKcGV/edit?usp=sharing&ouid=111109979069524025260&rtpof=true&sd=true
Q1) What is the average tenure of those customers of the telecom operator who are still with the
company as a customer and also those who have stopped using the services provided by the
company? (1 mark)
Here, churn = 'No' means that the customer is currently associated with the company, and churn
= 'Yes' means that the customer has stopped using the services provided by the company.
Q2)What is the monthly average revenue generated by the customers who are with the company
and also those who have left? (1 mark)
Q3) Find the percentage of churn and non-churn customers for each category of the following
services: (4 marks)
-MultipleLines
-PaperlessBilling
-OnlineSecurity
-OnlineBackup
-DeviceProtection
-TechSupport
-StreamingTV
-StreamingMovies.
Problem- Describe an algorithm for concatenating two singly linked lis.pdfkingsandqueens3
Problem: Describe an algorithm for concatenating two singly linked lists L and M, into a single
list L that contains all the nodes of L followed by all the nodes of M. Modify the
SinglyLinkedList class to contain the method:
public void concatenate(SinglyLinkedList other) { ... }
PLEASE PLEASE USE THE CODE BELOW..... THANK YOU
public class SinglyLinkedList<E> implements Cloneable {
//---------------- nested Node class ----------------
/**
* Node of a singly linked list, which stores a reference to its
* element and to the subsequent node in the list (or null if this
* is the last node).
*/
private static class Node<E> {
/** The element stored at this node */
private E element; // reference to the element stored at this node
/** A reference to the subsequent node in the list */
private Node<E> next; // reference to the subsequent node in the list
/**
* Creates a node with the given element and next node.
*
* @param e the element to be stored
* @param n reference to a node that should follow the new node
*/
public Node(E e, Node<E> n) {
element = e;
next = n;
}
// Accessor methods
/**
* Returns the element stored at the node.
* @return the element stored at the node
*/
public E getElement() { return element; }
/**
* Returns the node that follows this one (or null if no such node).
* @return the following node
*/
public Node<E> getNext() { return next; }
// Modifier methods
/**
* Sets the node's next reference to point to Node n.
* @param n the node that should follow this one
*/
public void setNext(Node<E> n) { next = n; }
} //----------- end of nested Node class -----------
// instance variables of the SinglyLinkedList
/** The head node of the list */
private Node<E> head = null; // head node of the list (or null if empty)
/** The last node of the list */
private Node<E> tail = null; // last node of the list (or null if empty)
/** Number of nodes in the list */
private int size = 0; // number of nodes in the list
/** Constructs an initially empty list. */
public SinglyLinkedList() { } // constructs an initially empty list
// access methods
/**
* Returns the number of elements in the linked list.
* @return number of elements in the linked list
*/
public int size() { return size; }
/**
* Tests whether the linked list is empty.
* @return true if the linked list is empty, false otherwise
*/
public boolean isEmpty() { return size == 0; }
/**
* Returns (but does not remove) the first element of the list
* @return element at the front of the list (or null if empty)
*/
public E first() { // returns (but does not remove) the first element
if (isEmpty()) return null;
return head.getElement();
}
/**
* Returns (but does not remove) the last element of the list.
* @return element at the end of the list (or null if empty)
*/
public E last() { // returns (but does not remove) the last element
if (isEmpty()) return null;
return tail.getElement();
}
// update methods
/**
* Adds an element to the front of the list.
* @param e the new element to add
*/
public vo.
we using java dynamicArray package modellinearpub imp.pdfadityagupta3310
we using java dynamicArray
package model.linearpub;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
public interface DynamicList<E> {
//-------------------- List Statistics ---------------------
/**
* Return number of elements in this list.
*/
int size();
/**
* Return true is this list contains no elements.
*/
boolean isEmpty();
//------------------ Accessing Elements --------------------
/**
* Return element at given index.
* Throws IndexOutOfBoundsException if passed index is invalid.
*/
E get(int index);
/**
* Return first element
* Throws RuntimeException if list is empty
*/
E first();
/**
* Return last element
* Throws RuntimeException if list is empty
*/
E last();
/**
* 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.
*/
DynamicList<E> subList(int start, int stop);
/**
* 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"));
*/
int findFirst(Function<E, Boolean> searchFct);
/**
* Return index of last matching element (where searchFct outputs true)
* E.g., if searching for employee with name "Kofi" and there is a match
* at index=3 and index=8, findLast will return 8 (the last matching index).
* Hint: start search at end of list and work backwards through list.
* Return -1 if no match
*/
int findLast(Function<E, Boolean> searchFct);
//------------------- Setting Elements ---------------------
/**
* Insert passed arg "newElem" into position "index"
* Return previous (replaced) elem at "index"
* Valid "index" values are between 0 and "size - 1"
* If "index" is invalid, throws IndexOutOfBoundsException.
*/
E set(int index, E newElem);
//------- Inserting, Appending & Replacing Elements --------
//------------------ (Dynamic Behaviors) ------------------
/**
* Add the passed element to start of list
*/
void addFirst(E newElem);
/**
* Add the passed element to end of list
*/
void addLast(E newElem);
/**
* Alias for "addLast" (same functionality)
*/
void add(E newElem);
/**
* Add all elements from "otherDynList" into "this" list
*/
void addAll(DynamicList<E> otherDynList);
/**
* Add all elements from passed fixed array "this" list
*/
void addAll(E[] array);
/**
* Shift to the right the element currently at "insertIndex" (if any) and all elements to the right
* Insert passed arg "newElem" into position "insertIndex"
* Valid "insertIndex" values are between 0 and "size"
* If index = "size" then it becomes a simple "add" operation
* If "insertIndex" is invalid, throws IndexOutOfBoundsException
*/
void insert(int insertIndex, E newElem);
//------------------- Removing Elements --------------------
//.
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 *.
LabProgram.java
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() {
first = null;
last = null;
iterator = null;
length = 0;
}
/**
* 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 {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return first.data;
}
/**
* Returns the value stored in the last node
* @precondition <>
* @return the value stored in the node last
* @throws NoSuchElementException <>
*/
public T getLast() throws NoSuchElementException {
if (isEmpty()){
throw new NoSuchElementException("The list is empty");
}
return last.data;
}
/**
* 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 iterator.data;
}
/**
* Returns the current length of the LinkedList
* @return the length of the LinkedList from 0 to n
*/
public int getLength() {
return length;
}
/**
* Returns whether the LinkedList is currently empty
* @return whether the LinkedList is empty
*/
public boolean isEmpty() {
return length == 0;
}
/**
* Returns whether the iterator is offEnd, i.e. null
* @return whether the iterator is null
*/
public boolean offEnd() {
return iterator == null;
}
/**** MUTATORS ****/
/**
* Creates a new first element
* @param data the data to insert at the front of the LinkedList
* @postcondition <>
*/
public void addFirst(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
newNode.next = first;
first.prev = newNode;
first = newNode;
}
length++;
}
/**
* Creates a new last element
* @param data the data to insert at the end of the LinkedList
* @postcondition <>
*/
public void addLast(T data) {
Node newNode = new Node(data);
if(isEmpty()){
first = newNode;
last = newNode;
}
else{
last.next = newNode;
newNode.prev = last;
last = newNode;
}
length++;
}
/**
* Inserts a new element after the iterator
* @param data the data to insert
* @precondition
* @throws NullPointerException
*/
public void addIter.
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.
package com.java2novice.ds.linkedlist;
import java.util.NoSuchElementException;
public class DoublyLinkedListImpl {
private Node head;
private Node tail;
private int size;
public DoublyLinkedListImpl() {
size = 0;
}
/**
* this class keeps track of each element information
* @author java2novice
*
*/
private class Node {
E element;
Node next;
Node prev;
public Node(E element, Node next, Node prev) {
this.element = element;
this.next = next;
this.prev = prev;
}
}
/**
* returns the size of the linked list
* @return
*/
public int size() { return size; }
/**
* return whether the list is empty or not
* @return
*/
public boolean isEmpty() { return size == 0; }
/**
* adds element at the starting of the linked list
* @param element
*/
public void addFirst(E element) {
Node tmp = new Node(element, head, null);
if(head != null ) {head.prev = tmp;}
head = tmp;
if(tail == null) { tail = tmp;}
size++;
System.out.println(\"adding: \"+element);
}
/**
* adds element at the end of the linked list
* @param element
*/
public void addLast(E element) {
Node tmp = new Node(element, null, tail);
if(tail != null) {tail.next = tmp;}
tail = tmp;
if(head == null) { head = tmp;}
size++;
System.out.println(\"adding: \"+element);
}
/**
* this method walks forward through the linked list
*/
public void iterateForward(){
System.out.println(\"iterating forward..\");
Node tmp = head;
while(tmp != null){
System.out.println(tmp.element);
tmp = tmp.next;
}
}
/**
* this method walks backward through the linked list
*/
public void iterateBackward(){
System.out.println(\"iterating backword..\");
Node tmp = tail;
while(tmp != null){
System.out.println(tmp.element);
tmp = tmp.prev;
}
}
/**
* this method removes element from the start of the linked list
* @return
*/
public E removeFirst() {
if (size == 0) throw new NoSuchElementException();
Node tmp = head;
head = head.next;
head.prev = null;
size--;
System.out.println(\"deleted: \"+tmp.element);
return tmp.element;
}
/**
* this method removes element from the end of the linked list
* @return
*/
public E removeLast() {
if (size == 0) throw new NoSuchElementException();
Node tmp = tail;
tail = tail.prev;
tail.next = null;
size--;
System.out.println(\"deleted: \"+tmp.element);
return tmp.element;
}
public static void main(String a[]){
DoublyLinkedListImpl dll = new DoublyLinkedListImpl();
dll.addFirst(10);
dll.addFirst(34);
dll.addLast(56);
dll.addLast(364);
dll.iterateForward();
dll.removeFirst();
dll.removeLast();
dll.iterateBackward();
}
}
Solution
package com.java2novice.ds.linkedlist;
import java.util.NoSuchElementException;
public class DoublyLinkedListImpl {
private Node head;
private Node tail;
private int size;
public DoublyLinkedListImpl() {
size = 0;
}
/**
* this class keeps track of each element information
* @author java2novice
*
*/
private class Node {
E element;
Node next;
Node prev;
public Node(E element, Node next, Node prev) {
this.element = element;
this.next = next;
this.prev = prev;
}
}
/**
* returns the size of the l.
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdfEdwardw5nSlaterl
Need Help!! C++
#include<iostream>
#include"linkedlist.h"
using namespace std;
/**
* @brief Destructor to destroy all nodes and release memory
*/
LinkedList::~LinkedList() {
//TODO: Add code here. Make sure memory is released properly.
}
/**
* @brief Purpose: Checks if the list is empty
* @return true if the list is empty, false otherwise
*/
bool LinkedList::isEmpty() const {
// TODO: Add code here
return count == 0;
}
/**
* @brief Get the number of nodes in the list
* @return int The number of nodes in the list
*/
int LinkedList::length() const{
//TODO: Add code here
}
/**
* @brief Convert the list to a string
*
*/
string LinkedList::toString() {
string str = "[";
Node *ptr = front;
if (ptr != nullptr) {
// Head node is not preceded by separator
str += to_string(ptr->val);
ptr = ptr->next;
}
while (ptr != nullptr) {
str += ", " + to_string(ptr->val);
ptr = ptr->next;
}
str += "]";
return str;
}
/**
* @brief Displays the contents of the list
*/
void LinkedList::displayAll() {
cout << toString() << endl;
}
//TODO: Add comments
void LinkedList::addRear(T val) {
// TODO: Add code here
// consider the two cases of whether the list was empty
}
//TODO: Add comments
void LinkedList::addFront(T val) {
// TODO: Add code here
// consider the two cases of whether the list was empty
}
//TODO: Add comments
bool LinkedList::deleteFront(T &OldNum) {
// TODO: Add code here
// consider if the list was empty and return false if the list is empty
// consider the special case of deleting the only node in the list
}
//TODO: Add comments
bool LinkedList::deleteRear(T &OldNum) {
// TODO: Add code here
// consider if the list was empty and return false if the list is empty
// consider the special case of deleting the only node in the list
}
/* --- harder ones for test 2 and 3 -- */
/**
* @brief Delete a node at a given position from the list. The
* node at position pos is deleted and the value of the deleted node is returned in val.
* The valid range of pos is 1 to count. pos = 1 is the first node, and pos = count is the last node.
* @param pos: position of the node to be deleted
* @param val: it is set to the value of the node to be deleted
* @return true: if the node was deleted successfully
* @return false: if the node was not deleted successfully because the position was out of range
*/
bool LinkedList::deleteAt(int pos, T &val) {
//TODO: Add code here
// check if the pos is valid first, then move the ptr to the rigth positon
// consider the special case of deleting the first node and the last node
// Do not forget to set value.
}
/**
* @brief Insert a value at a specified position in the list. The valid pos is in the range of 1 to
count+1.
* The value will be inserted before the node at the specified position. if pos = 1, the value will be
inserted
* at the front of the list. if pos = count+1, the value will be inserted at the rear of the list.
* @param pos: position to insert the value at.
* @param val: value to insert.
* @return true: if the value was inserte.
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.
Program 8 C++newproblems.txt12333142013KristinBrewer1032823.docxwkyra78
Program 8 C++/newproblems.txt12333/14/2013KristinBrewer10328/23/2013MarciaStephenson12228/28/2013JeremySavage11519/4/2013AlfredReddy10919/20/2013JustinLiu11734/22/2013FrancisWheeler11114/25/2013JeremyChung11934/26/2013MonicaFuller11125/1/2013ClaraGraves10535/3/2013DorothyCox11135/8/2013BryanMcCall10215/13/2013LorraineTe107210/7/2013AndreaBraun110210/8/2013DebbieBritt124210/9/2013WandaEnnis118210/11/2013TammyGrant120310/15/2013DorothyFlowers116110/16/2013ChristineBullardrrell
Program 8 C++/orderLinkedList.h
//*********************************************
// The ListNode class creates a type used to *
// store a node of the linked list. *
// PRECONDITIONS: *
// Choice for ItemType implements 'cout' *
// as well as "==" and "<" operators *
//*********************************************
#ifndef OrderOrderLinkedList_H
#define OrderOrderLinkedList_H
template <class ItemType>
class ListNode
{
public:
ItemType info; // Node value
ListNode<ItemType> *next; // Pointer to the next node
// Constructor
ListNode (ItemType nodeValue)
{
info = nodeValue;
next = NULL;
}
};
//*********************************************
// OrderLinkedList class *
//*********************************************
template <class ItemType>
class OrderLinkedList
{
private:
ListNode<ItemType> *head; // List head pointer
ListNode<ItemType> *currentPos; // Pointer to "current" list item
int length; // Length
public:
OrderLinkedList(); // Constructor
~OrderLinkedList(); // Destructor
OrderLinkedList( const OrderLinkedList<ItemType>& anotherList ); // Copy constructor
void operator= ( const OrderLinkedList<ItemType>& ); // Assignment op
void insertNode(ItemType);
void deleteNode(ItemType);
bool searchList(ItemType& item);
int getLength();
void displayList();
void resetList();
ItemType getNextItem(); // Iterator
bool atEnd();
};
//**************************************************
// Constructor *
// Initial list head pointer and length *
//**************************************************
template <class ItemType>
OrderLinkedList<ItemType>::OrderLinkedList()
{
head = NULL;
length = 0;
}
//**************************************************
// displayList shows the value stored in each node *
// of the linked list pointed to by head. *
// Precondition: "cout" operator enabled for *
// ItemType data type. *
//**************************************************
template <class ItemType>
void OrderLinkedList<ItemType>::displayList()
{
List ...
This is problem is same problem which i submitted on 22017, I just.pdffcaindore
There is a host of sociological and cultural research that paints a robust picture of the effects of
globalization on culture. This Application focuses on the flows of culture between Western and
developing nations. As a practitioner in this global environment, you should be familiar with
these culture effects. Use newspapers, magazines, and the Internet to research cultural changes in
both Western and developing countries due to globalization. Then perform the following tasks:
Outline the cultural aspects of globalization. Take an anthropological, rather than a business,
perspective. Explain how you think understanding culture helps in doing business in today\'s
global economy. Cite resources to justify your response.
Solution
Information technology has penetrated almost every aspect of our lives, “shrinking” our world
into a global village.
Economies and cultures have come closer. People are now aware of the cultures, traditions,
lifestyle, living conditions
prevailing in almost every corner of the world. Interestingly, this is going beyond awareness and
into a state of
integration that is a result of cross-pollinated views, ideologies, products and services.
This evolution is termed as “globalization.”
Culture has many definitions. My own definition is that culture is our collective experience as a
society,
and its impact on our reaction and decision-making relative to every-day facts and
circumstances.
Why is cross-cultural competence critical to your professional future and the viability of your
company?
It’s omnipresent in every business interaction and strategic decision.It is not feasible to be an
expert on
all the world’s cultures. It is possible, however, to incorporate a cross-cultural framework that
improves
cross-cultural understanding and interactions.
Multinational firms whose operations are borderless have to consider the cultural variability of
different regions
of the world and develop cultural understanding. Major cultural constraints encountered by
businesses include local
attitudes, taste preferences, language, religion, management style, gender discrimination, skills,
personalities,
education, etc. To be successful, they need to mold their business actions in accordance with the
local cultural models,
they need to establish a global mindset.
Let’s consider an example of the food giant, McDonald’s. The company enjoys a global
presence; operating in more than
100 countries serving 70 million people every day. Their headquarters and senior management
are U.S.-based but they
entrust their local operations to local managers of the countries they operate in. Operations in
more than 50 percent of
their outlets are franchised. Furthermore, their menus are customized according to cultural
habits and local taste
preferences in every country. It is without a doubt that global thinking and cultural
understanding are both powerful
business tools which allow multinational firms to dominate the local markets and establish a
global pres.
AvlTree.h
#ifndef AVL_TREE_H
#define AVL_TREE_H
#include "dsexceptions.h"
#include <iostream> // For NULL
#include <queue> // For level order printout
#include <vector>
#include <algorithm> // For max() function
using namespace std;
// AvlTree class
//
// CONSTRUCTION: with ITEM_NOT_FOUND object used to signal failed finds
//
// ******************PUBLIC OPERATIONS*********************
// Programming Assignment Part I
// bool empty( ) --> Test for empty tree @ root
// int size( ) --> Quantity of elements in tree
// int height( ) --> Height of the tree (null == -1)
// void insert( x ) --> Insert x
// void insert( vector<T> ) --> Insert whole vector of values
// void remove( x ) --> Remove x (unimplemented)
// bool contains( x ) --> Return true if x is present
// Comparable findMin( ) --> Return smallest item
// Comparable findMax( ) --> Return largest item
// boolean isEmpty( ) --> Return true if empty; else false
// void printTree( ) --> Print tree in sorted (in) order
// void printPreOrder( ) --> Print tree in pre order
// void printPostOrder( ) --> Print tree in post order
// void printInOrder( ) --> Print tree in *in* order
// Programming Assignment Part II (microassignment)
// void makeEmpty( ) --> Remove and delete all items
// void ~AvlTree( ) --> Big Five Destructor
// AvlTree(const AvlTree &other) --> BigFive Copy Constructor
// AvlTree(const AvlTree &&other) --> BigFive Move Constructor
// AvlTree &operator= ( AvlTree & other ) --> Big Five Copy *assignment* operator
// AvlTree &operator= ( AvlTree && other ) --> Big Five Move *assignment* operator
// void printLevelOrder( ) --> Print tree in LEVEL order :-)
// ******************ERRORS********************************
// Throws UnderflowException as warranted
template <typename Comparable>
class AvlTree
{
public:
/**
* Basic constructor for an empty tree
*/
AvlTree( ) : root( NULL )
{
//cout << " [d] AvlTree constructor called. " << endl;
}
/**
* Vector of data initializer (needed for move= operator rvalue)
*/
AvlTree( vector<Comparable> vals ) : root( NULL )
{
insert(vals);
}
//*******************************************************************************************
// START AVL TREES PART II - TODO: Implement
// Other functions to look for include: clone, makeEmpty, printLevelOrder
/**
* Destroy contents of the AvlTree object - Big Five Destructor
*/
~AvlTree( )
{
//cout << " [d] AvlTree Destructor called. " << endl;
// Empty out the AVL Tree and destroy all nodes (makeEmpty?)
}
/**
* Copy other to new object - Big Five Copy Constructor
*/
AvlTree( const AvlTree &other ) : root( NULL )
{
cout << " [d] Copy Constructor Called." << endl;
// Copy contents of other to ourselves (maybe clone?)
// Get a deep copy of other's tree
}
/* ...
How to do insertion sort on a singly linked list with no header usin.pdfarihantelehyb
How to do insertion sort on a singly linked list with no header using C?
Solution
/* C program for insertion sort on a linked list */
#include
#include
/* Link list node */
struct node
{
int data;
struct node* next;
};
// Function to insert a given node in a sorted linked list
void sortedInsert(struct node**, struct node*);
// function to sort a singly linked list using insertion sort
void insertionSort(struct node **head_ref)
{
// Initialize sorted linked list
struct node *sorted = NULL;
// Traverse the given linked list and insert every
// node to sorted
struct node *current = *head_ref;
while (current != NULL)
{
// Store next for next iteration
struct node *next = current->next;
// insert current in sorted linked list
sortedInsert(&sorted, current);
// Update current
current = next;
}
// Update head_ref to point to sorted linked list
*head_ref = sorted;
}
/* function to insert a new_node in a list. Note that this
function expects a pointer to head_ref as this can modify the
head of the input linked list (similar to push())*/
void sortedInsert(struct node** head_ref, struct node* new_node)
{
struct node* current;
/* Special case for the head end */
if (*head_ref == NULL || (*head_ref)->data >= new_node->data)
{
new_node->next = *head_ref;
*head_ref = new_node;
}
else
{
/* Locate the node before the point of insertion */
current = *head_ref;
while (current->next!=NULL &&
current->next->data < new_node->data)
{
current = current->next;
}
new_node->next = current->next;
current->next = new_node;
}
}
/* BELOW FUNCTIONS ARE JUST UTILITY TO TEST sortedInsert */
/* Function to print linked list */
void printList(struct node *head)
{
struct node *temp = head;
while(temp != NULL)
{
printf(\"%d \", temp->data);
temp = temp->next;
}
}
/* A utility function to insert a node at the beginning of linked list */
void push(struct node** head_ref, int new_data)
{
/* allocate node */
struct node* new_node = new node;
/* put in the data */
new_node->data = new_data;
/* link the old list off the new node */
new_node->next = (*head_ref);
/* move the head to point to the new node */
(*head_ref) = new_node;
}
// Driver program to test above functions
int main()
{
struct node *a = NULL;
push(&a, 5);
push(&a, 20);
push(&a, 4);
push(&a, 3);
push(&a, 30);
printf(\"Linked List before sorting \ \");
printList(a);
insertionSort(&a);
printf(\"\ Linked List after sorting \ \");
printList(a);
return 0;
}
/* C program for insertion sort on a linked list */
#include
#include
/* Link list node */
struct node
{
int data;
struct node* next;
};
// Function to insert a given node in a sorted linked list
void sortedInsert(struct node**, struct node*);
// function to sort a singly linked list using insertion sort
void insertionSort(struct node **head_ref)
{
// Initialize sorted linked list
struct node *sorted = NULL;
// Traverse the given linked list and insert every
// node to sorted
struct node *current = *head_ref;
while (current != NULL)
{
// Store next for next iteration
struct.
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <iterator>
/************************************************************/
// Local includes
/************************************************************/
// Using declarations
// YOU DO NOT NECESSARILY NEED TO USE ALL OF THESE!
using std::copy;
using std::copy_backward;
using std::distance;
using std::fill;
using std::ostream;
using std::ptrdiff_t;
/************************************************************/
template<typename T>
class Array
{
public:
//*****************************************************
// DO NOT MODIFY THIS SECTION!
// Some standard Container type aliases
using value_type = T;
// Iterators are just pointers to objects of type T
using iterator = value_type*;
using const_iterator = const value_type*;
using reference = value_type&;
using const_reference = const value_type&;
using size_type = size_t;
using difference_type = ptrdiff_t;
//*****************************************************
// Default ctor.
// Initialize an empty Array.
// This method is complete, and does NOT need modification.
// Remember to use a _member initialization list_ for each ctor,
// like I have below for the default ctor.
Array ()
: m_size (0),
m_capacity (0),
m_array (nullptr)
{
}
// Size ctor.
// Initialize an Array of size "pSize", with each element
// set to "value".
explicit Array (size_t pSize, const T& value = T ())
: m_size (pSize),
m_capacity (pSize),
m_array (new T[m_capacity])
{
fill (begin (), end (), value);
}
// TODO!
// Range ctor.
// Initialize an Array from the range [first, last).
// "first" and "last" must be Array iterators or pointers
// into a primitive array.
Array (const_iterator first, const_iterator last)
:m_size(distance(first,last)),m_capacity(m_size),m_array(new T[m_capacity])
{
copy(first,last,m_array);
}
// TODO!
// Copy ctor.
// Initialize this object from "a".
Array (const Array& a)
:m_size(a.m_size),m_capacity(a.m_capacity),m_array(new T[m_capacity])
{
copy(a.begin(),a.end(),m_array);
}
// TODO!
// Destructor.
// Release allocated memory.
~Array ()
{
delete[] m_array;
}
// TODO!
// Assignment operator.
// Assign "a" to this object.
// Be careful to check for self-assignment.
Array&
operator= (const Array& a)
{
if (this != &a)
{
delete[] m_array;
m_size = a.m_size;
m_capacity = a.m_capacity;
m_array = new T[m_capacity];
copy(a.begin(),a.end(),m_array);
}
return *this;
}
// Return the size.
size_t
size () const
{
return m_size;
}
// TODO!
// Return true if this Array is empty, false o/w.
bool
empty () const
{
return m_size == 0;
}
// TODO!
// Return the capacity.
size_t
capacity () const
{
return m_capacity;
}
// TODO!
// Return the element at position "index".
T& operator[] (size_t index)
{
return m_array[index];
}
// TODO!
const T& operator[] (size_t index) const
{
return m_array[index];
}
// TODO!
// Insert an element at the back.
// If the capacity is insufficient, DOUBLE it.
// If the capacity is 0, increase it to 1.
void
push_back (const T&.
Complete in JavaCardApp.javapublic class CardApp { private.pdfMAYANKBANSAL1981
Complete in Java
CardApp.java
public class CardApp {
private LinkedList list;
/**
* User interface prompts user, reads and writes files.
*/
public static void main(String[] args) {
}
/**
* Default constructor to initialize the deck
*/
public CardApp() {
}
/**
* Inserts a new Card into the deck
* @param card a playing Card
*/
public void addCard(Card card) {
}
/**
* Shuffles cards following this algorithm:
* First swaps first and last card
* Next, swaps every even card with the card 3
* nodes away from that card. Stops when it
* reaches the 3rd to last node
* Then, swaps ALL cards with the card that is
* 2 nodes away from it, starting at the 2nd card
* and stopping stopping at the 3rd to last node
*/
public void shuffle() {
}
/**
* Implements the bubble sort algorithm
* to sort cardList into sorted order, first by suit
* (alphabetical order)
* then by rank from 2 to A
*/
public void sort() {
}
/**
* Returns the deck of cards with each card separated
* by a blank space and a new line character at the end.
* @return The deck of cards as a string.
*/
@Override public String toString() {
return "";
}
}
Card.java
public class Card implements Comparable{
private String rank;
private String suit;
/**
* Constructor for the Card class
* @param rank the rank of card from 2 to A
* @param suit the suit of card C, D, H, or S
*/
public Card(String rank, String suit) {
}
/**
* Returns the card's rank
* @return rank a rank from 2 (low) to A (high)
*/
public String getRank() {
return "";
}
/**
* Returns the card's suit
* @return C, D, H, or S
*/
public String getSuit() {
return "";
}
/**
* Updates the card's rank
* @param rank a new rank
*/
public void setRank(String rank) {
}
/**
* Updates the card's suit
* @param suit the new suit
*/
public void setSuit(String suit) {
}
/**
* Concatenates rank and suit
* @return card rank and suit
*/
@Override public String toString() {
return "";
}
/**
* Overrides the equals method for Card
* Compares rank and suit and
* follows the equals formula given in
* Lesson 4 and also in Joshua Block's text
* @param obj another Object to compare for
* equality
* @return whether obj is a Card and, if so,
* of equal rank and suit
*/
@Override public boolean equals(Object obj) {
return false;
}
/**
* Orders two cards first by suit (alphabetically)
* Next by rank. "A" is considered the high card
* Order goes 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A
* @param card another Card to compare to this Card
* @return a negative number if this comes before c
* and a positive number if c comes before this
* and 0 if this and c are equal according to the above
* equals method
*/
@Override public int compareTo(Card card) {
return -1;
}
}
}
LinkedList.Java
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 iterato.
Given BinaryNode.javapackage util;import java.util.;T.pdfConint29
Given BinaryNode.java
package util;
import java.util.*;
/*
This class implements Binary Node for Binary Trees
Methods:
I) Two constructors
II) Two toString methods
III) height and size methods
IV) preorder, postorder, and inorder traversals
V) BFS and DFS traversal
*/
public class BinaryNode {
public E element;//data
public BinaryNode left;//left child
public BinaryNode right;//right child
//constructor for leaves
public BinaryNode(E element) {
this(element, null, null);
}
//constructor for internal nodes
public BinaryNode(E element, BinaryNode left, BinaryNode right) {
this.left = left;
this.right = right;
this.element = element;
}
public String toString2() {
if (left == null && right == null)//base case
return element + "";
return element + "(" + left + ", " + right + ")";
}
public int height() {
if (left == null && right == null)
return 0;
if (left == null)
return 1 + right.height();
if (right == null)
return 1 + left.height();
return 1 + Math.max(left.height(), right.height());
}
public int size() {
int size = 1;//counting root
if (left != null)//counting left subtree nodes
size += left.size();
if (right != null)//counting right subtree nodes
size += right.size();
return size;
}
public void printPreOrder() {
System.out.print(element + " ");
if (left != null)
left.printPreOrder();
if (right != null)
right.printPreOrder();
}
public void printPostOrder() {
if (left != null)
left.printPostOrder();
if (right != null)
right.printPostOrder();
System.out.print(element + " ");
}
public void printInOrder() {
if (left != null)
left.printInOrder();
System.out.print(element + " ");
if (right != null)
right.printInOrder();
}
public void printBFS() {//breadth first search traversal - non-recursive method
Queue q = new LinkedList<>();
q.add(this);
while (!q.isEmpty()) {
BinaryNode cur = q.remove();
System.out.print(cur.element + " ");
if (cur.left != null)
q.add(cur.left);
if (cur.right != null)
q.add(cur.right);
}
}
public void printDFS() {//depth first search traversal - equivalent to pre-order traversal
Stack stack = new Stack<>();
stack.add(this);
while (!stack.empty()) {
BinaryNode cur = stack.pop();
System.out.print(cur.element + " ");
if (cur.right != null)
stack.push(cur.right);
if (cur.left != null)
stack.push(cur.left);
}
}
public String toString() {
if (left == null && right == null && element == null)
return "";
Queue list = new LinkedList<>();
String result = "";
list.add(this);
list.add(null);
int level = (int) Math.pow(2, height());
BinaryNode dummy = new BinaryNode(null);
while (!list.isEmpty()) {
boolean allDummies = true;
for (BinaryNode b : list)
if (b != dummy && b != null) {
allDummies = false;
break;
}
BinaryNode cur = list.remove();
if (cur == null || allDummies)
break;
for (int i = 0; i < level - 1; i++)
result += '\t';
if (cur != dummy)
result += cur.element;
for (int i = 0; i < level + 1; i++)
result += '\t';
if (cur.left != null)
list.add(cur.left);
else
list.add(dummy);
if (cur.right != null)
list.add(cur.right);
else
list.add.
Domain Description for the Lunar Rover Back in July 30th 1971, the c.pdfConint29
Domain Description for the Lunar Rover: Back in July 30th 1971, the crew of Apollo 15
reached the moon surface. The first American astronaut reached the moon along with his team.
But they needed a mean of transportation. Their solution: A lunar buggy called Lunar Rover that
could travel speeds up to 12 km/h. This was an awesome opportunity for astronauts to travel long
distances outside Earth, but there were some technological constraints 45 years ago. The Lunar
Roving Vehicle could had only two pedals and two buttons to control the vehicles systems.
Moon Roover Movement Control: Engineers had to be creative in order to add all the
functionality need for a lunar cruise, so they came up with the following ideas: When the left
pedal was pressed once it accelerates the buggy forward. If accelerating forward and you press
right pedal once, it deaccelerates. To achieve constant forward speed press the right pedal for
more than 3 seconds. If the buggy is at rest and the left pedal is pressed for more than 3 seconds,
it will accelerate backwards. Part 1 Design a state machine to model the Movement Control as
described above. Note: The description above is not complete. Your task includes filling in these
missing details. Make sure to write down any assumptions you make as you develop the state
machine model. Part 2- Camera & Drill (Bonus 4 points): The coolest feature of the buggy
was not its speed but rather the color television camera, the 16-mm camera, and the drill. The
control was packed inside a television control unit. The only problem was that the cameras, and
the lunar rover drill were also controlled by the same control unit. So again engineers used the
two button controller to manipulate all devices: Press the button 1 for five seconds to interact
with the color camera. Press the button 1 for ten seconds to interact with the 16-mm camera.
Press button 1 twice to interact with the drill. Pressing button 2 at any of these modes return to
idle state. In any of the two camera modes, pressing button 1 takes a picture, while if pressed for
5 seconds activates the temporizer (moon selfies). Last inside the drill mode button 1 only acted
as an on off switch. Design a state machine to model the Camera and Drill. Extend the model
you developed for the movement control (2 points). Provide an implementation for this extended
state machine in Java (2 points). Every state should implement an entry action that prints on the
console the current state..
Design a PIC based wearable device that keeps a tract of the activit.pdfConint29
Design a PIC based wearable device that keeps a tract of the activity level of a user. The level of
movement should be classed as: immobile, relatively mobile (walking), highly mobile (HIIT). If
the user has been immobile for a set amount of time, the device should sound an alarm
prompting him to move and only stop when it detects movement. In the mobile state, the device
should count the number of steps taken, and store the number and the length of time in that
activity state. If the number of steps is more than 10, it should be recorded as an exercise session.
The user should be able see a full report of the activities done at the end of the day, including the
details of each session in the mobility states. An additional spec can be to record and display the
time of day the sessions were done..
Describe any five (5) advantages of computer networkingList any (5) ex.pdfConint29
Describe any five (5) advantages of computer networkingList any (5) examples of search engines
besides GoogleList any five (5) examples of presentation software besides MS PowerPoint,
Google Slides Differentiate between the following terms
a).WAN and WLAN
b).Fiber Cable and ethernet cable
c).Scalability and
aggregation
d).A Repeater and a bridge
c).Bluetooth
and Wi-Fi.
I am looking for some assistance with SQLite database. I have tried se.pdfConint29
I am looking for some assistance with SQLite database. I have tried several other scenarios to no
avail. I am looking to have a table in my activity_weight_table.xml, I'm thinking recyclerview
but not sure. Also, I would need help with my login and password checking it agaisnt a database
and having these screens work together. My database should be able to Create: The user should
be able to add items to a database. Delete: The user should be able to remove items from a
database. Update: The user should be able to change the value associated with individual
database items (e.g. the number of a specific item in an inventory or the date of an event). Read:
The user should be able to view all of the database items displayed as a grid. These are my
following Java codes: MainActivity.java package com.example.weight; import
android.content.Intent; import android.os.Bundle; import android.widget.Button; import
android.widget.EditText; import androidx.appcompat.app.AppCompatActivity; public class
MainActivity extends AppCompatActivity { Button button_login, createAccount; EditText
loginUserName, loginPassword; @Override protected void onCreate(Bundle
savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login_weight); button_login =
findViewById(R.id.button_login); loginPassword = findViewById(R.id.loginPassword);
loginUserName = findViewById(R.id.loginUserName); createAccount =
findViewById(R.id.createAccount); createAccount.setOnClickListener((view) -> {
Intent intent = new Intent(MainActivity.this, CreateAccountActivity.class);
startActivity(intent); }); button_login.setOnClickListener((view) -> { Intent
intent = new Intent(MainActivity.this, LoginActivity.class); startActivity(intent); });
} } DatabaseHelper.java package com.example.weight; import android.content.Context;
import android.database.sqlite.SQLiteDatabase; import
android.database.sqlite.SQLiteOpenHelper; public class DatabaseHelper extends
SQLiteOpenHelper { private static final String DATABASE_NAME = "UserAccounts.db";
private static final int DATABASE_VERSION = 1; public static final String
TABLE_USERS = "users"; public static final String COLUMN_ID = "id"; public static
final String COLUMN_USERNAME = "username"; public static final String
COLUMN_PASSWORD = "password"; private static final String TABLE_CREATE =
"CREATE TABLE " + TABLE_USERS + " (" + COLUMN_ID + " INTEGER
PRIMARY KEY AUTOINCREMENT, " + COLUMN_USERNAME + " TEXT, "
+ COLUMN_PASSWORD + " TEXT)"; public DatabaseHelper(Context
context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); }
@Override public void onCreate(SQLiteDatabase db) {
db.execSQL(TABLE_CREATE); } @Override public void onUpgrade(SQLiteDatabase
db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " +
TABLE_USERS); onCreate(db); } } LoginActivity.java package com.example.weight;
import android.content.Intent; import android.database.Cursor; import
android.database.sqlite.SQLiteDatabase; import an.
How do I declare the following constructors in my .h file Below.pdfConint29
How do I declare the following constructors in my .h file?
Below was the original code.
\#include const int CAPACITY =1024; using namespace std; typedef int ElementType; // Now
"ElementType" is "int" L//can change int to double, char,... class List \{ public: List();
//constructor unsigned size() const; bool empty() const; //check if empty void
insert(ElementType item, int pos); //insertion void erase(int pos); //deletion void
display(ostream\& out) const; //display every item ElementType get(unsigned pos) const;
private: int mySize; // current \# of items in list int myArray[CAPACITY]; No issues found 4
Error List Entire
Solution
(i) 0 Messages Q7 Build + IntelliSense " Code Description abc E0135 class "List" has no
member "removeAll" abc E0020 identifier "myArray" is undefined abc E0020 identifier
"mySize" is undefined abc E0020 identifier "mySize" is undefined abc E0493 no instance of
overloaded function "List::List" matches the specified type
\#include \#include cstdlib> \#include "list.h" using namespace std; void List: :
insert(ElementType item, int pos) \{ if (mySize == CAPACITY) exit(1); if (pos< 0|| pos >
mysize) return; // shift array elements right to make room for for (int i= mysize; i> pos; i )
myArray[i]=myArray[i1]; // insert item at pos and increase list size myArray [pos] = item;
mySize++; // don't forget this! \} void List: :erase(int pos) \{ if (pos<0 || pos >= mySize) return;
// shift array elements left for (int i= pos; i < mysize-1; i++ ) myArray[i]=myArray[i+1]; \}
mySize--; // don't forget this! List: : List( ) \{ mySize =0; \} bool List: :empty() const \{ return
(mySize ==0 ); \} unsigned List::size() const \{ return mysize; \} ElementType List:
:get(unsigned pos) const \{ if (pos >= mysize) \{ cerr "Invalid Index." endl; exit(1); \} return
myArray[pos]; \} void List: : display(ostream \& out) const \{ for (int i=0; i.
Here I have a function in my code that checks the separation of airc.pdfConint29
Here I have a function in my code that checks the separation of aircraft when called and returns
either no separation issues if the predicted paths of all other aircraft (stored in an expandable
array) does not intersect with the minimum distance circle around the current one when
comparing their relative position and velocity. it doesn't work though and I'm really confused as
to what is wrong. I can send the rest of the code through if required
void check_separation(ADSBPacket *plane, int planes_info)
{
int num = -1;
for(int i = 0; i < planes_info; i++)
{
if(plane[planes_info].id == plane[i].id)
{ num = i; break;
}
}
int original_time = (plane[num].hours * 3600) + (plane[num].minutes * 60); int new_time =
(plane[planes_info].hours * 3600) + (plane[planes_info].minutes * 60);
int time_change = new_time - original_time;
double distance = plane[num].speed * time_change / 1000; double angle = plane[num].heading *
M_PI / 180;
double east_change = distance * cos(angle);
double north_change = distance * sin(angle); plane[planes_info].north = plane[num].north +
north_change;
plane[planes_info].east = plane[num].east + east_change;
plane[planes_info].heading = plane[num].heading;
for(int i = 0; i < planes_info; i++)
{
int original_time = (plane[num].hours * 3600) + (plane[num].minutes * 60);
int new_time = (plane[planes_info].hours * 3600) + (plane[planes_info].minutes * 60);
int time_change = new_time - original_time;
double distance = plane[i].speed * time_change / 1000;
double angle = plane[i].heading * M_PI / 180;
double east_change = distance * cos(angle);
double north_change = distance * sin(angle);
plane[planes_info].north = plane[i].north + north_change;
plane[planes_info].east = plane[i].east + east_change;
plane[planes_info].heading = plane[num].heading;
double delta_p_north = plane[planes_info].north - plane[num].north;
double delta_p_east = plane[planes_info].east - plane[num].east;
double delta_v_north = (plane[planes_info].speed * sin(plane[i].heading)) - (plane[num].speed *
sin(plane[i].heading));
double delta_v_east = (plane[planes_info].speed * cos(plane[i].heading)) - (plane[num].speed *
cos(plane[i].heading));
double a = (delta_v_east * delta_v_east) + (delta_v_north * delta_v_north);
double b = 2 * ((delta_v_north * delta_p_north) + (delta_v_east * delta_p_east));
double separation = 100; double c = (delta_p_north * delta_p_north) + (delta_p_east +
delta_p_east) - (separation * separation);
if((b * b)- (4 * a * c) >= 0)
{
printf("Separation issue\n"); break; }
}
printf("No separation issues\n");
}.
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.
Exchange Rate Determination Theory OvershootingExchange rate over.pdfConint29
Exchange Rate Determination Theory: Overshooting
Exchange rate overshooting refers to the process in which the movement of the exchange rate
reacts more than the long-term equilibrium state in the short run when a currency volume shock
occurs.
Answer the following questions.
(1) Illustrate and explain the short-term and long-term effects of the increase in the home
country's money supply on the local currency volume, the local interest rate, and the exchange
rate (the Korean won's exchange rate against the dollar) in a two-country model in which both
countries (Korea) and foreign (US) exist.
(2) In the problem above (1), picture the movement of nominal currency volume, price level,
interest rate, exchange rate, and real currency volume over time (i.e., time path) after the
domestic currency volume was moderate..
Encapsulating method details in a class [ Choose ] instance vari.pdfConint29
Encapsulating method details in a class
[ Choose ] instance variables implementation hiding methods signature data fields extended
dead code mutator method accessor method return statement static method formal parameters
new operator parameter type class user header
The combination of the method name and the number, types, and order of arguments
[ Choose ] instance variables implementation hiding methods signature data fields extended
dead code mutator method accessor method return statement static method formal parameters
new operator parameter type class user header
Method that retrieves a value
[ Choose ] instance variables implementation hiding methods signature data fields extended
dead code mutator method accessor method return statement static method formal parameters
new operator parameter type class user header
Unreachable statements that can never execute
[ Choose ] instance variables implementation hiding methods signature data fields extended
dead code mutator method accessor method return statement static method formal parameters
new operator parameter type class user header
Variables in the method declaration that accept the values from the actual parameters
[ Choose ] instance variables implementation hiding methods signature data fields extended
dead code mutator method accessor method return statement static method formal parameters
new operator parameter type class user header
Allocates memory for an object
[ Choose ] instance variables implementation hiding methods signature data fields extended
dead code mutator method accessor method return statement static method formal parameters
new operator parameter type class user header
Classes that can be used as the basis for any other class
[ Choose ] instance variables implementation hiding methods signature data fields extended
dead code mutator method accessor method return statement static method formal parameters
new operator parameter type class user header
An application or a class that instantiates objects of another prewritten class
[ Choose ] instance variables implementation hiding methods signature data fields extended
dead code mutator method accessor method return statement static method formal parameters
new operator parameter type class user header
Variables you declare within a class, but outside of any method
[ Choose ] instance variables implementation hiding methods signature data fields extended
dead code mutator method accessor method return statement static method formal parameters
new operator parameter type class user header
Method that sets or changes field values
[ Choose ] instance variables implementation hiding methods signature data fields extended
dead code mutator method accessor method return statement static method formal parameters
new operator parameter type class user header
Are called class methods
[ Choose ] instance variables implementation hiding methods signature data fields extended
dead code mutator method accessor method return state.
Hello. I need help with my assignment. Translate the ER Diagram for .pdfConint29
Hello. I need help with my assignment. Translate the ER Diagram for the Animal Pet Rescue
Database
Entities:
Donator
DonatorID (Primary Key)
Name
Address
Phone Number
Email
2. Pet
PetID (Primary Key)
Name
Type
Age
DonatorID (Foreign Key)
3. Staff
StaffID (Primary Key)
Name
Email
Phone Number
Employee Number
CenterID (Foreign Key)
4. Center
CenterID (Primary Key)
Name
Location
Phone
Contact Person
Email
5. Rescuer
RescuerID Primary Key)
Name
Email
Phone Number
Home Address
Internal ID
6. Transportation
TransportationID (Primary Key)
Vehicle Type
Pickup Point
Delivery Point
7. Pickup Schedule
PickupID (Primary Key)
DonatorID (Foreign Key)
StaffID (Foreign Key)
TransportationId (Foreign Key)
Pickup Date Time
8. Delivery Schedule
DeliveryID (Primary Key)
RescuerID (Foreign Key)
StaffID ( Foreign Key)
TransportID (Foreign Key)
Delivery Date Time
Relationships:
Donator to pet (One-to-many):
One donor can donate multiple Pets.
Pet has a foreign Key (DonatorID) to link to the Donator.
Center to Staff (One-to -Many):
One Center can have multiple staff members.
Staff has a foreign key (CenterID) to link to the center.
Rescuer to pickup Schedule(One-to-Many):
One rescuer can be scheduled for multiple pickups.
Pickup Schedule has a foreign key (RescuerID) to link to the Rescuer.
Staff to pickup Schedule One-to-Many):
One Staff member can schedule multiple pickups.
Pickup Schedule has a Foreign Key (StaffID) to link to the staff.
Transport to Pickup Schedule(One-to-many):
One Transportation can be associated with multiple pickups.
Pickup Schedule has a foreign key (TransportID) to link to the Transportation.
Rescuer to Delivery Schedule (One-to-Many):
One rescuer can be scheduled for multiple deliveries.
Delivery schedule has a foreign key (RescuerID) to link to the rescuer.
Staff to Delivery Schedule(One-to-Many):
One Staff member can schedule multiple deliveries.
Delivery schedule has a foreign key (StaffID) to link to the staff.
Transport to Delivery Schedule (One-to-Many):
One Transportation can be associated with multiple deliveries.
Delivery Schedule has a Foreign Key (TransportID)to link to the Transportation..
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
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.
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.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
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”.
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?
The Art Pastor's Guide to Sabbath | Steve Thomason
Fix my codeCode.pdf
1. Fix my code:
Code:
/***************************************************************************
* A Linked List class with a private static inner Node class.
*
*****************************************************************************/
import java.util.*;
public class MySingleLinkedList
{
private Node head;
/**
* Constructs an empty list
*/
public MySingleLinkedList()
{
head = null;
}
/**
* Returns true if the list is empty
* @return true/false - empty/not empty
*/
public boolean isEmpty()
{
return head == null;
}
/**
* Inserts a new node at the beginning of this list.
* @param item - element to add
*
2. */
public void addFirst(E item)
{
head = new Node(item, head);
}
/**
* Returns the first element in the list.
* @return the head of the list
* @exception NoSuchElementException if an empty list
*/
public E getFirst()
{
if(head == null) throw new NoSuchElementException();
return head.data;
}
/**
* Removes the first element in the list.
* @return head of the list
*
*/
public E removeFirst()
{
E tmp = getFirst();
head = head.next;
return tmp;
}
/**
* Inserts a new node to the end of this list.
* @param item - the element to add at the end of list
*/
public void addLast(E item)
{
3. if( head == null)
addFirst(item);
else
{
Node tmp = head;
while(tmp.next != null) tmp = tmp.next;
tmp.next = new Node(item, null);
}
}
/**
* Removes all nodes from the list.
*
*/
public void clear()
{
head = null;
}
/**
* Inserts a new node after the first appearance of the node containing the key
* @param key - the data of existing node included in the list
* @param toInsert - the data of the new node to be inserted
*/
public void insertAfter(E key, E toInsert)
{
Node tmp = head;
while(tmp != null && !tmp.data.equals(key))
tmp = tmp.next;
if(tmp != null)
tmp.next = new Node(toInsert, tmp.next);
}
4. /*
* ================================ The following functions need to be filled
===================================================
*
*/
/**
* Returns the last element in the list.
* @return last element in the list
* @throws NoSuchElementException if the list is empty
*/
public E getLast()
{
// TODO: please fill your code here.
Node tmp = head;
while(tmp.next != null) {
tmp = tmp.next;
}
return tmp.data;
}
/**
* Returns true if this list contains the specified element.
* @param item - element to be checked
* @return True - if contained; otherwise False
*
*/
public boolean contains(E item)
{
5. Node tmp = head;
while (tmp != null && !tmp.data.equals(item))
tmp = tmp.next;
if (tmp.data.equals(item) ) {
return true;
}
return false;
}
/**
* Returns the data at the specified position in the list.
* @param the position index
* @return the data contained at the given position index
* @throws IndexOutOfBoundsException if pos is larger than the size of list
*
*/
public E get(int pos)
{
Node tmp = head;
int i = 0;
while (i < pos) {
i++;
tmp = tmp.next;
}
return tmp.data;
}
/**
* Inserts a new node before the first appearance of the node containing the key.
* @param key the data of existing node included in the list
6. * @param toInsert the data of the new node to be inserted
*
*/
public void insertBefore(E key, E toInsert)
{
Node pre = null;
Node cur = head;
while (!cur.data.equals(key))
{
pre = cur;
cur = cur.next;
}
if (cur != null)
pre.next = new Node(toInsert, cur);
}
/**
* Removes the first occurrence of the specified element in this list.
* @param key - the element to be removed
*
*/
public void remove(E key)
{
7. }
/*************************** Extra Credit Exercises
*****************************************/
/***** This is for Extra Credit (5 points) *********************
/**
* Reverses the list: A->B->C to C->B->A
* @return the new head
*/
public Node reverse()
{
// TODO: please fill your code here.
return null; //remove this line after your implementation
}
/*
* ================================ The end of functions need to be filled
===================================================
*
*/
/*******************************************************
*
* The Node class
*
********************************************************/
private static class Node
8. {
private E data;
private Node next;
public Node(E data, Node next)
{
this.data = data;
this.next = next;
}
}
}
TESTER DO NOT CHANGE:
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import java.util.*;
public class TestMySingleyLinkedList
{
private MySingleLinkedList empty ;
private MySingleLinkedList one ;
private MySingleLinkedList several ;
@Before
public void setUp()
{
empty = new MySingleLinkedList() ;
one = new MySingleLinkedList() ;
one.addFirst(0);
several = new MySingleLinkedList() ;
several.addFirst(2) ;
several.addFirst(1) ;
several.addFirst(0) ;
}
@Test(expected = NoSuchElementException.class)