2. Protein-DNA binding
a) List the types of interactions that are involved between a protein that binds DNA non-specifically and DNA.
b) List two proteins that bind to DNA non-specifically.
c) List the types of interactions usually involved between a sequence-specific DNA binding protein and DNA.
d) List two proteins that bind DNA specifically.
e) What is the difference between non-specific and specific protein binding to DNA?
In: Biology
Write in Racket language.
Write a non-recursive Racket function called "keep-short-norec" that takes an integer and a list of strings as parameters and evaluates to a list of strings. The resulting list should be all strings on the original list, maintaining their relative order, whose string length is less than the integer parameter. For example, (keep-short-rec 3 '('abc' 'ab' 'a')) should evaluate to '('ab''a') because these are the only strings shorter than 3.
In: Computer Science
Performance Tires plans to engage in direct mail advertising. It is currently in negotiations to purchase a mailing list of the names of people who bought sports cars within the last three years. The owner of the mailing list claims that sales generated by contacting names on the list will more than pay for the cost of using the list. (Typically, a company will not sell its list of contacts, but rather provides the mailing services. For example, the owner of the list would handle addressing and mailing catalogs.)
Before it is willing to pay the asking price of $3 per name, the company obtains a sample of 225 names and addresses from the list in order to run a small experiment. It sends a promotional mailing to each of these customers. The data for this exercise show the gross dollar value of the orders produced by this experimental mailing. The company makes a profit of 20% of the gross dollar value of a sale. For example, an order for $100 produces $20 in profit.
Should the company agree to the asking price?
this is one part of the question i am stuck on the other 3 parts i did already
How is the certainty of your decision dependent on the number of names in the sample list? How would, for example, doubling the number of sample names change the certainty of your decision?
In: Statistics and Probability
IN PYTHON
Given a string with duplicate characters in it. Write a program to generate a list that only contains the duplicate characters. In other words, your new list should contain the characters which appear more than once.
Suggested Approach
Sample Output 1
List of duplicate chars: ['n', 'a']Sample Input 2
pneumonoultramicroscopicsilicovolcanoconiosisSample Output 2
List of duplicate chars: ['p', 'n', 'u', 'm', 'o', 'l', 'r', 'a', 'i', 'c', 's']Sample Input 3
pulchritudinousSample Output 3
List of duplicate chars: ['u', 'i']Sample Input 4
ordenSample Output 4
List of duplicate chars: []In: Computer Science
Could I please get explainations and working out as to how to get to the answers.
Note that is where part of the answer goes.
1.
Consider the following ArrayList list:
ArrayList list = new ArrayList(Arrays.asList(10,70,20,90));
//list = [10, 70, 20, 90]
Complete the following statements so that list contains the items [50, 70, 20]
Do NOT include spaces in your answers.
list.remove( ); list. ( , 50);
2.
Assume there exists an ArrayList list that contains the items
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, ....]
(So, we know the first item is 10, second item is 20, but we don't know how many items it contains. You may assume it contains at least 10 items)
Complete the following code that displays every other item starting at the fifth item (so, the pattern 50 70 90 ...)
Do NOT include spaces in your answer.
for(int i= ; i < ; ) {
System.out.println( +" ");
}
3.
Complete the following function that returns the number of negative (less than 0) items in ArrayList list.
public static int countNegatives(ArrayList list) {
int result = ;
for(int i=0; i < list.size(); i++) {
if( ) { ; }
} return result; }
In: Computer Science
1- Use FirstLastList: Write method public void
join(FirstLastList SecondList) such that given two
linked lists, join them together to give one. So if the lists lst1=
[1,3,7,4] and lst2=[2,4,5,8,6], the result of lst1.join(lst2) is
lst1=[1,3,7,4,2,4,5,8,6] and lst2=[].
2- Use FirstLastList: Write method public void
swap(). It swaps the first and last elements of a
FirstLastList. So if lst1= [1,3,7,4], lst1.swap() = [4,3,7,1].
Display or throw an exception if the list contains less than two
elements.
Demonstrate by displaying the list contents before
and after calling the above methods. Eg:
lst1
[1,3,7,4]
lst2
[2,4,5,8,6]
lst1.join(lst2)
[1,3,7,4,2,4,5,8,6]
lst1.swap()
[6,3,7,4,2,4,5,8,1]
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// firstLastList.java
// demonstrates list with first and last references
// to run this program: C>java FirstLastApp
////////////////////////////////////////////////////////////////
class Link
{
public long dData; // data item
public Link next; // next link in list
//
-------------------------------------------------------------
public Link(long d) // constructor
{ dData = d; }
//
-------------------------------------------------------------
public void displayLink() // display this link
{ System.out.print(dData + " "); }
//
-------------------------------------------------------------
} // end class Link
////////////////////////////////////////////////////////////////
class FirstLastList
{
private Link first; // ref to first link
private Link last; // ref to last link
//
-------------------------------------------------------------
public FirstLastList() // constructor
{
first = null; // no links on list yet
last = null;
}
//
-------------------------------------------------------------
public boolean isEmpty() // true if no links
{ return first==null; }
//
-------------------------------------------------------------
public void insertFirst(long dd) // insert at front of list
{
Link newLink = new Link(dd); // make new link
if( isEmpty() ) // if empty list,
last = newLink; // newLink <-- last
newLink.next = first; // newLink --> old first
first = newLink; // first --> newLink
}
//
-------------------------------------------------------------
public void insertLast(long dd) // insert at end of list
{
Link newLink = new Link(dd); // make new link
if( isEmpty() ) // if empty list,
first = newLink; // first --> newLink
else
last.next = newLink; // old last --> newLink
last = newLink; // newLink <-- last
}
//
-------------------------------------------------------------
public long deleteFirst() // delete first link
{ // (assumes non-empty list)
long temp = first.dData;
if(first.next == null) // if only one item
last = null; // null <-- last
first = first.next; // first --> old next
return temp;
}
//
-------------------------------------------------------------
public void displayList()
{
System.out.print("List (first-->last): ");
Link current = first; // start at beginning
while(current != null) // until end of list,
{
current.displayLink(); // print data
current = current.next; // move to next link
}
System.out.println("");
}
//
-------------------------------------------------------------
} // end class FirstLastList
////////////////////////////////////////////////////////////////
class FirstLastApp
{
public static void main(String[] args)
{ // make a new list
FirstLastList theList = new FirstLastList();
theList.insertFirst(22); // insert at front
theList.insertFirst(44);
theList.insertFirst(66);
theList.insertLast(11); // insert at rear
theList.insertLast(33);
theList.insertLast(55);
theList.displayList(); // display the list
theList.deleteFirst(); // delete first two items
theList.deleteFirst();
theList.displayList(); // display again
} // end main()
} // end class FirstLastApp
////////////////////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Class FirstLastAppTest.Java is only for testing. Please do not Edit.
class FirstLastAppTest
{
public static void main(String[] args)
{
FirstLastList lst1 = new FirstLastList(); // Start a new FirstLastList called lst1
lst1.insertLast(1); // Add links with data to the last position
lst1.insertLast(3);
lst1.insertLast(7);
lst1.insertLast(4);
System.out.print("\nlst1: "); // print the description for the list
lst1.displayList(); // print the contents of the list
FirstLastList lst2 = new FirstLastList(); // Start a new FirstLastList called lst2
lst2.insertLast(2); // Add links with data to the last position
lst2.insertLast(4);
lst2.insertLast(5);
lst2.insertLast(8);
lst2.insertLast(6);
System.out.print("\nlst2: "); // print the description for the list
lst2.displayList(); // print the contents of the list
System.out.print("\nlst1.join(lst2): "); // print the action to take place: lst1.join(lst2)
lst1.join(lst2); // call the join method for lst1 to add lst2
System.out.print("\nlst1: "); // print the description for the list
lst1.displayList(); // print the contents of the list lst1; post join()
System.out.print("lst2: "); // print the description for the list
lst2.displayList(); // print the contents of the list lst2; post join()
System.out.print("\nlst1.swap(): "); // print the action to take place: lst1.swap()
lst1.swap(); // call the swap method for lst1
System.out.print("\nlst1: "); // print the description for the list
lst1.displayList(); // print the contents of the list lst1; post swap()
} // end main()
} // end class In: Computer Science
java.lang.NullPointerException
at FirstLastList.swap(FirstLastList.java:85)
at FirstLastAppTest.main(FirstLastAppTest.java:32)
Plese correct this error
class FirstLastAppTest.Java is for testing purposes and not for editing.
class FirstLastAppTest
{
public static void main(String[] args)
{
FirstLastList lst1 = new FirstLastList(); // Start a new
FirstLastList called lst1
lst1.insertLast(1); // Add links with data to the last
position
lst1.insertLast(3);
lst1.insertLast(7);
lst1.insertLast(4);
System.out.print("\nlst1: "); // print the description for the
list
lst1.displayList(); // print the contents of the list
FirstLastList lst2 = new FirstLastList(); // Start a new FirstLastList called lst2
lst2.insertLast(2); // Add links with data to the last
position
lst2.insertLast(4);
lst2.insertLast(5);
lst2.insertLast(8);
lst2.insertLast(6);
System.out.print("\nlst2: "); // print the description for the
list
lst2.displayList(); // print the contents of the list
System.out.print("\nlst1.join(lst2): "); // print the action to
take place: lst1.join(lst2)
lst1.join(lst2); // call the join method for lst1 to add lst2
System.out.print("\nlst1: "); // print the description for the
list
lst1.displayList(); // print the contents of the list lst1; post
join()
System.out.print("lst2: "); // print the description for the
list
lst2.displayList(); // print the contents of the list lst2; post
join()
System.out.print("\nlst1.swap(): "); // print the action to take
place: lst1.swap()
lst1.swap(); // call the swap method for lst1
System.out.print("\nlst1: "); // print the description for the
list
lst1.displayList(); // print the contents of the list lst1; post
swap()
} // end main()
} // end class
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
class FirstLastList
{
private Link first; // ref to first link
private Link last; // ref to last link
//
-------------------------------------------------------------
public FirstLastList() // constructor
{
first = null; // no links on list yet
last = null;
}
//
-------------------------------------------------------------
public boolean isEmpty() // true if no links
{ return first==null; }
//
-------------------------------------------------------------
public void insertFirst(long dd) // insert at front of list
{
Link newLink = new Link(dd); // make new link
if( isEmpty() ) // if empty list,
last = newLink; // newLink <-- last
newLink.next = first; // newLink --> old first
first = newLink; // first --> newLink
}
//
-------------------------------------------------------------
public void insertLast(long dd) // insert at end of list
{
Link newLink = new Link(dd); // make new link
if( isEmpty() ) // if empty list,
first = newLink; // first --> newLink
else
last.next = newLink; // old last --> newLink
last = newLink; // newLink <-- last
}
//
-------------------------------------------------------------
public long deleteFirst() // delete first link
{
// (assumes non-empty list)
long temp = first.dData;
if(first.next == null) // if only one item
last = null; // null <-- last
first = first.next; // first --> old next
return temp;
}
//
-------------------------------------------------------------
public void displayList()
{
System.out.print("List (first-->last): ");
Link current = first; // start at beginning
while(current != null) // until end of list,
{
current.displayLink(); // print data
current = current.next; // move to next link
}
System.out.println("");
}
//
-------------------------------------------------------------
public void join(FirstLastList otherList)
{
Link current = otherList.first; // start at beginning
while(current != null) // until end of list,
{
this.insertLast(current.dData);
current = current.next; // move to next link
}
otherList.first=null;
}
public void swap()
{
int count = 0;
Link current = first; // start at beginning
while(current != null) // until end of list,
{
count++;
current = current.next; // move to next link
if(count < 2)
{
System.out.println("There is not enough element in the
list.");
}
else
{
long firstData = first.dData; // store the data of the first
node
long lastData = current.dData; // please use current object of the
Link class / store the data of last node
first.dData = lastData; // swap
current.dData = firstData; // swap
}
}
}
}
class Link
{
public long dData; // data item
public Link next; // next link in list
//
-------------------------------------------------------------
public Link(long d) // constructor
{ dData = d; }
//
-------------------------------------------------------------
public void displayLink() // display this link
{ System.out.print(dData + " "); }
//
-------------------------------------------------------------
} // end class Link
////////////////////////////////////////////////////////////////
class FirstLastApp
{
public static void main(String[] args)
{ // make a new list
FirstLastList lst1 = new FirstLastList();
lst1.insertFirst(1);
lst1.insertLast(3);
lst1.insertLast(7);
lst1.insertLast(4);
System.out.print("List 1 is : ");
lst1.displayList();
FirstLastList lst2 = new FirstLastList();
lst2.insertFirst(2);
lst2.insertLast(4);
lst2.insertLast(5);
lst2.insertLast(8);
lst2.insertLast(6);
System.out.print("\nList 2 is : ");
lst2.displayList();
lst1.join(lst2);
System.out.print("\nAfter joining List 1 is : ");
lst1.displayList();
System.out.print("\nList 2 is : ");
lst2.displayList();
try
{
lst1.swap();
System.out.println("\nAfter swap the list 1 is : ");
lst1.displayList();
lst2.swap();
System.out.println("\nAfter swap the list 2 is : ");
lst2.displayList();
}
catch(Exception e)
{
System.out.println( "Exception:" + e);
}
} // end main()
} // end class FirstLastAppd
so swap method works after both the queues have been merged, the first and last element swap places. in this case 1 & 8 should swap places.
In: Computer Science
3.) The function remove of the class arrayListType removes only the
first occurrence of an element. Add the function removeAll as an
abstract function to the class arrayListType, which would remove
all occurrences of a given element. Also, write the definition of
the function removeAll in the class unorderedArrayListType and
write a program to test this function.
4.) Add the function min as an abstract function to the class
arrayListType to return the smallest element of the list. Also,
write the definition of the function min in the class
unorderedArrayListType and write a program to test this
function.
5.) Add the function max as an abstract function to the class
arrayListType to return the largest element of the list. Also,
write the definition of the function max in the class
unorderedArrayListType and write a program to test this
function.
#include <iostream>
#include <cassert>
#include "arrayListType.h"
using namespace std;
bool arrayListType::isEmpty() const
{
return (length == 0);
} //end isEmpty
bool arrayListType::isFull() const
{
return (length == maxSize);
} //end isFull
int arrayListType::listSize() const
{
return length;
} //end listSize
int arrayListType::maxListSize() const
{
return maxSize;
} //end maxListSize
void arrayListType::print() const
{
for (int i = 0; i < length; i++)
cout << list[i] << " ";
cout << endl;
} //end print
bool arrayListType::isItemAtEqual(int location, int item)
const
{
if (location < 0 || location >= length)
{
cout << "The location of the item to be removed "
<< "is out of range." << endl;
return false;
}
else
return (list[location] == item);
} //end isItemAtEqual
void arrayListType::removeAt(int location)
{
if (location < 0 || location >= length)
cout << "The location of the item to be removed "
<< "is out of range." << endl;
else
{
for (int i = location; i < length - 1; i++)
list[i] = list[i + 1];
length--;
}
} //end removeAt
void arrayListType::retrieveAt(int location, int& retItem)
const
{
if (location < 0 || location >= length)
cout << "The location of the item to be retrieved is "
<< "out of range" << endl;
else
retItem = list[location];
} //end retrieveAt
// Part 1 - retrieve at as a value return function with
assert
int arrayListType::retrieveAt(int location) const
{
assert(0 < location && location < length);
return list[location];
}
void arrayListType::clearList()
{
length = 0;
} //end clearList
arrayListType::arrayListType(int size)
{
if (size <= 0)
{
cout << "The array size must be positive. Creating "
<< "an array of the size 100." << endl;
maxSize = 100;
}
else
maxSize = size;
length = 0;
list = new int[maxSize];
} //end constructor
//Add the function removeAll as an abstract function
//which would remove all occurrences of a given element
arrayListType::~arrayListType()
{
delete[] list;
} //end destructor
arrayListType::arrayListType(const arrayListType&
otherList)
{
maxSize = otherList.maxSize;
length = otherList.length;
list = new int[maxSize]; //create the array
for (int j = 0; j < length; j++) //copy otherList
list[j] = otherList.list[j];
#include <iostream>
#include "unorderedArrayListType.h"
using namespace std;
void unorderedArrayListType::insertAt(int location,
int insertItem)
{
if (location < 0 || location >= maxSize)
cout << "The position of the item to be inserted "
<< "is out of range." << endl;
else if (length >= maxSize) //list is full
cout << "Cannot insert in a full list" << endl;
else
{
for (int i = length; i > location; i--)
list[i] = list[i - 1]; //move the elements down
list[location] = insertItem; //insert the item at
//the specified position
length++; //increment the length
}
} //end insertAt
void unorderedArrayListType::insertEnd(int insertItem)
{
if (length >= maxSize) //the list is full
cout << "Cannot insert in a full list." << endl;
else
{
list[length] = insertItem; //insert the item at the end
length++; //increment the length
}
} //end insertEnd
int unorderedArrayListType::seqSearch(int searchItem)
const
{
int loc;
bool found = false;
loc = 0;
while (loc < length && !found)
if (list[loc] == searchItem)
found = true;
else
loc++;
if (found)
return loc;
else
return -1;
} //end seqSearch
void unorderedArrayListType::remove(int removeItem)
{
int loc;
if (length == 0)
cout << "Cannot delete from an empty list." <<
endl;
else
cout << "put the search and code here - use removeAt"
<< " in ArrayListType" << endl;
} //end remove
//Finish implementing max and return the largest number
//int unorderedArrayListType::max() const
//{
// if (length == 0)
// {
// cout << "The list is empty. "
// << "Cannot return the smallest element." <<
endl;
// exit(0);
// }
//
// int largest = list[0];
//} //end max
void unorderedArrayListType::replaceAt(int location, int
repItem)
{
if (location < 0 || location >= length)
cout << "The location of the item to be "
<< "replaced is out of range." << endl;
else
list[location] = repItem;
} //end replaceAt
//
// Implement in class remove all occurences of a certain
value
//void unorderedArrayListType::removeAll(int removeItem)
//{
// int loc;
//
// if (length == 0)
// cout << "Cannot delete from an empty list." <<
endl;
// else
// {
// loc = 0;
//
// }
//} ////end removeAll
//int unorderedArrayListType::min() const
//{
// if (length == 0)
// {
// cout << "The list is empty. "
// << "Cannot return the smallest element." <<
endl;
// exit(0);
// }
//
//
//
//} //end min
unorderedArrayListType::unorderedArrayListType(int size)
: arrayListType(size)
{
} //end constructor
In: Computer Science
For this program you will add and test 2 new member functions to the class in
//************************ intSLList.h **************************
// singly-linked list class to store integers
#ifndef INT_LINKED_LIST
#define INT_LINKED_LIST
class IntSLLNode {
public:
IntSLLNode() {
next = 0;
}
IntSLLNode(int el, IntSLLNode *ptr = 0) {
info = el; next = ptr;
}
int info;
IntSLLNode *next;
};
class IntSLList {
public:
IntSLList() {
head = tail = 0;
}
~IntSLList();
int isEmpty() {
return head == 0;
}
void addToHead(int);
void addToTail(int);
int deleteFromHead(); // delete the head and return its info;
int deleteFromTail(); // delete the tail and return its info;
void deleteNode(int);
bool isInList(int) const;
void printAll() const;
private:
IntSLLNode *head, *tail;
};
#endif
The two member functions are:
insertByPosn(int el, int pos)
Assuming that the positions of elements of a list begin numbering at 1 and continue to the end of the list, you will insert a new node with info value el at position pos. pos will become the position of the new node in the modified list. For example, if pos = 1, insert the new node at the head of the list. If pos = 2, for example, insert the new node BEFORE the node currently at position 2. If the list is empty prior to insertion, insert the new node in the list and adjust head and tail pointers. If pos is too large, don't do anything. If pos is 0 or negative, don't do anything.
removeByPosn(int pos)
Assume position of elements are defined as above. If pos is zero or negative, do nothing. If the list is empty prior to the request to delete a node, do nothing. If pos is too large, do nothing.
To aid in verifying results, you should use the following modified version of printAll. This requires: #include <string>
void IntSLList::printAll(string locn) const {
cout << "Contents of the list " << locn << endl;
for (IntSLLNode *tmp = head; tmp != 0; tmp = tmp->next)
cout << tmp->info << " ";
if (head != 0)
cout << "Head is: " << head->info << " Tail is: " << tail->info << endl << endl;
}
For extra credit, you can also create the following:
reverseList()
Traverse the existing list beginning at the head and create a new (reversed) list with head newhead and tail newtail. Put new nodes in the new list by putting the new nodes at the head of the new list each time. Do not call any other member functions during this process. If the list to be reversed is empty, make sure that you account for this case. After the new (reversed) list is created, delete the old list using its destructor.
The test program to be used is:
int main()
{
IntSLList singly_linked_list = IntSLList();
singly_linked_list.addToHead(9);
singly_linked_list.addToHead(7);
singly_linked_list.addToHead(6);
singly_linked_list.printAll("at creation:");
singly_linked_list.insertByPosn(8, 2);
singly_linked_list.printAll("after insertion of 8 at position 2:");
singly_linked_list.insertByPosn(10, 4);
singly_linked_list.printAll("after insertion of 10 at position 4:");
singly_linked_list.insertByPosn(12, 6);
singly_linked_list.printAll("after insertion of 12 at position 6:");
singly_linked_list.insertByPosn(14, 8);
singly_linked_list.printAll("after attempted insertion of 14 at position 8:");
singly_linked_list.insertByPosn(5, 1);
singly_linked_list.printAll("after insertion of 5 at position 1:");
singly_linked_list.insertByPosn(4, 0);
singly_linked_list.printAll("after attempted insertion of 4 at position 0:");
singly_linked_list.removeByPosn(2);
singly_linked_list.printAll("after deletion of 6 at position 2:");
singly_linked_list.removeByPosn(6);
singly_linked_list.printAll("after deletion of 12 at position 6:");
singly_linked_list.removeByPosn(10);
singly_linked_list.printAll("after attempted deletion at position 10:");
// insert test for optional list reversal here
return (0);
}
The correct output from running the test program is:
Contents of the list at creation:
6 7 9 Head is: 6 Tail is: 9
Contents of the list after insertion of 8 at position 2:
6 8 7 9 Head is: 6 Tail is: 9
Contents of the list after insertion of 10 at position 4:
6 8 7 10 9 Head is: 6 Tail is: 9
Contents of the list after insertion of 12 at position 6:
6 8 7 10 9 12 Head is: 6 Tail is: 12
Contents of the list after attempted insertion of 14 at position 8:
6 8 7 10 9 12 Head is: 6 Tail is: 12
Contents of the list after insertion of 5 at position 1:
5 6 8 7 10 9 12 Head is: 5 Tail is: 12
Contents of the list after attempted insertion of 4 at position 0:
5 6 8 7 10 9 12 Head is: 5 Tail is: 12
Contents of the list after deletion of 6 at position 2:
5 8 7 10 9 12 Head is: 5 Tail is: 12
Contents of the list after deletion of 12 at position 6:
5 8 7 10 9 Head is: 5 Tail is: 9
Contents of the list after attempted deletion at position 10:
5 8 7 10 9 Head is: 5 Tail is: 9
In: Computer Science
Illustrate Approaches that develop students’ imagery and visualization skills. (Illustrate means to draw or include pictures to represent.)
In: Math