Questions
Describe an algorithm to solve the variant of the Towers of Hanoi in as few moves...

Describe an algorithm to solve the variant of the Towers of Hanoi in as few moves as possible. Prove that your algorithm is correct. Initially, all the n disks are on peg 1, and you need to move the disks to peg 2. You are not allowed to put a bigger disk on top of a smaller disk.

1. Suppose you are forbidden to move any disk directly between peg 1 and peg 2, and every move must involve (the third peg). Exactly (i.e., not asymptotically) how many moves does your algorithm make as a function of n?

In: Computer Science

Write a program that reads a file line by line, and reads each line’s tokens to...

Write a program that reads a file line by line, and reads each line’s tokens to create a Student object that gets inserted into an ArrayList that holds Student objects.  Each line from the file to read will contain two strings for first and last name, and three floats for three test grades.  After reading the file and filling the ArrayList with Student objects, sort the ArrayList and output the contents of the ArrayList so that the students with the highest average are listed on top.

The Student class should have instance data for first and last name, and a float array to hold three test grades.  Create getters and setters for first and last name.  Create one getter and one setter for inserting tests into the array.  Don’t forget to verify that the quiz grades are within a range that makes sense before you insert them into the array.  Also, verify that you do not go outside the index range of the array when inserting quizzes.  Create a method to calculate and return test average. Also, override the toString method and the equals method to something that make sense. Also, implement the Comparable interface on the Student class so that when you compare Student objects by comparing the student's test average. If the average is the same when comparing, then compare the last names. If the last names are the same, then compare the first names.

Here is the file that the program should read:

Text File:

Frank Hanford 78.5 65.9 98.2
John Blake 93.1 85.9 89.1
Alex Sanders 87.1 56.9 67.2
Jane Hope 72.1 85.1 77.9
Donald Davidson 85.1 72.1 77.9
Alan Davidson 77.9 72.1 85.1
Perkins Jenkins 87.5 75.9 90.1
Barbara Thompson 90.1 89.9 99.7
Michael Jones 78.1 69.9 81.2

In: Computer Science

Pick one area where you think Blockchain Technology could be proposed as a solution and briefly...

Pick one area where you think Blockchain Technology could be proposed as a solution and briefly explain your proposed solution. Your final document should include an Abstract and a Conclusion

In: Computer Science

The Lucas Numbers are a sequence very similar to the Fibonacci Sequence, the only difference being...

The Lucas Numbers are a sequence very similar to the Fibonacci Sequence, the only difference being that the Lucas Numbers start with L0 = 2 and L1 = 1 as opposed to Fibonacci’s F0 = 0 and F1 = 1. Concretely, they are defined by L0 = 2, L1 = 1, and Ln := Ln−1 + Ln−2 for n > 1. Write a function in C++ that takes an integer argument N and returns the sum of the first N + 1 even Lucas Numbers.

In: Computer Science

Write a C code to let the main thread create N child threads, where each created...

Write a C code to let the main thread create N child threads, where each created thread will randomly generate an integer between 0 to 10 and put it into a global array variable. After that, the main thread will calculate the sum of all the generated integers. N should be input as a command line argument.

Complete the following C code by filling all “???”s in the code sketch. NOTE: when you compile the code, you need to add the parameter “-lpthread” to “gcc”, e.g., “gcc YourCode.c -lpthread”

// include the header file that allows us to use pthread
#include <???>
#include <stdio.h>
// include the header file that allows us to use dynamic memory management 
#include <???>
// define a pointer to point to an array to hold the randomly generated integers
int *a;

// define the function used to create a thread
???runner(???param);

int main(int argc, char *argv[])
{
        if (argc != 2)
        {
                fprintf(stderr, "usage: %s <integer value>\n", argv[0]);
                return -1;
        }

        int N = atoi(argv[1]);

        if (N<=0)
        {
                fprintf(stderr, "%d must be > 0\n", N);
                return -1;
        } 

        // define an array to hold the threads to be created
        ???              workers[N]; 

        // define a set of thread attributes for creating threads
???                     attr;

        // define a variable later used for “for” loop
int i;

        // use dynamic memory management to create an array to hold the integers
        a = ???                                         ;

        // seed the random number generator
        srandom((unsigned)time(NULL));

        // initialize the default thread attributes
        ???





        // use “for” loop to create the threads, where the index of the created thread in workers
// array should be passed to the thread as the parameter
        ???





        // use “for” loop to wait for all the threads to exit
        ???




        // calculate the sum
        int sum = 0;

        for (i=0; i<N; i++) sum += a[i];

        printf("sum = %d\n", sum);

        // free the dynamically created array
        ???

}

// The created thread will start its execution from this function
???             runner(???              param)
{
        // get the index of the thread in workers array and put it to “thread_index”
        int thread_index = ???                          ;       

        // randomly generate an integer between 0 to 10
        a[thread_index] = random()%11;  

        // print the information on the screen
        printf("Thread %d generates integer %d ...\n", thread_index, a[thread_index]);

        // terminate the thread
        ???



}

In: Computer Science

Please create a C++ program that will ask a high school group that is made of...

Please create a C++ program that will ask a high school group that is made of 5 to 17 students to sell candies for a fund raiser. There are small boxes that sell for $7 and large ones that sell for $13. The cost for each box is $4 (small box) and $6 (large box). Please ask the instructor how many students ended up participating in the sales drive (must be between 5 and 17). The instructor must input each student’s First name that sold items and enter the number of each box sold each (small or large). Calculate the total profit for each student and at the end of the program, print how many students participated and the total boxes sold for each (small and large) and finally generate how much profit the group made.

In: Computer Science

In python, write a program that asked the user to enter the monthly costs for the...

In python, write a program that asked the user to enter the monthly costs for the following expenses incurred from operating his automobile: loan payment, insurance, gas, oil, tires, and maintenance. The program should display total monthly cost and annual cost. Also, should contain main and calcExpenses functions, calcExpenses should only calculate the expenses and everything else should happen in the main function.

In: Computer Science

Please comment, exactly how this program works? #include <stdio.h> int main() { int i,j; int a[1000];...

Please comment, exactly how this program works?

#include <stdio.h>

int main()
{
int i,j;
int a[1000];

for(i=0;i<1000;i++)
a[i]=1;
  
for(i=2;i<1000;i++)
{
if(a[i]==1){
for(j=i+1;j<1000;j++)
{if(j%(i)==0)
a[j]=0;
}
}
}
printf("print numbers are:\n");
for(i=2;i<=1000;i++)
if(a[i]==1)
printf("%d, ",i);
}

In: Computer Science

Briefly explain the terms used in object-oriented programming with examples.

Briefly explain the terms used in object-oriented programming with examples.

In: Computer Science

Writing a caesar cipher in ARM assembly. INSTRUCTIONS: Step 1: The first thing you should do...

Writing a caesar cipher in ARM assembly.

INSTRUCTIONS:

Step 1:
    The first thing you should do is modify the case conversion program String.s (provided)
    Instead of subtracting 32 from all numbers you want to add a constant number which we will call the key.
    Assume that all input will be lowercase. 
    So it'll look like this,
        k = 2;
        letter = 'a';
        newletter = k+letter;
    Above is pseudocode and ABOVE NOT ASSEMBLY CODE DO NOT COPY.
    Use bl puts to show that everything is working correctly.
    You should hard code the plaintext in the assembly file.
Step 2:
    If the key + letter is bigger is 'z' then you have to subtract 26.
    If the key + letter is less than 'a' then you have to add 26.

STRING.S

.text
.global main

main:
    ldr r4,=string

get_another_byte:
    ldrb r5,[r4]

    cmp r5,#'a'
#    blt keep_going
#    cmp r5,#'z'
#    bgt keep_going

    subeq r5,#32
    strbge r5,[r4]

keep_going:
    add r4,#1
    cmp r5,#0
    bne get_another_byte

    ldr r0,=temp
    str lr,[r0]

    ldr r0,=string
    bl puts

    ldr r0,=temp
    ldr lr,[r0]

    bx lr

.data

string:
.asciz "This is a string |"


temp:
    .word 0

In: Computer Science

C# Programming using Windows Form 1. Define a variable named isTrue that stores a value of...

C# Programming using Windows Form


1. Define a variable named isTrue that stores a value of
whether something is true or false. Set this variable
   to the negative. Output this variable to the txtIsTrue textbox.

2. Define a variable named favoriteGame that could store
the name of a game. Set this variable's value to your favorite game. Output this variable to the txtFavoriteGame textbox.

3.. Define a variable named pi that can store real numbers. initialize it to a value of 3.14. Output the value to txtPi

4. Create a control structure that will print out "That's Right"
to a textbox named txtRightOrWrong if isTrue from the 1st problem is positive result and "Nope" if isTrue is not true.

5. Write a loop of your choosing to print out the following
numbers to txtLoop textbox: -1 -3 -5 -7 -9 -13 -15 -17
  

6. Write a nested loop to print out the following to txtNestedLoop:
0
0 1
0 2 4
0 3 6 9
0 4 8 16 32
  

7. Call the method from number 8 and output the result to xtMethodCall textbox.

8. Create a method called Foo that takes an integer from
txtForFoo and returns Bar the amount of times entered.
ex: txtForFoo is 2 the result is "Bar Bar".

9. Add a try catch block in the Foo method to catch the  generic exception and one other exception of your choosing
bonus 5 pts if it applies to the method.

10. Create an array of 2 DateTime objects. Set the first
to the current date and time. Set the second to the
current date. Output both dates with a space between
them to txtDates.

/* ***BONUS***
Time how long it takes from the loading of the program
until the run button finishes running the first time it
is clicked.

In: Computer Science

I have a question that I would like an explanation on how an ethical hacker uses...

I have a question that I would like an explanation on how an ethical hacker uses the information derived by use of Nslookup and Whois to mitigate network connectivity issues. If you could explain in a paragraph it would help me tremendously.


In: Computer Science

Consider the following sorted int array: 1 3 4 5 7 9 10 12 If we...

Consider the following sorted int array:

1 3 4 5 7 9 10 12

If we search for the key value 10 in the array using the binary search algorithm, what is the sequence of indices that will be accessed in the array?

(Hint: For a sublist between index values low and high, the middle index is calculated using: (low + high) / 2. So you need to show the sequence of indices of the middle index in each pass.)

Question 40 options:

In: Computer Science

Q2. Write an 8051 C program that uses 3 temperature sensors (TS1, TS2, TS3),   3 LEDs...

Q2. Write an 8051 C program that uses 3 temperature sensors (TS1, TS2, TS3),   3 LEDs (GreenLED, BlueLED and RedLED) and 1 buzzer (BUZZ). Monitor the temperature sensors such that whenever any of the sensor goes high, the buzzer will produce a sound and at the same time, its corresponding LED blinks 3 times. You may use any of the I/O Port Pins.    
SOLUTION:
C PROGRAM

In: Computer Science

Active Directory Domain Services Installation Wizard

Active Directory Domain Services Installation Wizard

In: Computer Science