Introduction and Background
In recent lectures we discussed using arrays, classes and interfaces (see newly added course
notes if you want to read ahead about interfaces – we will cover them this week in lecture). In
this lab you will utilize all of these topics to build a simple yet useful new class. Consider the
following interface describing the methods for a simple double ended queue (or deque):
public interface SimpleDeque
{
public void addFront(Object X); // Add Object X at front of list
public void addRear(Object X); // Add Object X at rear of list
// If array is full, add methods should do nothing
public Object removeFront(); // Remove and return Object X from
// front of list
public Object removeRear(); // Remove and return Object X from
// rear of list
// If array is empty, remove methods should return null
public boolean isEmpty(); // Return true if the list is empty
// Return false otherwise
}
A queue has the behavior such that items are added at the rear and removed from the front,
thereby giving a First In First Out (FIFO) access to the items added and subsequently removed
from the list. No other manipulations of the data are permitted (for example, we cannot add or
remove anywhere in the middle). Looking at it \"in reverse\", we could add new items at the
front of the queue and remove them from the rear. This is still providing FIFO access, but just
from a different point of view. Now consider both adding and removing items at the rear of the
list (without ever accessing the front). This is called stack access and gives us Last In First Out
(LIFO) access to the items (the data is removed in reverse order). The same behavior occurs if
we both add and remove at the front without ever accessing the rear of the list.
The simple deque above is expressed as an interface rather than a class, because we are not
describing the data or how it is represented -- we are simply describing its access behavior.
However, to actually build a working deque, we need a class that implements the interface
above. For example:
public class MyDeque implements SimpleDeque
{
Object [] theData;
int numItems;
public MyDeque(int maxItems)
{
theData = new Object[maxItems];
numItems = 0;
}
// Implementation of the five methods of SimpleDeque, plus
// perhaps other methods as well
}
Note that the implementation above uses an array of Object to store the items in the deque. Since
Object is the base class to all other Java classes, an array of Object can thus be used to store any
Java class types (we can even store primitive values if we utilize their wrapper classes). Also
note that nothing in the SimpleDeque interface requires an array to be used to store the data. You
will see in your CS 0445 course that a linked list may in fact be a better implementation than an
array in this case. However, for this implementation we will use an array because it is simple and
easy to understand.
Another important thing to notice about the partial implementation above is tha.
project2/.classpath
project2/.project
project2
linklist
org.eclipse.jdt.core.javabuilder
org.eclipse.jdt.core.javanature
project2/bin/project2/emplist.classpackage project2;
publicsynchronizedclass emplist {
public void emplist();
publicstatic void main(String[]) throws java.io.IOException;
}
project2/bin/project2/method1.classpackage project2;
publicsynchronizedclass method1 {
java.util.LinkedList newList;
public void method1();
void reverse(java.util.LinkedList);
void downsize(java.util.LinkedList, int);
}
project2/employees.txt
Ahmed
Bill
Diana
Harry
Juliet
Nina
Romeo
Sam
Tom
Zack
project2/src/project2/emplist.javaproject2/src/project2/emplist.javapackage project2;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.ListIterator;
publicclass emplist {
publicstaticvoid main(String[] args)throwsIOException{
// TODO Auto-generated method stub
LinkedList<String> linkedlist =newLinkedList<String>();
method1 obj =new method1();
System.out.println("\t\t\t********************************************************");
System.out.println("\t\t\t********* This Program was written by ziyad **********");
System.out.println("\t\t\t********************************************************");
try(BufferedReader br =newBufferedReader(newFileReader(
"employees.txt"))){
String sCurrentLine;
while((sCurrentLine = br.readLine())!=null){
// System.out.println(sCurrentLine);
linkedlist.add(sCurrentLine);
// System.out.println(linkedlist);
}
String firstElement = linkedlist.get(0);
String lastElement = linkedlist.getLast();
System.out.println("\tDisplaying List contentusing traditional for loop");
for(int i =0; i < linkedlist.size(); i++){
System.out.println("Name of Emp is "+ linkedlist.get(i));
}
System.out.println("The first element of the List: "+ firstElement);
System.out.println("The last element of the List: "+ lastElement);
System.out.println("The size of the list after removing the last element Zack is: 9");
System.out.println("\tDisplaying using by using enhances for loop: ");
for(int a =0; a < linkedlist.size(); a++){
System.out.println(linkedlist.get(a));
}
ListIterator iter = linkedlist.listIterator();
while(iter.hasNext()){
int i = iter.nextIndex();
iter.next();
// System.out.println(iter.next() + " is at index" + i);
if(i ==0){
System.out.println("The current emplyee after advancing the iter five timers is: "
+ iter.previous());
Object element = iter.next();
iter.add("kelly");
// iter.set( "Kelly");
int k =0;
// while( k < linkedlist.size())
{
System.out.println("\tDisplaying list after inserting Kelly after the fifth position\n"+ linkedlist +" ");
k++;
}
}elseif(i ==6){
System.out.println("\tDisplaying list after setting the current element to Nancy"+ iter.previous());
Object element1 = iter.next();
.
project2/.classpath
project2/.project
project2
linklist
org.eclipse.jdt.core.javabuilder
org.eclipse.jdt.core.javanature
project2/bin/project2/emplist.classpackage project2;
publicsynchronizedclass emplist {
public void emplist();
publicstatic void main(String[]) throws java.io.IOException;
}
project2/bin/project2/method1.classpackage project2;
publicsynchronizedclass method1 {
java.util.LinkedList newList;
public void method1();
void reverse(java.util.LinkedList);
void downsize(java.util.LinkedList, int);
}
project2/employees.txt
Ahmed
Bill
Diana
Harry
Juliet
Nina
Romeo
Sam
Tom
Zack
project2/src/project2/emplist.javaproject2/src/project2/emplist.javapackage project2;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.ListIterator;
publicclass emplist {
publicstaticvoid main(String[] args)throwsIOException{
// TODO Auto-generated method stub
LinkedList<String> linkedlist =newLinkedList<String>();
method1 obj =new method1();
System.out.println("\t\t\t********************************************************");
System.out.println("\t\t\t********* This Program was written by ziyad **********");
System.out.println("\t\t\t********************************************************");
try(BufferedReader br =newBufferedReader(newFileReader(
"employees.txt"))){
String sCurrentLine;
while((sCurrentLine = br.readLine())!=null){
// System.out.println(sCurrentLine);
linkedlist.add(sCurrentLine);
// System.out.println(linkedlist);
}
String firstElement = linkedlist.get(0);
String lastElement = linkedlist.getLast();
System.out.println("\tDisplaying List contentusing traditional for loop");
for(int i =0; i < linkedlist.size(); i++){
System.out.println("Name of Emp is "+ linkedlist.get(i));
}
System.out.println("The first element of the List: "+ firstElement);
System.out.println("The last element of the List: "+ lastElement);
System.out.println("The size of the list after removing the last element Zack is: 9");
System.out.println("\tDisplaying using by using enhances for loop: ");
for(int a =0; a < linkedlist.size(); a++){
System.out.println(linkedlist.get(a));
}
ListIterator iter = linkedlist.listIterator();
while(iter.hasNext()){
int i = iter.nextIndex();
iter.next();
// System.out.println(iter.next() + " is at index" + i);
if(i ==0){
System.out.println("The current emplyee after advancing the iter five timers is: "
+ iter.previous());
Object element = iter.next();
iter.add("kelly");
// iter.set( "Kelly");
int k =0;
// while( k < linkedlist.size())
{
System.out.println("\tDisplaying list after inserting Kelly after the fifth position\n"+ linkedlist +" ");
k++;
}
}elseif(i ==6){
System.out.println("\tDisplaying list after setting the current element to Nancy"+ iter.previous());
Object element1 = iter.next();
.
In java , I want you to implement a Data Structure known as a Doubly.pdfaromalcom
In java , I want you to implement a Data Structure known as a Doubly-Ended-Queue. it is a
“fair” data structure in that it implements a FIFO (First In First Out ) behavior. As such, it is
often used to implement various wait lists in computer systems. For example, jobs waiting to use
the CPU, jobs waiting for a printer, jobs waiting to be placed into RAM for execution. In short,
whenever we want a fair strategy for waiting we use queues.
A DEQUE (Doubly-ended-queue) is a related data structure. Although similar to a Queue, it
differs in that it allows for insertions AND deletions from either end of the list (both the front
and the rear).
Your implementation MUST use a doubly-linked-list implementation. You may not use a static
array implementation.
Thus, a Deque is a List but it is one which only concerns itself with the first and last positions for
any insertion or deletion. The 6 operations supported are :
public void insertFront( int item ) - insert the given item (as a node) into the first position of the
Deque.
public void insertRear( int item ) - insert the given item (as a node) into the last position of the
Deque.
public int deleteFront( ) - delete and return the element stored in the first node of the Deque.
public int deletRear( ) – delete and return the element stored in the last node of the Deque.
public boolean isempty( ) - returns true if the Deque is currently empty or false if it is not.
public void printDeque( ) - print the integers from the list, one per line, from the first element
through to the last in order.
Classes
Your program must implement the following 3 classes. public class dequeDriver
This class will contain your program’s main method. It will need to declare a deque object and
process input as indicated below.
Your program should prompt the user for the path of an input file. It should open the file for
input and process it line by line. Each line of the input file will have one of the following forms.
PR
IF
IR
DF
DR
The meanings of each input is as follows:
PR - print the current contents of the deque from front to rear using the printDeque( ) method of
the deque object.
IF - insert the given int value into the front of the deque.
IR - insert the given int value into the rear of the deque.
DF - delete the front value from the deque.
DR – delete the rear element of the deque.
Below is an example input file that your program should be able to process.
PR
IF 4
IF 5
IF 6
IR 7
PR
DR
PR
DF
PR
The output for the input file shown above is :
EMPTY DEQUE
----- Front -----
6
5
4
7
----- Rear -----
----- Front -----
6
5
4
----- Rear -----
----- Front -----
5
4
----- Rear -----
public class dequeNode
This class will implement the linked nodes that will be used to implement the deque itself.
It should have the following protected data members.
protected dequeNode next; // next pointer to next node
protected dequeNode prev; // previous pointer to previous node
protected int val; // the integer value stored within the dequeNod.
Collections and its types in C# (with examples)Aijaz Ali Abro
Learn step by step c# collections with easy examples. Learn generic, non-generic and specialized collections along with easy and great examples. Learn about arraylist, queue class,stack class and more. Difference between generic and non-generic collections. Difference between arraylist and simple array.
Data Structure Introduction
Data Structure Definition
Data Structure Types
Data Structure Characteristics
Need for Data Structure
Stack Definition
Stack Representation
Stack Operations
Stack Algorithm
Program for Stack in C++
Linked List Definition
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
Linked List Defination
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
JAVA A double-ended queue is a list that allows the addition and.pdfamrishinda
**JAVA** A double-ended queue is a list that allows the addition and removal of items from
either end. One end is arbitrarily called the front and other the rear, but the two ends behave
identically. Specify, design and implement a class for a double-ended queue. Include operations
to check if it is empty and to return the number of items in the list. For each end, include
operations for adding and deleting items. Use doubly linked list for your implementation. Call
your class Deque (pronounced \"deck\").
Solution
//package com.java2novice.ds.queue;
public class DequeDblLinkedListImpl {
private LinkedNode front;
private LinkedNode rear;
public void insertFront(T item){
//add element at the beginning of the queue
System.out.println(\"adding at front: \"+item);
LinkedNode nd = new LinkedNode();
nd.setValue(item);
nd.setNext(front);
if(front != null) front.setPrev(nd);
if(front == null) rear = nd;
front = nd;
}
public void insertRear(T item){
//add element at the end of the queue
System.out.println(\"adding at rear: \"+item);
LinkedNode nd = new LinkedNode();
nd.setValue(item);
nd.setPrev(rear);
if(rear != null) rear.setNext(nd);
if(rear == null) front = nd;
rear = nd;
}
public void removeFront(){
if(front == null){
System.out.println(\"Deque underflow!! unable to remove.\");
return;
}
//remove an item from the beginning of the queue
LinkedNode tmpFront = front.getNext();
if(tmpFront != null) tmpFront.setPrev(null);
if(tmpFront == null) rear = null;
System.out.println(\"removed from front: \"+front.getValue());
front = tmpFront;
}
public int size(){
if(front == null && rear ==null){
return 0;
}
//remove an item from the beginning of the queue
LinkedNode tmpFront = front;
LinkedNode tmpRear = rear;
int i=0;
while(tmpFront != rear)
{
i++;
tmpFront=tmpFront.getNext();
}
i++;
return i;
}
public void removeRear(){
if(rear == null){
System.out.println(\"Deque underflow!! unable to remove.\");
return;
}
//remove an item from the beginning of the queue
LinkedNode tmpRear = rear.getPrev();
if(tmpRear != null) tmpRear.setNext(null);
if(tmpRear == null) front = null;
System.out.println(\"removed from rear: \"+rear.getValue());
rear = tmpRear;
}
public static void main(String a[]){
DequeDblLinkedListImpl deque = new DequeDblLinkedListImpl();
deque.insertFront(34);
deque.insertFront(67);
System.out.println(\"Size of the queue : \"+deque.size());
deque.insertFront(29);
deque.insertFront(765);
deque.removeFront();
deque.removeFront();
deque.removeFront();
deque.insertRear(43);
deque.insertRear(83);
deque.insertRear(84);
deque.insertRear(546);
deque.insertRear(356);
deque.removeRear();
deque.removeRear();
deque.removeRear();
deque.removeRear();
deque.removeFront();
deque.removeFront();
deque.removeFront();
}
}
class LinkedNode{
private LinkedNode prev;
private LinkedNode next;
private T value;
public LinkedNode getPrev() {
return prev;
}
public void setPrev(LinkedNode prev) {
this.prev = prev;
}
public LinkedNode getNext() {
return next;
}
public void setNext(L.
match the following attributes to the parts of a compilerstrips ou.pdfarpitaeron555
match the following attributes to the parts of a compiler
strips out the comments and whitespace
converts text into lexemes
generates an Abstrat Symbol Tree
recursive descent or table driven
uses BNF or EBNF definitions
a. lexer
b. parser
Solution
The Program and Portfolio Management Maturity Model is an effective tool for organizations to
decide quickly what PPM improvements they should make to enhance their organization\'s
ability to optimize investments, execute big changes and deliver value.
Overview
Key Findings
Real project, program and portfolio management, when operating at the level of well-integrated
practices, is the key enabler that allows organizations to identify and execute strategic change.
Any meaningful undertakings to enhance or evolve the program and portfolio management
(PPM) function must pay more than lip service to organizational structure, business model and
culture to have any chance of success.
Competitive pressures and changing market conditions are forcing organizations toward Level 3,
and most organizations still aren\'t ready to make the leap.
Recommendations
At any level of PPM maturity, focus first on helping the organization make well-informed
investment choices. This will improve the odds of project success more than any other factor.
For organizations that require enterprisewide change and capabilities, it is worth the effort to
pursue Level 4, where enterprise PPM practices are built.
Identify objectives for your enterprise, and use them to identify the most salient improvement
opportunities for your enterprise.
Meticulously manage the change involved in maturing/improving your PPM capabilities.
Analysis
Project/program/portfolio management office (PMO) leaders, program managers and portfolio
managers are frequently challenged by ineffective processes, lack of stakeholder engagement and
difficult-to-quantify value. 1 Part of the problem is failure to match their processes, people and
technology approaches to the maturity level of their organizations. 2
The Gartner Program and Portfolio Management (PPM) Maturity Model assessment is designed
to help PPM leaders understand best practices around large project management, as well as PPM
to handle delivery of strategic value. This model assumes that organizations progress through a
maturity curve and that each level of organizational maturity directly affects the level of
investment and types of PPM approaches organizations choose to adopt.
arsing
A parser is an algorithm that determines whether a given input string is in a language and, as a
side-effect, usually produces a parse tree for the input. There is a procedure for generating a
parser from a given context-free grammar.
Recursive-Descent Parsing
Recursive-descent parsing is one of the simplest parsing techniques that is used in practice.
Recursive-descent parsers are also called top-down parsers, since they construct the parse tree
top down (rather than bottom up).
The basic idea of recursive-descent par.
Multiple-Choice Which one is a discrete variableRadius of a ball.pdfarpitaeron555
Multiple-Choice: Which one is a discrete variable?
Radius of a ball in an urn
Weight of a ball in an urn
Diameter of a ball in an urn
Number of balls in an urn
Solution
A discrete variable can only take up some specific values.
Hence,
OPTION D: Number of balls in an urn [ANSWER]
as it can only take integer values..
More Related Content
Similar to Introduction and BackgroundIn recent lectures we discussed usi.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdfaromalcom
In java , I want you to implement a Data Structure known as a Doubly-Ended-Queue. it is a
“fair” data structure in that it implements a FIFO (First In First Out ) behavior. As such, it is
often used to implement various wait lists in computer systems. For example, jobs waiting to use
the CPU, jobs waiting for a printer, jobs waiting to be placed into RAM for execution. In short,
whenever we want a fair strategy for waiting we use queues.
A DEQUE (Doubly-ended-queue) is a related data structure. Although similar to a Queue, it
differs in that it allows for insertions AND deletions from either end of the list (both the front
and the rear).
Your implementation MUST use a doubly-linked-list implementation. You may not use a static
array implementation.
Thus, a Deque is a List but it is one which only concerns itself with the first and last positions for
any insertion or deletion. The 6 operations supported are :
public void insertFront( int item ) - insert the given item (as a node) into the first position of the
Deque.
public void insertRear( int item ) - insert the given item (as a node) into the last position of the
Deque.
public int deleteFront( ) - delete and return the element stored in the first node of the Deque.
public int deletRear( ) – delete and return the element stored in the last node of the Deque.
public boolean isempty( ) - returns true if the Deque is currently empty or false if it is not.
public void printDeque( ) - print the integers from the list, one per line, from the first element
through to the last in order.
Classes
Your program must implement the following 3 classes. public class dequeDriver
This class will contain your program’s main method. It will need to declare a deque object and
process input as indicated below.
Your program should prompt the user for the path of an input file. It should open the file for
input and process it line by line. Each line of the input file will have one of the following forms.
PR
IF
IR
DF
DR
The meanings of each input is as follows:
PR - print the current contents of the deque from front to rear using the printDeque( ) method of
the deque object.
IF - insert the given int value into the front of the deque.
IR - insert the given int value into the rear of the deque.
DF - delete the front value from the deque.
DR – delete the rear element of the deque.
Below is an example input file that your program should be able to process.
PR
IF 4
IF 5
IF 6
IR 7
PR
DR
PR
DF
PR
The output for the input file shown above is :
EMPTY DEQUE
----- Front -----
6
5
4
7
----- Rear -----
----- Front -----
6
5
4
----- Rear -----
----- Front -----
5
4
----- Rear -----
public class dequeNode
This class will implement the linked nodes that will be used to implement the deque itself.
It should have the following protected data members.
protected dequeNode next; // next pointer to next node
protected dequeNode prev; // previous pointer to previous node
protected int val; // the integer value stored within the dequeNod.
Collections and its types in C# (with examples)Aijaz Ali Abro
Learn step by step c# collections with easy examples. Learn generic, non-generic and specialized collections along with easy and great examples. Learn about arraylist, queue class,stack class and more. Difference between generic and non-generic collections. Difference between arraylist and simple array.
Data Structure Introduction
Data Structure Definition
Data Structure Types
Data Structure Characteristics
Need for Data Structure
Stack Definition
Stack Representation
Stack Operations
Stack Algorithm
Program for Stack in C++
Linked List Definition
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
Linked List Defination
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
JAVA A double-ended queue is a list that allows the addition and.pdfamrishinda
**JAVA** A double-ended queue is a list that allows the addition and removal of items from
either end. One end is arbitrarily called the front and other the rear, but the two ends behave
identically. Specify, design and implement a class for a double-ended queue. Include operations
to check if it is empty and to return the number of items in the list. For each end, include
operations for adding and deleting items. Use doubly linked list for your implementation. Call
your class Deque (pronounced \"deck\").
Solution
//package com.java2novice.ds.queue;
public class DequeDblLinkedListImpl {
private LinkedNode front;
private LinkedNode rear;
public void insertFront(T item){
//add element at the beginning of the queue
System.out.println(\"adding at front: \"+item);
LinkedNode nd = new LinkedNode();
nd.setValue(item);
nd.setNext(front);
if(front != null) front.setPrev(nd);
if(front == null) rear = nd;
front = nd;
}
public void insertRear(T item){
//add element at the end of the queue
System.out.println(\"adding at rear: \"+item);
LinkedNode nd = new LinkedNode();
nd.setValue(item);
nd.setPrev(rear);
if(rear != null) rear.setNext(nd);
if(rear == null) front = nd;
rear = nd;
}
public void removeFront(){
if(front == null){
System.out.println(\"Deque underflow!! unable to remove.\");
return;
}
//remove an item from the beginning of the queue
LinkedNode tmpFront = front.getNext();
if(tmpFront != null) tmpFront.setPrev(null);
if(tmpFront == null) rear = null;
System.out.println(\"removed from front: \"+front.getValue());
front = tmpFront;
}
public int size(){
if(front == null && rear ==null){
return 0;
}
//remove an item from the beginning of the queue
LinkedNode tmpFront = front;
LinkedNode tmpRear = rear;
int i=0;
while(tmpFront != rear)
{
i++;
tmpFront=tmpFront.getNext();
}
i++;
return i;
}
public void removeRear(){
if(rear == null){
System.out.println(\"Deque underflow!! unable to remove.\");
return;
}
//remove an item from the beginning of the queue
LinkedNode tmpRear = rear.getPrev();
if(tmpRear != null) tmpRear.setNext(null);
if(tmpRear == null) front = null;
System.out.println(\"removed from rear: \"+rear.getValue());
rear = tmpRear;
}
public static void main(String a[]){
DequeDblLinkedListImpl deque = new DequeDblLinkedListImpl();
deque.insertFront(34);
deque.insertFront(67);
System.out.println(\"Size of the queue : \"+deque.size());
deque.insertFront(29);
deque.insertFront(765);
deque.removeFront();
deque.removeFront();
deque.removeFront();
deque.insertRear(43);
deque.insertRear(83);
deque.insertRear(84);
deque.insertRear(546);
deque.insertRear(356);
deque.removeRear();
deque.removeRear();
deque.removeRear();
deque.removeRear();
deque.removeFront();
deque.removeFront();
deque.removeFront();
}
}
class LinkedNode{
private LinkedNode prev;
private LinkedNode next;
private T value;
public LinkedNode getPrev() {
return prev;
}
public void setPrev(LinkedNode prev) {
this.prev = prev;
}
public LinkedNode getNext() {
return next;
}
public void setNext(L.
match the following attributes to the parts of a compilerstrips ou.pdfarpitaeron555
match the following attributes to the parts of a compiler
strips out the comments and whitespace
converts text into lexemes
generates an Abstrat Symbol Tree
recursive descent or table driven
uses BNF or EBNF definitions
a. lexer
b. parser
Solution
The Program and Portfolio Management Maturity Model is an effective tool for organizations to
decide quickly what PPM improvements they should make to enhance their organization\'s
ability to optimize investments, execute big changes and deliver value.
Overview
Key Findings
Real project, program and portfolio management, when operating at the level of well-integrated
practices, is the key enabler that allows organizations to identify and execute strategic change.
Any meaningful undertakings to enhance or evolve the program and portfolio management
(PPM) function must pay more than lip service to organizational structure, business model and
culture to have any chance of success.
Competitive pressures and changing market conditions are forcing organizations toward Level 3,
and most organizations still aren\'t ready to make the leap.
Recommendations
At any level of PPM maturity, focus first on helping the organization make well-informed
investment choices. This will improve the odds of project success more than any other factor.
For organizations that require enterprisewide change and capabilities, it is worth the effort to
pursue Level 4, where enterprise PPM practices are built.
Identify objectives for your enterprise, and use them to identify the most salient improvement
opportunities for your enterprise.
Meticulously manage the change involved in maturing/improving your PPM capabilities.
Analysis
Project/program/portfolio management office (PMO) leaders, program managers and portfolio
managers are frequently challenged by ineffective processes, lack of stakeholder engagement and
difficult-to-quantify value. 1 Part of the problem is failure to match their processes, people and
technology approaches to the maturity level of their organizations. 2
The Gartner Program and Portfolio Management (PPM) Maturity Model assessment is designed
to help PPM leaders understand best practices around large project management, as well as PPM
to handle delivery of strategic value. This model assumes that organizations progress through a
maturity curve and that each level of organizational maturity directly affects the level of
investment and types of PPM approaches organizations choose to adopt.
arsing
A parser is an algorithm that determines whether a given input string is in a language and, as a
side-effect, usually produces a parse tree for the input. There is a procedure for generating a
parser from a given context-free grammar.
Recursive-Descent Parsing
Recursive-descent parsing is one of the simplest parsing techniques that is used in practice.
Recursive-descent parsers are also called top-down parsers, since they construct the parse tree
top down (rather than bottom up).
The basic idea of recursive-descent par.
Multiple-Choice Which one is a discrete variableRadius of a ball.pdfarpitaeron555
Multiple-Choice: Which one is a discrete variable?
Radius of a ball in an urn
Weight of a ball in an urn
Diameter of a ball in an urn
Number of balls in an urn
Solution
A discrete variable can only take up some specific values.
Hence,
OPTION D: Number of balls in an urn [ANSWER]
as it can only take integer values..
Looking for some help with this assignment. 1. Define distribut.pdfarpitaeron555
Looking for some help with this assignment.
1. Define distributed computing and the impact it has had on organizations.
2. Why should you be concerned about the innovation butterfly is you are an IT professional?
3. What is the difference between single threading and multithreading and how would I use it in
a Distributed system?
4. What is a mobile architecture and what are some of the design considerations?
5. Explain why naming conventions are important in large enterprise organizations.
6. What is the difference between a disruptive and a sustaining technology?
7. Describe the difference amongst Mobile, Cloud and Embedded systems.
8. Explain the role time plays in distributed systems and why it is difficult to manage.
9. What are the major challenges IOT plays in a distributed system?
10. How does mobility, ubiquity and PAN increase the complexity of distributed systems.
Solution
1)
sol:defnition:
it is a one type of model where software components are shared with mutliple computer
to make work easier and gives more effieciency and performance
impact of distributed computing
1)at present it keeps a main roles in organizations ,all the organizations are converting to
distributed system
2)we can process data at one place and access data at one place so there is lot of availability
3)many organization doing thier business process in remote computer and accesing their
database
2)differenece between sustaining and disruptive technology
1)by using sustaining technology improves performance for products which had been established
with the
dimension of the product which gives market to the mainstream customers
2) coming to the disruptive technology bring to market in diffrent praportions of values which
had been
available previously,these disruptive techonolgy underperform which had been established in
main steram market.
In the binary search, if the array being searched has 32 elements in.pdfarpitaeron555
In the binary search, if the array being searched has 32 elements in it, how many elements of the
array must be examined to be certain that the array does not contain the key? What about 1024
elements? Note: the answer is the same regardless of whether the algorithm is recursive or
iterative.
Solution
Binary Search Algorithm- Fundamentals, Implementation and Analysis
Hitesh Garg | May 15, 2015 | algorithms | 5 Comments
Binary Search Algorithm and its Implementation
In our previous tutorial we discussed about Linear search algorithm which is the most basic
algorithm of searching which has some disadvantages in terms of time complexity,so to
overcome them to a level an algorithm based on dichotomic (i.e. selection between two distinct
alternatives) divide and conquer technique is used i.e. Binarysearch algorithm and it is used to
find an element in a sorted array (yes, it is a prerequisite for this algorithm and a limitation too).
In this algorithm we use the sorted array so as to reduce the time complexity to O(log n). In this,
size of the elements reduce to half after each iteration and this is achieved by comparing the
middle element with the key and if they are unequal then we choose the first or second half,
whichever is expected to hold the key (if available) based on the comparison i.e. if array is sorted
in an increasing manner and the key is smaller than middle element than definitely if key exists,
it will be in the first half, we chose it and repeat same operation again and again until key is
found or no more elements are left in the array.
Recursive Pseudocode:
1
2
3
4
5
6
7
8
9
10
11
12
// initially called with low = 0, high = N – 1
BinarySearch_Right(A[0..N-1], value, low, high) {
// invariants: value >= A[i] for all i < low
value < A[i] for all i > high
if (high < low)
return low
mid = low +((high – low) / 2) // THIS IS AN IMPORTANT STEP TO AVOID BUGS
if (A[mid] > value)
return BinarySearch_Right(A, value, low, mid-1)
else
return BinarySearch_Right(A, value, mid+1, high)
}
Iterative Pseudocode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
BinarySearch_Right(A[0..N-1], value) {
low = 0
high = N - 1
while (low <= high) {
// invariants: value >= A[i] for all i < low
value < A[i] for all i > high
mid = low +((high – low) / 2) // THIS IS AN IMPORTANT STEP TO AVOID BUGS
if (A[mid] > value)
high = mid - 1
else
low = mid + 1
}
return low
}
Asymptotic Analysis
Since this algorithm halves the no of elements to be checked after every iteration it will take
logarithmic time to find any element i.e. O(log n) (where n is number of elements in the list) and
its expected cost is also proportional to log n provided that searching and comparing cost of all
the elements is same
Data structure used -> Array
Worst case performance -> O(log n)
Best case performance -> O(1)
Average case performance -> O(log n)
Worst case space complexity -> O(1)
So the idea is-
RECURSIVE Implementation of Binary search in C programming language
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
.
Is there any information out there about decorator crabs picking up .pdfarpitaeron555
Is there any information out there about decorator crabs picking up toxins and the correlation to
the polluted areas they inhabit
Solution
It\'s not true that these crabs pick up toxins from the environment. They use the surviving
environment to camouflage themselves. The is also no relation to the pollution thing..
Heliconius melpomene is a species of butterfly with ZW sex determina.pdfarpitaeron555
Heliconius melpomene is a species of butterfly with ZW sex determination. H. melpomene\'s
wing spots are normally orange, but a recessive Z-linked mutation causes the spots to be yellow,
while a recessive autosomal mutation causes the spots to be red. Butterflies homozygous (or
hemizygous) for both mutations have no wing spots. What are the expected F1 and F2
phenotypes from a cross between a red-spotted female and a yellow-spotted male?
Solution
The Heliconius melpomene butterfly having sex determination ZW have normally orange wing
spots.
Given
Recessive Z linked mutation causes the spots to be yellow, if Y is the dominant gene the y
represents the recessive gene. The recessive autosomal mutation causes the spot to be red,the
recessive autosomal mutation represented by rr.
a) WX represents female
b) WW represents male
Given-:
F1 generation
The red spotted female is crossed with yellow spotted male
ZWrr X ZZy
ZZ, WrrZ, ZZy, WrrZy
It gives 1 hemizygous butterfly, 1red spotted female butterfly, 1 yellow spotted male and 1
normal orange wing male butterfly.
The F2 generation gives the same result..
Identify the key mechanism that determines which X remains active an.pdfarpitaeron555
Identify the key mechanism that determines which X remains active and which X becomes
inactive.
Solution
In normal human females, only one X chromosome is transcriptionally active, the other X
chromosome remains condensed as heterochromatin and is called as sex chromatin or Barr body.
Formation of Barr body ensures that cells of both males and females have same number of active
X chromosomes and thus synthesise equal amount of products encoded by X linked genes.
This inactivation of one of the two X chromosome in each cell is called Lyonization, after the
name of British researcher Mary Lyon. She proposed that;
Inactivation of X chromosome in females occurs during early stages of embryonic development
and this Inactivation of X chromosome in embryo is a random process, so that paternally derived
and maternally derived X chromosomes stands equal chance of becoming inactivated in any
given cell.
MECHANISM OF INACTIVATION :
The mechanism of Inactivation is initiated by a non coding RNA molecule called XIST RNA.
There is a region on X chromosome called as X-Inactivation center (XIC) located on proximal
end of X chromosome. Genetic expression of this region occurs only on chromosome that is
inactivated. This region carries about 4 genes one of which is X-Inactivation specific transcript
(XIST). The RNA transcribed by this gene is called XIST RNA. This RNA is large (about 17kb
long) and is not translated. It does not diffuse into nucleoplasm,but accumulates along the length
of chromosome just before it is Inactivated.
Thus RNA product of XIST gene spread over and coat the X chromosome bearing the gene that
produced it ,creating some sort of molecular \"cage\" that entraps it leading to its Inactivation.
Thus X chromosome in which XIST gene is transcribed to form XIST RNA becomes inactive
(due to coating of this X chromsome by XIST RNA) while as the other X chromosome remains
active..
For each of the given functions, list the domain and range. Also list.pdfarpitaeron555
For each of the given functions, list the domain and range. Also list the period, amplitude and
the equations of all asymptotes where applicable. (If you choose to draw a graph it will not be
graded.) ln(x) Domain:_ Range:_ Period:_ Amplitude: _ Asymptotes:_
Solution
f(x) = lnx
Domain : ( 0, infinity)
Range : ( -inf , +inf)
Period : It is not periodic function
Amplitude : Vertical asymtote , x=0.
Given to girls born in the U.S. in the years The tables below give t.pdfarpitaeron555
Given to girls born in the U.S. in the years The tables below give the ten most popular names
1974 and 1999 and the percentages of girls given those names. Consider group of 20 girls born in
1974. and another group of 20 bom in 1999. Use the data in the tables to do problems 22-25
regarding these groups. The name Jennifer was approximately 3 times as popular in 1974 as
Emily was in 1999, despite each being the #1 name in their respective years. Determine by
calculation if you are 3 times as likely to have more than one Jennifer in the 1974 group of 20 as
you are to have multiple Emilys in the 1999 group of 20.
Solution.
How do open source projects work How is it different from closed sou.pdfarpitaeron555
How do open source projects work? How is it different from closed source projects? Discus the
creation of a database. Explain its working. (E.g, what you need to use to create tables and
relationship? What you do to modify a database?) Explain what\'s SaaS, PaaS and laaS?
Distinguish among these three.
Solution
31) In open source project the source code of the project is made available to anyone for free.
The code can be studied, modified and even redistributed for any purpose.Many of the open
source projects are developed in an open collaberative manner. People volunteer to develop the
projects.Where as in closed source projects the source code is not developed by an organization
and the source code is not openly available.
32) A database consists of many tables created for a project. In mysql it is created using the
command \'create database sample_database;\'. We generally use a RDBMS(Relational Database
Management System). The data is stored in RDBMS database objects called tables. You can
create a table by specifying the number of rows, names of each row and the type of data that will
be stored in each of them.
33) SaaS means software as a service in which a software is provided as a serive. Generally the
service is centrally hosted, but this many not always be the case. The consumer is charged on a
one time basis or in a subscription model. PaaS stands for platform as a service. The service
provides platform as a service for customers to develop, manage and run applications. This is
generally referred for cloud computing applications. LaaS stands for logging as a serivce. This
represents a architechture used for collection of log files from a specific location or source..
Ferdinand is affected by hemophilia, a recessive x-linked condition..pdfarpitaeron555
Ferdinand is affected by hemophilia, a recessive x-linked condition. He mates with an unaffected
woman with no history of hemophilia in her family. Their first child is a girl with Turner
Syndrome (XO sex chromosomes), who is also hemophiliac. You infer that she resulted from the
following sperm and egg (answers listed in the order of sperm, egg):normal, normal
Solution
Answer: Because Ferdinand has hemophilia which is X-linked ressesive disease. Daughters
produced by mating of ferdinand and a normal female would be carriers of hemophilia. In this
case however, the daughter is having Turners\' syndrome (XO) and is heophilic as well. This
implies that the X came from sperm of Ferdinand and the O is beacuse the X chromosome from
the female was nondisjunct at meiosis I, as non-disjunction at meiosis II would result in two
gaetes being normal, One being trisomic and one being monosomic. whereas nondysjunction at
meiosis I would give rise to 50% trisomic and 50% monosomic gametes. Hence raising the
possibility of turners\' syndrome after nondysjunction at meiosis I.
Therefore answer is:
c. Normal and non-dysjunction at meiosis I..
Explain whether you think IFRS and GAAP will be fully converged. Wha.pdfarpitaeron555
Explain whether you think IFRS and GAAP will be fully converged. What is the current status of
convergence projects?
Solution
There has been a concerted convergence effort between the Generally Accepted Accounting
Principles (GAAP) and the International Financial Reporting Standards (IFRS) in order to avoid
conflict and confusion, promote simplicity, streamlining, consistency and transparency, and
avoid any future financial crises or meltdowns.
Despite the research-indicated evidence of a higher accounting quality being experienced by
firms that either apply the IFRS standards or have switched to them from the GAAP, the
convergence process has not proven to be an easy task, mostly because of the differences in
approach between the two accounting bodies.
The GAAP is a rules-based methodology, while the IFRS takes a principle-based approach. The
rules-based approach is comprised of a complex set of guidelines that establishes criteria for
every possible contingency and provides the rules required for specified transactions, thus
promoting uniformity. The principle-based methodology lays out the key objectives of good
reporting in each subject area and then provides guidance, explaining the objective, and relates it
to common examples, thus promoting transparency.
If these methodological differences between the two approaches cannot be resolved, they may
prolong the process of compiling a true set of international accounting standards and increase the
costs required to maintain two sets of books.
So from the above discussion it is clear that, IFRS and GAAP will be fully converged, but it will
took a time.
current status of convergence projects
One of the main concerns in the United States business world is how the convergence process
and its results will impact the future evolution of the accounting profession. This specific
concern, simply stated, is about uniformity over transparency, and it has a serious impact on the
standards development process. Could the goals of uniformity and transparency be achieved?
Are they incompatible or mutually exclusive?
This incompatibility - real or perceived - is grounded in the conflicts existing among the
constructs of rules-based and principle-based shareholder and stakeholder primacy theories,
which are recognized by the Financial Accounting Standards Board (FASB), the International
Accounting Standards Board (IASB) and the European and Asian Accounting Standards Boards,
and which have an impact on the standards development methodology. Transparency has a direct
impact on the areas of business combinations (Phase I and II), revenue recognition and financial
performance of business enterprises reporting. hence they are still in process..
Does the following picture depict a function It so, is it a one to o.pdfarpitaeron555
Does the following picture depict a function? It so, is it a one to one function?
Solution
The given picture depict the function.Every element of set x mapping into set y\'s exactly one
element.so it is called a function.
A function is said to be one-to-one if every y value has exactly one x value mapped onto it.So the
given picture is not one-to-one function.because two elements of set x mapping to one set y\'s
element..
Do patients have health care rights that are not legal or statuatory.pdfarpitaeron555
Do patients have health care rights that are not legal or statuatory rights? Explain your answer.
Solution
Legal Conceptualization: it supplies that a patient has a right to realize potential benefits, risks,
and option a of proposed therapy; duty of physician to reveal to the patient a full apprehension of
the suggested care before patient assent to it.
Statuatory Rights: when a patient is clinically unfit to give assent to a lifesaving emergency
therapy. The law implicit assent (exigency in most states abolish need for assent).
Describe the authentication process in the figure below Solutio.pdfarpitaeron555
Describe the authentication process in the figure below:
Solution
Authentication begins when a user tries to access information. First, the user must prove his
access rights and identity. When logging into a computer, users commonly enter usernames and
passwords for authentication purposes. This login combination, which must be assigned to each
user, authenticates access. However, this type of authentication can be circumvented by hackers.
A better form of authentication, biometrics, depends on the user’s presence and biological
makeup (i.e., retina or fingerprints). This technology makes it more difficult for hackers to break
into computer systems.
The Public Key Infrastructure (PKI) authentication method uses digital certificates to prove a
user’s identity. There are other authentication tools, too, such as key cards and USB tokens. One
of the greatest authentication threats occurs with email, where authenticity is often difficult to
verify. For example, unsecured emails often appear legitimate..
Discuss the history of bureaucratic and administrative management..pdfarpitaeron555
Discuss the history of bureaucratic and administrative management.
Solution
1. History of Bureaucratic Management:
There was time before 1800 when the organisations operated like a family. Supervisors, workers
and employees did not have proper defined work. Every one did everything. During late 1800,
Max Weber brought about changes in this system of organisational operation. He believed that
having an informal organisation decreases the productivity of the employees as they are not
focussed and goal-driven.
Max Weber created the idea of bureaucratic management which made the organisation more
rigid, authorative and structured. He believed that employees do not follow the organisation but
they follow their bosses. He defined supervisors and workers role properly. The workers were
supposed to take their immediate bosses orders and cannot operate beyond that capacity.
Max Weber\'s theory of bureaucratic management has two important elements. First, it involves
structuring an organization into a hierarchy system. Secondly, the organization as well as its
employees operate through clearly defined rational-legal decision-making rules. Both the
elements help the organisation to achieve its goals.
2. History of Administrative Mangement
During 1900, the management expert Jules Henri Fayol, came to the conclusion that
management is an activity that is followed by all the human undertakings. Management is
needed at school, housework, business, government services, etc. All these human undertakings
need five basic administrative functions to operate. They are:
i. Planning
ii. Organizing
iii. Commanding
iv. Coordinating
v. Controlling
Henri Fayol rejected the notion that \"Managers are born and not made.\" Instead he believed that
management is a skill that can be developed over the time through proper training and
enthusiasm. Managemnt skills can be acquired if its principles are understood.
Henri Fayol was of the belief that since management is an all-encompassing activity, the
management skills should be taught in schools, colleges and universities..
Describe or explain how SNPs in genes at evolutionary conserved brea.pdfarpitaeron555
Describe or explain how SNPs in genes at evolutionary conserved breakpoints can lead to
dramatic phenotypic differences between species like chimpanzees and humans even though
their genomes are 98% similar? Provide and describe or explain an example of one gene with
SNP differences between gorillas and humans that might have resulted changes between humans
and apes.
Solution
SNP ( Single nucleotide polymorphism) is a type of genetic variation among living beings. SNP
represents a difference in a single DNA building block i.e, nucleotide. SNP replaces the
nucleotide cytosine ( C) With ghe nucleotide thymine (T) in a stetch of DNA. The difference
between the two genomes of humans and chimpanzees is actually 4% approximately. This
msinly contributes to the phenotypic differences in various species.
Humans differbfrom other primates like chimpanzees and apes in cognitive abilities and a
significantly larger brain. These correlate with metabolic changes, etc. Example of such genes
with SNP differences is 90 TF genes with significant expression levels in humans and
chimpanzee brain. Among these KRAB-Zinc finger genes are markedly important. The
differentially expressed TFs cluster within robust regulatory network consisting of two distinct
but interlinked modules, strongly associated with energy metabolism functions and the others
with transcription, vesticular transport and ubiquitination..
Can Variance Inflation factors be used to detect Heteroscedasticity .pdfarpitaeron555
Can Variance Inflation factors be used to detect Heteroscedasticity problem in the regression
analysis
Solution
Variance inflation factors (VIF) measure how much the variance of the estimated regression
coefficients are inflated as compared to when the predictor variables are not linearly related.
Use to describe how much multicollinearity (correlation between predictors) exists in a
regression analysis. Multicollinearity is problematic because it can increase the variance of the
regression coefficients, making them unstable and difficult to interpret.
Use the following guidelines to interpret the VIF:VIFStatus of predictorsVIF = 1Not correlated1
< VIF < 5Moderately correlatedVIF > 5 to 10Highly correlated.
A study undertaken by the Miami-Dade Supervisor of Elections in 2002.pdfarpitaeron555
A study undertaken by the Miami-Dade Supervisor of Elections in 2002 revealed that 44% of
registered voters are Democrats, 37% are Republicans, and 19% are others. If two registered
voters are selected at random, find the following probability:
One of them is a Democrat and another one is a Republican.
Solution
Here we have following probabilties:
P(democrats)=0.44
P(republicans)=0.37
P(others)=0.19
Since voters are independent from each other so the probabilityOne of them is a Democrat and
another one is a Republican is
P(One of them is a Democrat and another one is a
Republican)=P(democrats)P(republican)=0.44*0.37=0.1628
hence, the required probability is 0.1628..
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Home assignment II on Spectroscopy 2024 Answers.pdf
Introduction and BackgroundIn recent lectures we discussed usi.pdf
1. Introduction and Background
In recent lectures we discussed using arrays, classes and interfaces (see newly added course
notes if you want to read ahead about interfaces – we will cover them this week in lecture). In
this lab you will utilize all of these topics to build a simple yet useful new class. Consider the
following interface describing the methods for a simple double ended queue (or deque):
public interface SimpleDeque
{
public void addFront(Object X); // Add Object X at front of list
public void addRear(Object X); // Add Object X at rear of list
// If array is full, add methods should do nothing
public Object removeFront(); // Remove and return Object X from
// front of list
public Object removeRear(); // Remove and return Object X from
// rear of list
// If array is empty, remove methods should return null
public boolean isEmpty(); // Return true if the list is empty
// Return false otherwise
2. }
A queue has the behavior such that items are added at the rear and removed from the front,
thereby giving a First In First Out (FIFO) access to the items added and subsequently removed
from the list. No other manipulations of the data are permitted (for example, we cannot add or
remove anywhere in the middle). Looking at it "in reverse", we could add new items at the
front of the queue and remove them from the rear. This is still providing FIFO access, but just
from a different point of view. Now consider both adding and removing items at the rear of the
list (without ever accessing the front). This is called stack access and gives us Last In First Out
(LIFO) access to the items (the data is removed in reverse order). The same behavior occurs if
we both add and remove at the front without ever accessing the rear of the list.
The simple deque above is expressed as an interface rather than a class, because we are not
describing the data or how it is represented -- we are simply describing its access behavior.
However, to actually build a working deque, we need a class that implements the interface
above. For example:
public class MyDeque implements SimpleDeque
{
Object [] theData;
int numItems;
public MyDeque(int maxItems)
{
theData = new Object[maxItems];
numItems = 0;
}
// Implementation of the five methods of SimpleDeque, plus
// perhaps other methods as well
3. }
Note that the implementation above uses an array of Object to store the items in the deque. Since
Object is the base class to all other Java classes, an array of Object can thus be used to store any
Java class types (we can even store primitive values if we utilize their wrapper classes). Also
note that nothing in the SimpleDeque interface requires an array to be used to store the data. You
will see in your CS 0445 course that a linked list may in fact be a better implementation than an
array in this case. However, for this implementation we will use an array because it is simple and
easy to understand.
Another important thing to notice about the partial implementation above is that the size of the
array used is not equal to the number of items in the deque. The number of items in the deque is
maintained in the separate int variable numItems. Since Java array sizes are fixed once the array
object is created, to avoid having to recreate new array objects with each add or removal we
simply allocate an array that is some reasonable size (specified by the parameter in the
constructor) when we create the deque. At that time we also set numItems to zero since there are
no actual items in the deque. We then increment numItems with each addition and decrement
numItems with each removal. This is the same maintenance technique used in the MovieDB
class of Lab 7. As we discussed in lecture, and as you did in Assignment 3, when the array fills
we could copy the data into a new, larger array. However, in this case, to keep things simple, we
will not resize the array and simply not allow any new items to be added once the array fills.
Adding or removing at the rear of the array is a relatively simple process -- to add we simply put
the new object in location numItems and then increment numItems. To remove we store the last
item in a temp object, decrement numItems and then return the item. It is probably a good idea to
also set the location back to null before returning.
Adding or removing at the front of the array is a bit more complicated. For this simple
implementation we will do it in the following way:
4. addFront -- move objects in locations 0..numItems-1 over one spot to "the right" (i.e. into
locations 1..numItems), then put the new object into location 0 and increment numItems. For
example, given the array below of length 9 with 6 items in it, doing an addFront of 25 will have
the effect shown in the three lines below:
0
1
2
3
4
5
6
7
8
50
6. 80
25
50
30
10
40
20
80
removeFront -- store the object in location 0 in a temp variable, then move objects in locations
1..numItems-1 over one spot to "the left" (i.e. into locations 0..numItems-2). Set location
7. numItems-1 to null, decrement numItems and return the temp object. In effect, you are doing the
opposite of what is shown in the addFront above.
Note that the addFront and removeFront methods as described above are not implemented in the
most efficient manner. If you take CS 0445 you will likely discuss better ways of implementing
these methods. Also note the special cases for inserting into a full list (do nothing in this case)
and for removing from an empty list (return null in this case).
Program
For this lab you will complete the MyDeque class so that it works with the simple test program
Lab9.java (http://people.cs.pitt.edu/~ramirez/cs401/labs/Lab9.java). An outline of MyDeque.java
(http://people.cs.pitt.edu/~ramirez/cs401/labs/MyDeque.java) is provided for you to complete.
Make sure you handle the special cases shown. You will also need SimpleDeque.java
(http://people.cs.pitt.edu/~ramirez/cs401/labs/SimpleDeque.java), in which the interface is
defined. Download all three files onto your account through the links provided or through the
AFS file system. Then complete MyDeque.java, and compile and run Lab9.java so that it works
correctly. The output of your program should be:
Lab9> java Lab9
Stack adds and removes at rear
Marge Ingmar Ingrid Bertha Herb
Queue adds at rear and removes at front
0 1 2 3 4
Queue adds at front and removes at rear
0.0 2.0 4.0 6.0 8.0 10.0 12.0 14.0
8. Grading and Submission
Demonstrate that your MyDeque class works correctly by running the Lab9.java program for
your TA. Be ready to show your code to your TA as well.
There will be 4 raw points for this lab, broken down in the following way.
addFront() method – 1 point
removeFront() method – 1 point
addRear() method – 1 point
removeRear() method – 1 point
Note that your program must work with the provided driver program in order to receive credit for
these items. The 4 raw points will be normalized to give this lab equal weight to the other labs in
the CS 401 course.
Notes and Hints
Shifting the items in the array to allow the addFront() and removeFront() operations is not hard,
but it IS tricky. I recommend tracing it with a pencil and paper before coding it in your class. Be
especially careful with the order that you move the items.
Introduction and Background
In recent lectures we discussed using arrays, classes and interfaces (see newly added course
notes if you want to read ahead about interfaces – we will cover them this week in lecture). In
this lab you will utilize all of these topics to build a simple yet useful new class. Consider the
following interface describing the methods for a simple double ended queue (or deque):
public interface SimpleDeque
{
public void addFront(Object X); // Add Object X at front of list
9. public void addRear(Object X); // Add Object X at rear of list
// If array is full, add methods should do nothing
public Object removeFront(); // Remove and return Object X from
// front of list
public Object removeRear(); // Remove and return Object X from
// rear of list
// If array is empty, remove methods should return null
public boolean isEmpty(); // Return true if the list is empty
// Return false otherwise
}
A queue has the behavior such that items are added at the rear and removed from the front,
thereby giving a First In First Out (FIFO) access to the items added and subsequently removed
from the list. No other manipulations of the data are permitted (for example, we cannot add or
remove anywhere in the middle). Looking at it "in reverse", we could add new items at the
front of the queue and remove them from the rear. This is still providing FIFO access, but just
from a different point of view. Now consider both adding and removing items at the rear of the
list (without ever accessing the front). This is called stack access and gives us Last In First Out
(LIFO) access to the items (the data is removed in reverse order). The same behavior occurs if
we both add and remove at the front without ever accessing the rear of the list.
The simple deque above is expressed as an interface rather than a class, because we are not
describing the data or how it is represented -- we are simply describing its access behavior.
However, to actually build a working deque, we need a class that implements the interface
10. above. For example:
public class MyDeque implements SimpleDeque
{
Object [] theData;
int numItems;
public MyDeque(int maxItems)
{
theData = new Object[maxItems];
numItems = 0;
}
// Implementation of the five methods of SimpleDeque, plus
// perhaps other methods as well
}
Note that the implementation above uses an array of Object to store the items in the deque. Since
Object is the base class to all other Java classes, an array of Object can thus be used to store any
Java class types (we can even store primitive values if we utilize their wrapper classes). Also
note that nothing in the SimpleDeque interface requires an array to be used to store the data. You
will see in your CS 0445 course that a linked list may in fact be a better implementation than an
array in this case. However, for this implementation we will use an array because it is simple and
easy to understand.
Another important thing to notice about the partial implementation above is that the size of the
array used is not equal to the number of items in the deque. The number of items in the deque is
maintained in the separate int variable numItems. Since Java array sizes are fixed once the array
object is created, to avoid having to recreate new array objects with each add or removal we
11. simply allocate an array that is some reasonable size (specified by the parameter in the
constructor) when we create the deque. At that time we also set numItems to zero since there are
no actual items in the deque. We then increment numItems with each addition and decrement
numItems with each removal. This is the same maintenance technique used in the MovieDB
class of Lab 7. As we discussed in lecture, and as you did in Assignment 3, when the array fills
we could copy the data into a new, larger array. However, in this case, to keep things simple, we
will not resize the array and simply not allow any new items to be added once the array fills.
Adding or removing at the rear of the array is a relatively simple process -- to add we simply put
the new object in location numItems and then increment numItems. To remove we store the last
item in a temp object, decrement numItems and then return the item. It is probably a good idea to
also set the location back to null before returning.
Adding or removing at the front of the array is a bit more complicated. For this simple
implementation we will do it in the following way:
addFront -- move objects in locations 0..numItems-1 over one spot to "the right" (i.e. into
locations 1..numItems), then put the new object into location 0 and increment numItems. For
example, given the array below of length 9 with 6 items in it, doing an addFront of 25 will have
the effect shown in the three lines below:
0
1
2
3
14. 10
40
20
80
removeFront -- store the object in location 0 in a temp variable, then move objects in locations
1..numItems-1 over one spot to "the left" (i.e. into locations 0..numItems-2). Set location
numItems-1 to null, decrement numItems and return the temp object. In effect, you are doing the
opposite of what is shown in the addFront above.
Note that the addFront and removeFront methods as described above are not implemented in the
most efficient manner. If you take CS 0445 you will likely discuss better ways of implementing
these methods. Also note the special cases for inserting into a full list (do nothing in this case)
and for removing from an empty list (return null in this case).
Program
For this lab you will complete the MyDeque class so that it works with the simple test program
Lab9.java (http://people.cs.pitt.edu/~ramirez/cs401/labs/Lab9.java). An outline of MyDeque.java
(http://people.cs.pitt.edu/~ramirez/cs401/labs/MyDeque.java) is provided for you to complete.
Make sure you handle the special cases shown. You will also need SimpleDeque.java
15. (http://people.cs.pitt.edu/~ramirez/cs401/labs/SimpleDeque.java), in which the interface is
defined. Download all three files onto your account through the links provided or through the
AFS file system. Then complete MyDeque.java, and compile and run Lab9.java so that it works
correctly. The output of your program should be:
Lab9> java Lab9
Stack adds and removes at rear
Marge Ingmar Ingrid Bertha Herb
Queue adds at rear and removes at front
0 1 2 3 4
Queue adds at front and removes at rear
0.0 2.0 4.0 6.0 8.0 10.0 12.0 14.0
Grading and Submission
Demonstrate that your MyDeque class works correctly by running the Lab9.java program for
your TA. Be ready to show your code to your TA as well.
There will be 4 raw points for this lab, broken down in the following way.
addFront() method – 1 point
removeFront() method – 1 point
addRear() method – 1 point
removeRear() method – 1 point
Note that your program must work with the provided driver program in order to receive credit for
these items. The 4 raw points will be normalized to give this lab equal weight to the other labs in
the CS 401 course.
Notes and Hints
16. Shifting the items in the array to allow the addFront() and removeFront() operations is not hard,
but it IS tricky. I recommend tracing it with a pencil and paper before coding it in your class. Be
especially careful with the order that you move the items.
Introduction and Background
In recent lectures we discussed using arrays, classes and interfaces (see newly added course
notes if you want to read ahead about interfaces – we will cover them this week in lecture). In
this lab you will utilize all of these topics to build a simple yet useful new class. Consider the
following interface describing the methods for a simple double ended queue (or deque):
public interface SimpleDeque
{
public void addFront(Object X); // Add Object X at front of list
public void addRear(Object X); // Add Object X at rear of list
// If array is full, add methods should do nothing
public Object removeFront(); // Remove and return Object X from
// front of list
public Object removeRear(); // Remove and return Object X from
// rear of list
// If array is empty, remove methods should return null
public boolean isEmpty(); // Return true if the list is empty
// Return false otherwise
17. }
A queue has the behavior such that items are added at the rear and removed from the front,
thereby giving a First In First Out (FIFO) access to the items added and subsequently removed
from the list. No other manipulations of the data are permitted (for example, we cannot add or
remove anywhere in the middle). Looking at it "in reverse", we could add new items at the
front of the queue and remove them from the rear. This is still providing FIFO access, but just
from a different point of view. Now consider both adding and removing items at the rear of the
list (without ever accessing the front). This is called stack access and gives us Last In First Out
(LIFO) access to the items (the data is removed in reverse order). The same behavior occurs if
we both add and remove at the front without ever accessing the rear of the list.
The simple deque above is expressed as an interface rather than a class, because we are not
describing the data or how it is represented -- we are simply describing its access behavior.
However, to actually build a working deque, we need a class that implements the interface
above. For example:
public class MyDeque implements SimpleDeque
{
Object [] theData;
int numItems;
public MyDeque(int maxItems)
{
theData = new Object[maxItems];
numItems = 0;
}
// Implementation of the five methods of SimpleDeque, plus
// perhaps other methods as well
18. }
Note that the implementation above uses an array of Object to store the items in the deque. Since
Object is the base class to all other Java classes, an array of Object can thus be used to store any
Java class types (we can even store primitive values if we utilize their wrapper classes). Also
note that nothing in the SimpleDeque interface requires an array to be used to store the data. You
will see in your CS 0445 course that a linked list may in fact be a better implementation than an
array in this case. However, for this implementation we will use an array because it is simple and
easy to understand.
Another important thing to notice about the partial implementation above is that the size of the
array used is not equal to the number of items in the deque. The number of items in the deque is
maintained in the separate int variable numItems. Since Java array sizes are fixed once the array
object is created, to avoid having to recreate new array objects with each add or removal we
simply allocate an array that is some reasonable size (specified by the parameter in the
constructor) when we create the deque. At that time we also set numItems to zero since there are
no actual items in the deque. We then increment numItems with each addition and decrement
numItems with each removal. This is the same maintenance technique used in the MovieDB
class of Lab 7. As we discussed in lecture, and as you did in Assignment 3, when the array fills
we could copy the data into a new, larger array. However, in this case, to keep things simple, we
will not resize the array and simply not allow any new items to be added once the array fills.
Adding or removing at the rear of the array is a relatively simple process -- to add we simply put
the new object in location numItems and then increment numItems. To remove we store the last
item in a temp object, decrement numItems and then return the item. It is probably a good idea to
also set the location back to null before returning.
Adding or removing at the front of the array is a bit more complicated. For this simple
implementation we will do it in the following way:
19. addFront -- move objects in locations 0..numItems-1 over one spot to "the right" (i.e. into
locations 1..numItems), then put the new object into location 0 and increment numItems. For
example, given the array below of length 9 with 6 items in it, doing an addFront of 25 will have
the effect shown in the three lines below:
0
1
2
3
4
5
6
7
8
50
22. 1..numItems-1 over one spot to "the left" (i.e. into locations 0..numItems-2). Set location
numItems-1 to null, decrement numItems and return the temp object. In effect, you are doing the
opposite of what is shown in the addFront above.
Note that the addFront and removeFront methods as described above are not implemented in the
most efficient manner. If you take CS 0445 you will likely discuss better ways of implementing
these methods. Also note the special cases for inserting into a full list (do nothing in this case)
and for removing from an empty list (return null in this case).
Program
For this lab you will complete the MyDeque class so that it works with the simple test program
Lab9.java (http://people.cs.pitt.edu/~ramirez/cs401/labs/Lab9.java). An outline of MyDeque.java
(http://people.cs.pitt.edu/~ramirez/cs401/labs/MyDeque.java) is provided for you to complete.
Make sure you handle the special cases shown. You will also need SimpleDeque.java
(http://people.cs.pitt.edu/~ramirez/cs401/labs/SimpleDeque.java), in which the interface is
defined. Download all three files onto your account through the links provided or through the
AFS file system. Then complete MyDeque.java, and compile and run Lab9.java so that it works
correctly. The output of your program should be:
Lab9> java Lab9
Stack adds and removes at rear
Marge Ingmar Ingrid Bertha Herb
Queue adds at rear and removes at front
0 1 2 3 4
Queue adds at front and removes at rear
23. 0.0 2.0 4.0 6.0 8.0 10.0 12.0 14.0
Grading and Submission
Demonstrate that your MyDeque class works correctly by running the Lab9.java program for
your TA. Be ready to show your code to your TA as well.
There will be 4 raw points for this lab, broken down in the following way.
addFront() method – 1 point
removeFront() method – 1 point
addRear() method – 1 point
removeRear() method – 1 point
Note that your program must work with the provided driver program in order to receive credit for
these items. The 4 raw points will be normalized to give this lab equal weight to the other labs in
the CS 401 course.
Notes and Hints
Shifting the items in the array to allow the addFront() and removeFront() operations is not hard,
but it IS tricky. I recommend tracing it with a pencil and paper before coding it in your class. Be
especially careful with the order that you move the items.
Solution
Code:
package lab9;
public class MyDeque implements SimpleDeque
{
Object [] theData;
int numItems;
public MyDeque(int maxItems)
{
theData = new Object[maxItems];
numItems = 0;
24. }
public boolean isEmpty()
{
return (numItems == 0);
}
public void addFront(Object X)
{
// Add new item at front of list (shifting old items
// to right first). If the list is full, do not add
// the item (just do nothing).
if (X == null)
throw new IllegalArgumentException("item must be non-null");
System.out.println(numItems);
if (numItems == theData.length)
return; // no more room!
else {
for(int i=numItems-1;i>=0;i--)
theData[i+1]=theData[i];
theData[0]=X;
numItems++;
}
}
public void addRear(Object X)
{
// Add new item at rear of list. If the list is full,
// do not add the item (just do nothing).
if (numItems == theData.length)
return; // no more room!
else {
theData[numItems]=X;
numItems++;
}
}
25. public Object removeFront()
{
// Remove and return front item from list, shifting remaining
// items to the left to fill the spot. If list is empty,
// return null.
if (numItems ==0)
{
//System.out.println("Empty");
return null;// no more room!
}
else {
Object x=theData[0];
for(int i=0;i