A 0.41 μF and a 0.65 μF capacitor are connected in series to a
15 V battery.
Part A] Calculate the potential difference across each
capacitor.
Part B] Calculate the charge on each capacitor.
Part C] Repeat part A assuming the two capacitors are in
parallel.
Part D] Repeat part B assuming the two capacitors are in
parallel.
In: Physics
In the case of Kimbrell’s of Sanford, Inc. v. KPS, Inc.:
a. Kimbrell’s was required to file a financing statement to perfect it security interest.
b. Burns signed a security agreement granting Kimbrell’s a purchase money security interest in the VCR.
c. Kimbrell’s was not entitled to recover possession of the VCR when it filed its cause of action.
d. Kimbrell’s filed a financial statement to perfect its purchase money security interest in the VCR.
In: Accounting
A 14.7 μF capacitor is charged to a potential of 55.0 V and then discharged through a 75.0 Ω resistor.
(a) How long after discharge begins does it take for the capacitor to lose 90.0% of the following?
(i) its initial charge: _______s
(ii) its initial energy: _______s
(b) What is the current through the resistor at both times in part
(a)?
(i) at tcharge: ________A
(ii) at tenergy: ________A
In: Physics
Using swap.s as a starting point and conforming to the stack frame structure explained above, provide MINIMAL MIPS assembly codes which EXACTLY match the desired behavior of C program below. Note that the selection function does not return value, instead it stores the outcome into the address (*list, a pointer of the array data, means the beginning address of the array data) provided by the caller. Hence, the caller needs to allocate a local variable, temp, in the stack.
void main()
{ int data[10] = {55, 44, 22, 33, 77, 0, 11, 99, 88, 44};
int size = 10, i;
selection(data, 0, 0, size, 1);
printf("The sorted list in ascending order is\n");
for (i = 0; i < size; i++)
{ printf("%d ", data[i]);
} } void selection(int *list, int i, int j, int size, int flag)
{
int temp;
if (i < size - 1)
{
if (flag)
{
j = i + 1;
}
if (j < size)
{
if (list[i] > list[j])
{
temp = list[i];
list[i] = list[j];
list[j] = temp;
}
selection(list, i, j + 1, size, 0);
}
selection(list, i + 1, 0, size, 1);
}
}
In: Computer Science
////Fixme(1) add a statement to import ArrayList class
public class ListManipulation {
public static void main(String[] args) {
//Fixme(2) create an ArrayList of integers and name the ArrayList
list.
//Fixme(3) add the following numbers to the list: 10, 15, 7, -5,
73, -11, 100, 20, 5, -1
displayList(list);
System.out.println();
displayListBackwards(list);
}
public static void displayList(ArrayList<Integer> list)
{
for(Integer i: list)
System.out.print(i + " ");
}
//Fixme(4) define a method displayListBackwards, which takes an
ArrayList as a parameter and returns nothing.
//The method displays each element in the list in the reverse
order, and adds a space after each element.
//Fixme(5) define a method maxElement, which takes an ArrayList as
a parameter and returns the maximum element in the list.
//Fixme(6) define a method searchElement, which takes two
parameters.
//The first parameter is an ArrayList and the second is an int type
value.
//The method searches for value in the list.
//If the value is found in the list, the method returns its index,
otherwise, it returns -1.
//Fixme(7) define a method eventCount, which takes an ArrayList as
a parameter and returns the number of even element in the
list.
}
In: Computer Science
In C++
Question 1) Theoretical Questions
1.1) Why is it better to store the tail pointer rather than the head pointer in a circular singular linked list?
1.2) What are the main advantages of a doubly linked list compared to a singularly linked list?
Question 2) Practical Questions
Suppose a doubly-linked list makes use of a class called DLNode, defined as follows:
template<class T>
struct DLNode
{
T data;
DLNode<T> * next;
DLNode<T> * prev;
};
Further suppose the linked list class maintains a pointer to the first node in the list as a member variable called DLNode<T> *head.
2.1) Suppose left and right are variables of type DLNode<int>* pointing to two nodes that are adjacent in a doubly-linked list, i.e left->next points to right. Both nodes have predecessors and successors in the list. Write the code taht will swap the nodes in the list by adjusting pointers. Do not change the value of the data field of either nodes.
2.2) Given a circular doubly-linked list of 5 integers (1,2,3,4,5), write a function printAll() to output the list in the following order: (1,5,2,4,3). The function should work on any odd number of nodes.
In: Computer Science
Hi!
I 'm writing a code for a doubly linked list and this is the header file
#include<iostream>
#include <string>
using namespace std;
struct node
{
int data;
node *next,*prev;
node(int d,node *p=0,node *n=0)
{
data=d; prev=p; next=n;
}
};
class list
{
node *head,*tail;
public:
list();
bool is_empty();
int size();
void print();
void search();
int search2(int el);
void add_last(int el);
void add_first(int el);
bool add_pos();
bool delete_first();
bool delete_last();
void delete_pos(int pos);
void delete_el();
void add_sorted();
};
i want to write a function that split the list into 2 list from a specific number
ex. 5 4 7 2 8
if I spilt it from number 4 it will be 5 in the first list and 7 2 8 in the second list and number 4 will go to the List that contains fewer element so first list will have 5 4 and second list 7 2 8 if the have the same number of element the number that you were separated from it goes to any list it does not matter
In: Computer Science
File IntList.java contains definitions for a linked list of integers. The class contains an inner class IntNode that holds information for a single node in the list (a node has a value and a reference to the next node) and the following IntList methods:
File IntListTest.java contains a driver that allows you to experiment with these methods. Save both of these files to your directory, compile and run IntListTest, and play around with it to see how it works. Then add the following methods to the IntList class. For each, add an option to the driver to test it.
Note that you can still use the old nodes; just replace the values stored in those nodes.
// ***************************************************************
// FILE: IntList.java
//
// Purpose: Defines a class that represents a list of integers
//
// ***************************************************************
public class IntList
{
private IntNode front; //first node in list
//-----------------------------------------
// Constructor. Initially list is empty.
//-----------------------------------------
public IntList()
{
front = null;
}
//-----------------------------------------
// Adds given integer to front of list.
//-----------------------------------------
public void addToFront(int val)
{
front = new IntNode(val,front);
}
//-----------------------------------------
// Adds given integer to end of list.
//-----------------------------------------
public void addToEnd(int val)
{
IntNode newnode = new IntNode(val,null);
//if list is empty, this will be the only node in it
if (front == null)
front = newnode;
else
{
//make temp point to last thing in list
IntNode temp = front;
while (temp.next != null)
temp = temp.next;
//link new node into list
temp.next = newnode;
}
}
//-----------------------------------------
// Removes the first node from the list.
// If the list is empty, does nothing.
//-----------------------------------------
public void removeFirst()
{
if (front != null)
front = front.next;
}
//------------------------------------------------
// Prints the list elements from first to last.
//------------------------------------------------
public void print()
{
System.out.println("--------------------");
System.out.print("List elements: ");
IntNode temp = front;
while (temp != null)
{
System.out.print(temp.val + " ");
temp = temp.next;
}
System.out.println("\n-----------------------\n");
}
//*************************************************************
// An inner class that represents a node in the integer list.
// The public variables are accessed by the IntList class.
//*************************************************************
private class IntNode
{
public int val; //value stored in node
public IntNode next; //link to next node in list
//------------------------------------------------------------------
// Constructor; sets up the node given a value and IntNode reference
//------------------------------------------------------------------
public IntNode(int val, IntNode next)
{
this.val = val;
this.next = next;
}
}
}
// ***************************************************************
// IntListTest.java
//
// Driver to test IntList methods.
// ***************************************************************
import java.util.Scanner;
public class IntListTest
{
private static Scanner scan;
private static IntList list = new IntList();
//----------------------------------------------------------------
// Creates a list, then repeatedly prints the menu and does what
// the user asks until they quit.
//----------------------------------------------------------------
public static void main(String[] args)
{
scan = new Scanner(System.in);
printMenu();
int choice = scan.nextInt();
while (choice != 0)
{
dispatch(choice);
printMenu();
choice = scan.nextInt();
}
}
//----------------------------------------
// Does what the menu item calls for.
//----------------------------------------
public static void dispatch(int choice)
{
int newVal;
switch(choice)
{
case 0:
System.out.println("Bye!");
break;
case 1: //add to front
System.out.println("Enter integer to add to front");
newVal = scan.nextInt();
list.addToFront(newVal);
break;
case 2: //add to end
System.out.println("Enter integer to add to end");
newVal = scan.nextInt();
list.addToEnd(newVal);
break;
case 3: //remove first element
list.removeFirst();
break;
case 4: //print
list.print();
break;
default:
System.out.println("Sorry, invalid choice")
}
}
//-----------------------------------------
// Prints the user's choices
//-----------------------------------------
public static void printMenu()
{
System.out.println("\n Menu ");
System.out.println(" ====");
System.out.println("0: Quit");
System.out.println("1: Add an integer to the front of the list");
System.out.println("2: Add an integer to the end of the list");
System.out.println("3: Remove an integer from the front of the list");
System.out.println("4: Print the list");
System.out.print("\nEnter your choice: ");
}
}
In: Computer Science
*Explain the difference between procedural and nonprocedural
languages. Use specific procedural
and nonprocedural languages of your choice to illustrate the
difference.
*Explain what is backtracking in Prolog systems, and why
backtracking is necessary.
*Explain resolution and unification in Prolog, and their
relationship.
*Write Prolog programs for the following problems:
a) Reverse a list.
b) Find the length of a list.
c) Find the average of a list of numbers.
*Write Scheme programs for the following problems:
a) Reverse a list.
b) Find the length of a list.
c) Find the average of a list of numbers.
In: Computer Science
You are given a singly linked list. Write a function to find if the linked list contains a cycle or not. A linked list may contain a cycle anywhere. A cycle means that some nodes are connected in the linked list. It doesn't necessarily mean that all nodes in the linked list have to be connected in a cycle starting and ending at the head. You may want to examine Floyd's Cycle Detection algorithm.
/*This function returns true if given linked list has a cycle, else returns false. */ static boolean hasCycle( Node head)
In: Computer Science