Questions
A Linked List of Integers File IntList.java contains definitions for a linked list of integers. The...

  1. A Linked List of Integers

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:

  • public IntList()—constructor; creates an empty list of integers
  • public void addToFront(int val)—takes an integer and puts it on the front of the list
  • public void addToEnd(int val)—takes an integer and puts it on the end of the list
  • public void removeFirst()—removes the first value from the list
  • public void print()—prints the elements in the list from first to last

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.

  1. public int length()—returns the number of elements in the list
  2. public String toString()—returns a String containing the print value of the list.
  3. public void removeLast()—removes the last element of the list. If the list is empty, does nothing.
  4. public void replace(int oldVal, int newVal)—replaces all occurrences of oldVal in the list with newVal.

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

in the pandas_names notebook, write python code to analyze and plot how popular your name is...

in the pandas_names notebook, write python code to analyze and plot how popular your name is compared to one of your family member..

alberto and arturo

if your name is not in the dataset use "penny"as a female name and "ken" as male name.

In: Computer Science

C++ language Using classes (OOD), design a system that will support lending various types of media...

C++ language

Using classes (OOD), design a system that will support lending various types of media starting with books. Program should be able to handle a maximum of 500 books. Program should meet at least the following requirements:

1. Define a base media class with a book class derived from it. (Specific class names determined by programmer.)

2. The classes should contain at least the following information: title, up to four authors, ISBN.

3. Define a collection class that will hold up to 500 books.

4. The program should be able to perform the following operations supported by the class definitions:

a) Load data from a drive

b)Sort and display the books by title

c)Sort and display the books by author

d)Add and remove books

Programming requirements: Must include examples of inheritance and composition

~~~Function/Class comments (Description, pre and post conditions)

~~~Internal comments for all functions

In: Computer Science

Python Program: Description Create an object-oriented program that uses inheritance to perform calculations on a rectangle...

Python Program:

Description
Create an object-oriented program that uses inheritance to perform calculations on a rectangle or a square.

Specifications

  • Use a Rectangle class that provides attributes to store the height and width of a rectangle. This class should also provide methods that calculate the perimeter and area of the rectangle.
  • Use a Square class that inherits the Rectangle class. This class should set the height and the width of the Rectangle superclass to the length that’s set in the Square subclass.
  • The program should determine whether the user wants to enter a rectangle or a square.
  • For a rectangle, the program should get the height and width from the user.
  • For a square, the program should get the length of the square from the user.

Sample Output (Your output should be similar or can be the same to the text in the following box)

Rectangle Calculator
Rectangle or square? (r/s): r
Height: 5
Width: 10
Perimeter: 30
Area: 50

Continue? (y/n): y

Rectangle or square? (r/s): s
Length: 5
Perimeter: 20
Area: 25

Continue? (y/n): n

Thank you for using my app.

In: Computer Science

In Python, Define an object-oriented class to represent a Sensorless Wheeled Robot, including: (a) class data...

In Python, Define an object-oriented class to represent a Sensorless Wheeled Robot, including:

(a) class data variables to store the robot’s x and y position.

(b) A class function or functions to move the robot by one distance unit in either positive or negative x, or positive or negative y dimensions. Include printed, informative output of each move and the resulting robot position

(c) A class function to navigate to the destination location by calling the class move functions (described above) • The destination object is passed in as a parameter to this function. • The obstacle position is also passed as a parameter to the function. • Reaching the destination does not require that the robot is rotated to ’face’ the destination in this model

In: Computer Science

construct flow chart for c program #include <stdio.h> #include <stdlib.h> #include <math.h> void brst(); void thight();...

construct flow chart for c program

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void brst();
void thight();
void wings();
void back();
void neck();
void menu();
void ex();

float price;
float total;
char choice;
int again;

void main()
{
menu();
}

void menu()
{
char choice = ' ' ;
  
printf("----------------------------------------------------------------------");
printf("\n Welcome to Chicken Chicky Place. \n ");
printf(" && Please select the chicken part that you would like to purchase. && \n\n");
printf(" [A] Breast\n");
printf(" [B] Thigh\n");
printf(" [C] Wings\n");
printf(" [D] Back\n");
printf(" [E] Neck\n");
printf("\n");
printf(" [F] Exit\n\n");
printf("Enter your choice here : ");
scanf("%c", &choice);
printf("----------------------------------------------------------------------");
  
{
if ((choice) == 'A' )
brst();
else
if ((choice) == 'B')
thight();
else
if ((choice) == 'C')
wings();
else
if ((choice) == 'D')
back();
else
if ((choice) == 'E')
neck();
else
if ((choice) == 'F')
ex();
else
if ((choice) != 'A' , 'B' , 'C' , 'D' ,'E', 'F')
{
printf("\n");
system("clear");
menu();
}
}
}
void brst()
{
int choice = 0;
int quantity = 0;
int again = 0;

printf("\n Welcome to Chicken Chicky Place. \n ");
printf(" $ Cooking Style $ \n\n");
printf(" && Please select the cooking that you would like && \n\n");
printf(" [1] ASAM PEDAS - RM 2.50\n");
printf(" [2] SAMBAL - RM 3.00\n");
printf(" [3] ROASTED - RM 5.00\n");
printf(" [4] GRILLED - RM 6.00\n");

printf("Enter your choice here : ");
scanf("%d", &choice);
{
if (choice == 1)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 2.50 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
brst();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 2)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 3.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
//Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
if (again == 1 )
brst();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 3 )
{
printf("Enter quantity (pieces): ");
scanf("%d", &quantity);
total = 5.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
brst();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 4 )
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 6.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
// Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
if (again == 1 )
{
brst();
}
else
if (again == 2 )
{
menu();
}
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if (choice != 1 , 2 , 3 )
{
printf("\n\n\t\t Invalid Choice Entered\n\n");
ex();
}
}
}

void thight()
{
int choice;
int quantity;
int again;

printf(" Welcome to Chicken Chicky Place. \n ");
printf(" $ Cooking style $ \n\n");
printf(" && Please select the cooking style that you would like to purchase. &&\n\n");
printf(" [1] ASAM PEDAS - RM 2.50\n");
printf(" [2] SAMBAL - RM 3.00\n");
printf(" [3] ROASTED - RM 5.00\n");
printf(" [4] GRILLED - RM 6.00\n");
  
printf("Enter your choice here : ");
scanf("%d", &choice);
{
if (choice == 1)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 2.50* quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
thight();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if ( choice == 2)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 3.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
if (again == 1 )
thight();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if ( choice == 3 )
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 5.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No :");
scanf("%d", &again);
system("clear");
if (again == 1 )
thight();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if ( choice == 4 )
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 6.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No :");
scanf("%d", &again);
system("clear");
if (again == 1 )
thight();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if (choice != 1 , 2 , 3)
{
printf("\n\n Invalid Choice Entered\n\n");
thight();
}
}

}

void wings()
{
int choice;
int quantity;
int again;


printf(" Welcome to Chicken Chicky Place. \n ");
printf(" $ Cooking style $ \n\n");
printf(" && Please select the cooking style that you would like to purchase. &&\n\n");
printf(" [1] ASAM PEDAS - RM 2.50\n");
printf(" [2] SAMBAL - RM 3.00\n");
printf(" [3] ROASTED - RM 5.00\n");
printf(" [4] GRILLED - RM 6.00\n");

printf("Enter your choice here : ");
scanf("%d", &choice);
{
if (choice == 1)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 2.50 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n ", total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
wings();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if ( choice == 2)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 3.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n ", total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
wings();
else
if (again == 2 )
menu();
else
if (again != 1 , 2 )
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if ( choice == 3 )
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 5.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No :");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
wings();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
  
}
}
else
if ( choice == 4 )
{
printf("Enter quantity (pieces): ");
scanf("%d", &quantity);
total = 6.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No :");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
wings();
else
if (again == 2 )
menu();
else
if (again != 1 , 2 )
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
  
}
}
else
if (choice != 1 , 2 )
{
printf("\n\n Invalid Choice Entered\n\n");
wings();
}
}
}

void back()
{
int choice = 0;
int quantity = 0;
int again = 0;

printf("\n Welcome to Chicken Chicky Place. \n ");
printf(" $ Cooking Style $ \n\n");
printf(" && Please select the cooking that you would like && \n\n");
printf(" [1] ASAM PEDAS - RM 2.50\n");
printf(" [2] SAMBAL - RM 3.00\n");
printf(" [3] ROASTED - RM 5.00\n");
printf(" [4] GRILLED - RM 6.00\n");

printf("Enter your choice here : ");
scanf("%d", &choice);
{
if (choice == 1)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 2.50 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
  
if (again == 1 )
back();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 2)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 3.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
//Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
if (again == 1 )
back();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 3 )
{
printf("Enter quantity (KG): ");
scanf("%d", &quantity);
total = 5.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
back();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 4 )
{
printf("Enter quantity (KG) : ");
scanf("%d", &quantity);
total = 6.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
// Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
if (again == 1 )
{
back();
}
  
else
if (again == 2 )
{
menu();
}
  
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if (choice != 1 , 2 , 3 )
  
printf("\n\n\t\t Invalid Choice Entered\n\n");
ex();
}
}

void neck()
{
int choice = 0;
int quantity = 0;
int again = 0;
  
printf("\n Welcome to Chicken Chicky Place. \n ");
printf(" $ Cooking Style $ \n\n");
printf(" && Please select the cooking that you would like && \n\n");
printf(" [1] ASAM PEDAS - RM 2.50\n");
printf(" [2] SAMBAL - RM 3.00\n");
printf(" [3] ROASTED - RM 5.00\n");
printf(" [4] GRILLED - RM 6.00\n");

printf("Enter your choice here : ");
scanf("%d", &choice);
{
if (choice == 1)
{
printf("Enter quantity (KG) : ");
scanf("%d", &quantity);
total = 2.50 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
  
if (again == 1 )
neck();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 2)
{
printf("Enter quantity (KG) : ");
scanf("%d", &quantity);
total = 3.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
//Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
  
if (again == 1 )
neck();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 3 )
{
printf("Enter quantity (KG): ");
scanf("%d", &quantity);
total = 5.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
neck();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 4 )
{
printf("Enter quantity (KG) : ");
scanf("%d", &quantity);
total = 6.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
// Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
if (again == 1 )
{
neck();
}
else
if (again == 2 )
{
menu();
}
  
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if (choice != 1 , 2 , 3 )
{
printf("\n\n\t\t Invalid Choice Entered\n\n");
ex();
}
}
}

void ex() // Exit Screen
{
printf("\n");
printf(" Thank You Very Much \n ");
printf(" && Please come again. && \n\n");
}

In: Computer Science

Python: def factors(matrix, factor): The matrix is a 3D list of integers. factors are either one,...

Python:

def factors(matrix, factor):

The matrix is a 3D list of integers.

factors are either one, two, or three

If the factor is 'one' it will return a the first value from each list

if the factor is 'two' it will return the second value, and same for the third.

Example;

input = [ [ [1, 2, 3], [3, 2, 9], [9, 8, 6] ],

[ [0, 0, 4], [8, 9, 0], [5, 2, 1] ],

[ [0, 1, 1], [5, 5, 9], [3, 8, 4] ] ], 'one')

output = [ [1, 3, 9], [0, 8, 5], [0, 5, 3] ]

In: Computer Science

Explain the shortest seek time first, first come first serve, scan, and c scan algorithms of...

Explain the shortest seek time first, first come first serve, scan, and c scan algorithms of storage management algorithms with the single of the sequence (93, 176, 42, 148, 14, 180).

Draw good diagrams and CALCULATE the total distance traveled and the total waiting time.

initial position is at 50

In: Computer Science

lets say i have a set of data and I want to build an ensemble classifier...

lets say i have a set of data and I want to build an ensemble classifier and wanted to do models for a python machine learning project, how would the startup/build up to put all of that together.

In: Computer Science

1. Give, using “big oh” notation, the worst case running times of the following procedures as...

1. Give, using “big oh” notation, the worst case running times of the following procedures as a function of n ≥ 0.

(a). procedure unknown

for i =1 to n – 1 do

for j =i + 1 to n do

for k =1 to j do

{statements requiring O(1) time}

endfor

endfor

endfor

(b). procedure quiteodd

for i =1 to n do

if odd(i) then

for j =i to n do

x ← x + 1

                           endfor

                           for j =1 to i do

                                        y ← y + 1

                           endfor

             endif

endfor

(c). function recursion (n)

if n <= 1 then

return (1)

else

return (recursion (n – 1) + recursion (n – 1))

endif

2.

The function max (i, n) given below returns the largest element in positions i through i + n – 1 of an integer array A. Assume for convenience that n is a power of 2.

function max(i, n)

if n = 1 then

             return (A[i])

else

             m1 ← max (i, n/2)

             m2 ← max (i + n/2, n/2)

if m1 < m2 then

return (m2)

else

             return (m1)

endif

             endif

(a). Let T(n) denote the worst-case time taken by max with the second argument n. Note that n is the number of elements of which the largest is to be determined. Write an equation expressing T(n) in terms of T(j) for j < n and constants that represent the times taken by statements of the program.

(b). Obtain a big theta bound on T(n).  

In: Computer Science

What is the legal business structure of the company (sole proprietorship, partnership, corporation, LLC/LLP, etc.)? Why...

What is the legal business structure of the company (sole proprietorship, partnership, corporation, LLC/LLP, etc.)? Why was this legal business structure chosen?

In: Computer Science

(16) Convert the following numbers into 8-bit hexadecimal values. Number Binary Complemented Two's Complement Hex -102...

(16) Convert the following numbers into 8-bit hexadecimal values.
Number Binary Complemented Two's Complement Hex
-102
-87
-31
(17) Add up the first two binary numbers from the previous problem in Two’s complement form.  
(17a) What is the sum in hex?
(17b) What is the sign bit?
(17c) Did overflow occur?
(17d) Code this up in 68K and include a screenshot of the output here as well as your source & listing files. What happens?

Please show work!

If you can't do 17 d I understand, no worries!!!

In: Computer Science

I need to write a C++ program that will generate random numbers between the ranges of...

I need to write a C++ program that will generate random numbers between the ranges of your own choice and within the random numbers, indicate the maximum, minimum and the average of the random numbers.

In: Computer Science

Given a csv file named “result_niwtawq.csv”, extract the data from it. Store the first column data...

Given a csv file named “result_niwtawq.csv”, extract the data from it. Store the first column data to a list named time, second column data to a list named Turb_annual_avg, third column data to a list named Turb_min, fourth column data to a list named Turb_max, fifth column data to a list named Turb_mean. Calculate and write the average, maximumand minimumof Turb_min to a file named “lab3_output.txt”.

https://dropbox.cse.sc.edu/pluginfile.php/256369/mod_assign/introattachment/0/result_niwtawq.csv?forcedownload=1

In: Computer Science

The First National Bank of Parkville recently opened up a new “So You Want to Be...

The First National Bank of Parkville recently opened up a new “So You Want to Be a Millionaire” savings account. The new account works as follows:

  • The bank doubles the customer’s balance every year until the customer’s balance reaches one million.
  • The customer isn’t allowed to touch the money (no deposits or withdrawals) until the customer’s balance reaches one million. If the customer dies before becoming a millionaire, the bank keeps the customer’s balance.
  • Note:Customers close to $1,000,000 tend to get “accidentally” run over in the bank’s parking lot.

Write a java program that prompts the user for a starting balance and then prints the number of years it takes to reach $100,000 and also the number of years it takes to reach $1,000,000.

Sample session:

Enter starting balance: 10000
It takes 4 years to reach $100,000.
It takes 7 years to reach $1,000,000.

In: Computer Science